Calling support

This commit is contained in:
Peter Thatcher 2020-06-04 11:16:19 -07:00 committed by Scott Nonnenberg
parent 83574eb067
commit d3a27a6442
72 changed files with 3864 additions and 191 deletions

View file

@ -19,6 +19,7 @@ import { IncomingIdentityKeyError } from './Errors';
import {
AttachmentPointerClass,
CallingMessageClass,
DataMessageClass,
DownloadAttachmentType,
EnvelopeClass,
@ -1217,9 +1218,8 @@ class MessageReceiverInner extends EventTarget {
} else if (content.nullMessage) {
this.handleNullMessage(envelope);
return;
} else if (content.callMessage) {
this.handleCallMessage(envelope);
return;
} else if (content.callingMessage) {
return this.handleCallingMessage(envelope, content.callingMessage);
} else if (content.receiptMessage) {
return this.handleReceiptMessage(envelope, content.receiptMessage);
} else if (content.typingMessage) {
@ -1228,9 +1228,15 @@ class MessageReceiverInner extends EventTarget {
this.removeFromCache(envelope);
throw new Error('Unsupported content message');
}
handleCallMessage(envelope: EnvelopeClass) {
window.log.info('call message from', this.getEnvelopeId(envelope));
async handleCallingMessage(
envelope: EnvelopeClass,
callingMessage: CallingMessageClass
) {
this.removeFromCache(envelope);
await window.Signal.Services.calling.handleCallingMessage(
envelope,
callingMessage
);
}
async handleReceiptMessage(
envelope: EnvelopeClass,

View file

@ -9,6 +9,7 @@ import OutgoingMessage from './OutgoingMessage';
import Crypto from './Crypto';
import {
AttachmentPointerClass,
CallingMessageClass,
ContentClass,
DataMessageClass,
} from '../textsecure.d';
@ -892,6 +893,28 @@ export default class MessageSender {
);
}
async sendCallingMessage(
recipientId: string,
callingMessage: CallingMessageClass,
sendOptions: SendOptionsType
) {
const recipients = [recipientId];
const finalTimestamp = Date.now();
const contentMessage = new window.textsecure.protobuf.Content();
contentMessage.callingMessage = callingMessage;
const silent = true;
await this.sendMessageProtoAndWait(
finalTimestamp,
recipients,
contentMessage,
silent,
sendOptions
);
}
async sendDeliveryReceipt(
recipientE164: string,
recipientUuid: string,

View file

@ -478,6 +478,7 @@ const URL_CALLS = {
accounts: 'v1/accounts',
updateDeviceName: 'v1/accounts/name',
removeSignalingKey: 'v1/accounts/signaling_key',
getIceServers: 'v1/accounts/turn',
attachmentId: 'v2/attachments/form/upload',
deliveryCert: 'v1/certificate/delivery',
supportUnauthenticatedDelivery: 'v1/devices/unauthenticated_delivery',
@ -541,6 +542,7 @@ export type WebAPIType = {
getAttachment: (cdnKey: string, cdnNumber: number) => Promise<any>;
getAvatar: (path: string) => Promise<any>;
getDevices: () => Promise<any>;
getIceServers: () => Promise<any>;
getKeysForIdentifier: (
identifier: string,
deviceId?: number
@ -702,6 +704,7 @@ export function initialize({
getAttachment,
getAvatar,
getDevices,
getIceServers,
getKeysForIdentifier,
getKeysForIdentifierUnauth,
getMessageSocket,
@ -983,6 +986,13 @@ export function initialize({
});
}
async function getIceServers() {
return _ajax({
call: 'getIceServers',
httpType: 'GET',
});
}
async function removeSignalingKey() {
return _ajax({
call: 'removeSignalingKey',