Proper call requests for callee
This commit is contained in:
parent
e9957ac12f
commit
333dc17c0a
6 changed files with 54 additions and 93 deletions
|
@ -2517,7 +2517,7 @@
|
|||
"description": "Shown in reaction viewer as the title for the 'all' category"
|
||||
},
|
||||
"MessageRequests--message-direct": {
|
||||
"message": "Let $name$ message you and share your name and photo with them? They won’t know you’ve seen their messages until you accept.",
|
||||
"message": "Let $name$ message you, call you, and share your name and photo with them? They won’t know you’ve seen their messages until you accept.",
|
||||
"description": "Shown as the message for a message request in a direct message",
|
||||
"placeholders": {
|
||||
"name": {
|
||||
|
@ -2527,7 +2527,7 @@
|
|||
}
|
||||
},
|
||||
"MessageRequests--message-direct-blocked": {
|
||||
"message": "Let $name$ message you and share your name and photo with them? You won't receive any messages until you unblock them.",
|
||||
"message": "Let $name$ message you, call you, and share your name and photo with them? You won't receive any messages until you unblock them.",
|
||||
"description": "Shown as the message for a message request in a direct message with a blocked account",
|
||||
"placeholders": {
|
||||
"name": {
|
||||
|
|
|
@ -131,7 +131,7 @@
|
|||
"redux-ts-utils": "3.2.2",
|
||||
"reselect": "4.0.0",
|
||||
"rimraf": "2.6.2",
|
||||
"ringrtc": "https://github.com/signalapp/signal-ringrtc-node.git#7563474ee920d4535535ae01476ced3e8dc668d1",
|
||||
"ringrtc": "https://github.com/signalapp/signal-ringrtc-node.git#bfa94f2749324029ed4b4c51dfaf3e27bafe3eed",
|
||||
"sanitize-filename": "1.6.3",
|
||||
"sanitize.css": "11.0.0",
|
||||
"semver": "5.4.1",
|
||||
|
|
|
@ -4,12 +4,16 @@ import {
|
|||
Call,
|
||||
CallEndedReason,
|
||||
CallId,
|
||||
CallingMessage,
|
||||
CallLogLevel,
|
||||
CallSettings,
|
||||
CallState,
|
||||
CanvasVideoRenderer,
|
||||
DeviceId,
|
||||
GumVideoCapturer,
|
||||
HangupMessage,
|
||||
HangupType,
|
||||
OfferType,
|
||||
RingRTC,
|
||||
UserId,
|
||||
} from 'ringrtc';
|
||||
|
@ -21,7 +25,7 @@ import {
|
|||
ActionsType as UxActionsType,
|
||||
CallDetailsType,
|
||||
} from '../state/ducks/calling';
|
||||
import { CallingMessageClass, EnvelopeClass } from '../textsecure.d';
|
||||
import { EnvelopeClass } from '../textsecure.d';
|
||||
import {
|
||||
AudioDevice,
|
||||
CallHistoryDetailsType,
|
||||
|
@ -398,7 +402,7 @@ export class CallingClass {
|
|||
|
||||
async handleCallingMessage(
|
||||
envelope: EnvelopeClass,
|
||||
callingMessage: CallingMessageClass
|
||||
callingMessage: CallingMessage
|
||||
): Promise<void> {
|
||||
window.log.info('CallingClass.handleCallingMessage()');
|
||||
|
||||
|
@ -439,6 +443,35 @@ export class CallingClass {
|
|||
}
|
||||
const receiverIdentityKey = receiverIdentityRecord.publicKey.slice(1); // Ignore the type header, it is not used.
|
||||
|
||||
const conversation = window.ConversationController.get(remoteUserId);
|
||||
if (!conversation) {
|
||||
window.log.error('Missing conversation; ignoring call message.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (callingMessage.offer && !conversation.getAccepted()) {
|
||||
window.log.info(
|
||||
'Conversation was not approved by user; rejecting call message.'
|
||||
);
|
||||
|
||||
const hangup = new HangupMessage();
|
||||
hangup.callId = callingMessage.offer.callId;
|
||||
hangup.deviceId = remoteDeviceId;
|
||||
hangup.type = HangupType.NeedPermission;
|
||||
|
||||
const message = new CallingMessage();
|
||||
message.legacyHangup = hangup;
|
||||
|
||||
await this.handleOutgoingSignaling(remoteUserId, message);
|
||||
|
||||
this.addCallHistoryForFailedIncomingCall(
|
||||
conversation,
|
||||
callingMessage.offer.type === OfferType.VideoCall
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const messageAgeSec = envelope.messageAgeSec ? envelope.messageAgeSec : 0;
|
||||
|
||||
window.log.info('CallingClass.handleCallingMessage(): Handling in RingRTC');
|
||||
|
@ -525,7 +558,7 @@ export class CallingClass {
|
|||
|
||||
private async handleOutgoingSignaling(
|
||||
remoteUserId: UserId,
|
||||
message: CallingMessageClass
|
||||
message: CallingMessage
|
||||
): Promise<boolean> {
|
||||
const conversation = window.ConversationController.get(remoteUserId);
|
||||
const sendOptions = conversation
|
||||
|
@ -585,17 +618,10 @@ export class CallingClass {
|
|||
window.log.info(
|
||||
`Peer is not trusted, ignoring incoming call for conversation: ${conversation.idForLogging()}`
|
||||
);
|
||||
this.addCallHistoryForFailedIncomingCall(conversation, call);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Simple Call Requests: Ensure that the conversation is accepted.
|
||||
// If not, do not allow the call.
|
||||
if (!conversation.getAccepted()) {
|
||||
window.log.info(
|
||||
`Messaging is not accepted, ignoring incoming call for conversation: ${conversation.idForLogging()}`
|
||||
this.addCallHistoryForFailedIncomingCall(
|
||||
conversation,
|
||||
call.isVideoCall
|
||||
);
|
||||
this.addCallHistoryForFailedIncomingCall(conversation, call);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -610,7 +636,7 @@ export class CallingClass {
|
|||
return await this.getCallSettings(conversation);
|
||||
} catch (err) {
|
||||
window.log.error(`Ignoring incoming call: ${err.stack}`);
|
||||
this.addCallHistoryForFailedIncomingCall(conversation, call);
|
||||
this.addCallHistoryForFailedIncomingCall(conversation, call.isVideoCall);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -774,11 +800,11 @@ export class CallingClass {
|
|||
|
||||
private addCallHistoryForFailedIncomingCall(
|
||||
conversation: ConversationModel,
|
||||
call: Call
|
||||
wasVideoCall: boolean
|
||||
) {
|
||||
const callHistoryDetails: CallHistoryDetailsType = {
|
||||
wasIncoming: true,
|
||||
wasVideoCall: call.isVideoCall,
|
||||
wasVideoCall,
|
||||
// Since the user didn't decline, make sure it shows up as a missed call instead
|
||||
wasDeclined: false,
|
||||
acceptedTime: undefined,
|
||||
|
|
64
ts/textsecure.d.ts
vendored
64
ts/textsecure.d.ts
vendored
|
@ -12,6 +12,7 @@ import { ByteBufferClass } from './window.d';
|
|||
import SendMessage, { SendOptionsType } from './textsecure/SendMessage';
|
||||
import { WebAPIType } from './textsecure/WebAPI';
|
||||
import utils from './textsecure/Helpers';
|
||||
import { CallingMessage as CallingMessageClass } from 'ringrtc';
|
||||
|
||||
type AttachmentType = any;
|
||||
|
||||
|
@ -1214,65 +1215,4 @@ export declare class WebSocketResponseMessageClass {
|
|||
body?: ProtoBinaryType;
|
||||
}
|
||||
|
||||
// Everything from here down to HangupType (everything related to calling)
|
||||
// must be kept in sync with RingRTC (ringrtc-node).
|
||||
// Whenever you change this, make sure you change RingRTC as well.
|
||||
|
||||
type ProtobufArrayBuffer = ArrayBuffer | { toArrayBuffer: () => ArrayBuffer };
|
||||
|
||||
export type DeviceId = number;
|
||||
|
||||
export type CallId = any;
|
||||
|
||||
export class CallingMessageClass {
|
||||
offer?: OfferMessageClass;
|
||||
answer?: AnswerMessageClass;
|
||||
iceCandidates?: Array<IceCandidateMessageClass>;
|
||||
legacyHangup?: HangupMessageClass;
|
||||
busy?: BusyMessageClass;
|
||||
hangup?: HangupMessageClass;
|
||||
supportsMultiRing?: boolean;
|
||||
destinationDeviceId?: DeviceId;
|
||||
}
|
||||
|
||||
export class OfferMessageClass {
|
||||
callId?: CallId;
|
||||
type?: OfferType;
|
||||
sdp?: string;
|
||||
}
|
||||
|
||||
export enum OfferType {
|
||||
AudioCall = 0,
|
||||
VideoCall = 1,
|
||||
}
|
||||
|
||||
export class AnswerMessageClass {
|
||||
callId?: CallId;
|
||||
sdp?: string;
|
||||
}
|
||||
|
||||
export class IceCandidateMessageClass {
|
||||
callId?: CallId;
|
||||
mid?: string;
|
||||
line?: number;
|
||||
opaque?: ProtobufArrayBuffer;
|
||||
sdp?: string;
|
||||
}
|
||||
|
||||
export class BusyMessageClass {
|
||||
callId?: CallId;
|
||||
}
|
||||
|
||||
export class HangupMessageClass {
|
||||
callId?: CallId;
|
||||
type?: HangupType;
|
||||
deviceId?: DeviceId;
|
||||
}
|
||||
|
||||
export enum HangupType {
|
||||
Normal = 0,
|
||||
Accepted = 1,
|
||||
Declined = 2,
|
||||
Busy = 3,
|
||||
NeedPermission = 4,
|
||||
}
|
||||
export { CallingMessageClass };
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { CallState } from 'ringrtc';
|
||||
|
||||
// Must be kept in sync with RingRTC.AudioDevice
|
||||
export interface AudioDevice {
|
||||
// Device name.
|
||||
|
@ -10,15 +12,6 @@ export interface AudioDevice {
|
|||
i18nKey?: string;
|
||||
}
|
||||
|
||||
// This must be kept in sync with RingRTC.CallState.
|
||||
export enum CallState {
|
||||
Prering = 'init',
|
||||
Ringing = 'ringing',
|
||||
Accepted = 'connected',
|
||||
Reconnecting = 'connecting',
|
||||
Ended = 'ended',
|
||||
}
|
||||
|
||||
export enum CallingDeviceType {
|
||||
CAMERA,
|
||||
MICROPHONE,
|
||||
|
@ -46,3 +39,5 @@ export type ChangeIODevicePayloadType =
|
|||
| { type: CallingDeviceType.CAMERA; selectedDevice: string }
|
||||
| { type: CallingDeviceType.MICROPHONE; selectedDevice: AudioDevice }
|
||||
| { type: CallingDeviceType.SPEAKER; selectedDevice: AudioDevice };
|
||||
|
||||
export { CallState };
|
||||
|
|
|
@ -14075,9 +14075,9 @@ rimraf@~2.4.0:
|
|||
dependencies:
|
||||
glob "^6.0.1"
|
||||
|
||||
"ringrtc@https://github.com/signalapp/signal-ringrtc-node.git#7563474ee920d4535535ae01476ced3e8dc668d1":
|
||||
version "2.7.1"
|
||||
resolved "https://github.com/signalapp/signal-ringrtc-node.git#7563474ee920d4535535ae01476ced3e8dc668d1"
|
||||
"ringrtc@https://github.com/signalapp/signal-ringrtc-node.git#bfa94f2749324029ed4b4c51dfaf3e27bafe3eed":
|
||||
version "2.7.2"
|
||||
resolved "https://github.com/signalapp/signal-ringrtc-node.git#bfa94f2749324029ed4b4c51dfaf3e27bafe3eed"
|
||||
|
||||
ripemd160@^2.0.0, ripemd160@^2.0.1:
|
||||
version "2.0.1"
|
||||
|
|
Loading…
Add table
Reference in a new issue