Update to RingRTC v2.26.2

This commit is contained in:
Jim Gustafson 2023-03-29 14:16:19 -07:00 committed by GitHub
parent 92baa76c09
commit 43e70720f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 79 additions and 54 deletions

View file

@ -86,7 +86,7 @@
"@react-spring/web": "9.5.5", "@react-spring/web": "9.5.5",
"@signalapp/better-sqlite3": "8.4.3", "@signalapp/better-sqlite3": "8.4.3",
"@signalapp/libsignal-client": "0.22.0", "@signalapp/libsignal-client": "0.22.0",
"@signalapp/ringrtc": "2.25.2", "@signalapp/ringrtc": "2.26.2",
"@types/fabric": "4.5.3", "@types/fabric": "4.5.3",
"backbone": "1.4.0", "backbone": "1.4.0",
"blob-util": "2.0.2", "blob-util": "2.0.2",

View file

@ -14,6 +14,8 @@ import type {
VideoRequest, VideoRequest,
} from '@signalapp/ringrtc'; } from '@signalapp/ringrtc';
import { import {
AnswerMessage,
BusyMessage,
Call, Call,
CallEndedReason, CallEndedReason,
CallingMessage, CallingMessage,
@ -28,6 +30,8 @@ import {
GumVideoCapturer, GumVideoCapturer,
HangupMessage, HangupMessage,
HangupType, HangupType,
IceCandidateMessage,
OfferMessage,
OpaqueMessage, OpaqueMessage,
RingCancelReason, RingCancelReason,
RingRTC, RingRTC,
@ -72,7 +76,7 @@ import type { ConversationModel } from '../models/conversations';
import * as Bytes from '../Bytes'; import * as Bytes from '../Bytes';
import { uuidToBytes, bytesToUuid } from '../Crypto'; import { uuidToBytes, bytesToUuid } from '../Crypto';
import { drop } from '../util/drop'; import { drop } from '../util/drop';
import { dropNull, shallowDropNull } from '../util/dropNull'; import { dropNull } from '../util/dropNull';
import { getOwn } from '../util/getOwn'; import { getOwn } from '../util/getOwn';
import { isNormalNumber } from '../util/isNormalNumber'; import { isNormalNumber } from '../util/isNormalNumber';
import * as durations from '../util/durations'; import * as durations from '../util/durations';
@ -220,44 +224,51 @@ function protoToCallingMessage({
destinationDeviceId, destinationDeviceId,
opaque, opaque,
}: Proto.ICallingMessage): CallingMessage { }: Proto.ICallingMessage): CallingMessage {
return { const newIceCandidates: Array<IceCandidateMessage> = [];
offer: offer if (iceCandidates) {
? { iceCandidates.forEach(candidate => {
...shallowDropNull(offer), if (candidate.callId && candidate.opaque) {
newIceCandidates.push(
new IceCandidateMessage(
candidate.callId,
Buffer.from(candidate.opaque)
)
);
}
});
}
type: dropNull(offer.type) as number, return {
opaque: offer.opaque ? Buffer.from(offer.opaque) : undefined, offer:
} offer && offer.callId && offer.opaque
: undefined, ? new OfferMessage(
answer: answer offer.callId,
? { dropNull(offer.type) as number,
...shallowDropNull(answer), Buffer.from(offer.opaque)
opaque: answer.opaque ? Buffer.from(answer.opaque) : undefined, )
} : undefined,
: undefined, answer:
iceCandidates: iceCandidates answer && answer.callId && answer.opaque
? iceCandidates.map(candidate => { ? new AnswerMessage(answer.callId, Buffer.from(answer.opaque))
return { : undefined,
...shallowDropNull(candidate), iceCandidates: newIceCandidates.length > 0 ? newIceCandidates : undefined,
opaque: candidate.opaque legacyHangup:
? Buffer.from(candidate.opaque) legacyHangup && legacyHangup.callId
: undefined, ? new HangupMessage(
}; legacyHangup.callId,
}) dropNull(legacyHangup.type) as number,
: undefined, legacyHangup.deviceId || 0
legacyHangup: legacyHangup )
? { : undefined,
...shallowDropNull(legacyHangup), busy: busy && busy.callId ? new BusyMessage(busy.callId) : undefined,
type: dropNull(legacyHangup.type) as number, hangup:
} hangup && hangup.callId
: undefined, ? new HangupMessage(
busy: shallowDropNull(busy), hangup.callId,
hangup: hangup dropNull(hangup.type) as number,
? { hangup.deviceId || 0
...shallowDropNull(hangup), )
type: dropNull(hangup.type) as number, : undefined,
}
: undefined,
supportsMultiRing: dropNull(supportsMultiRing), supportsMultiRing: dropNull(supportsMultiRing),
destinationDeviceId: dropNull(destinationDeviceId), destinationDeviceId: dropNull(destinationDeviceId),
opaque: opaque opaque: opaque
@ -1536,25 +1547,26 @@ export class CallingClass {
'Conversation was not approved by user; rejecting call message.' 'Conversation was not approved by user; rejecting call message.'
); );
const hangup = new HangupMessage(); const { callId } = callingMessage.offer;
hangup.callId = callingMessage.offer.callId; assertDev(callId != null, 'Call ID missing from offer');
hangup.deviceId = remoteDeviceId;
hangup.type = HangupType.NeedPermission; const hangup = new HangupMessage(
callId,
HangupType.NeedPermission,
remoteDeviceId
);
const message = new CallingMessage(); const message = new CallingMessage();
message.legacyHangup = hangup; message.legacyHangup = hangup;
await this.handleOutgoingSignaling(remoteUserId, message); await this.handleOutgoingSignaling(remoteUserId, message);
const callId = callingMessage.offer.callId?.toString();
assertDev(callId != null, 'Call ID missing from offer');
const ProtoOfferType = Proto.CallingMessage.Offer.Type; const ProtoOfferType = Proto.CallingMessage.Offer.Type;
await this.addCallHistoryForFailedIncomingCall( await this.addCallHistoryForFailedIncomingCall(
conversation, conversation,
callingMessage.offer.type === ProtoOfferType.OFFER_VIDEO_CALL, callingMessage.offer.type === ProtoOfferType.OFFER_VIDEO_CALL,
envelope.timestamp, envelope.timestamp,
callId callId.toString()
); );
return; return;

View file

@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai'; import { assert } from 'chai';
import type { CallId } from '@signalapp/ringrtc';
import { import {
CallMessageUrgency, CallMessageUrgency,
CallingMessage, CallingMessage,
@ -23,9 +24,10 @@ describe('callingMessageToProto', () => {
}); });
it('attaches the type if provided', () => { it('attaches the type if provided', () => {
const callId: CallId = { high: 0, low: 0, unsigned: false };
const callingMessage = new CallingMessage(); const callingMessage = new CallingMessage();
callingMessage.hangup = new HangupMessage(); callingMessage.hangup = new HangupMessage(callId, HangupType.Busy, 1);
callingMessage.hangup.type = HangupType.Busy;
const result = callingMessageToProto(callingMessage); const result = callingMessageToProto(callingMessage);

View file

@ -3,6 +3,7 @@
import type { CallingMessage } from '@signalapp/ringrtc'; import type { CallingMessage } from '@signalapp/ringrtc';
import { CallMessageUrgency } from '@signalapp/ringrtc'; import { CallMessageUrgency } from '@signalapp/ringrtc';
import Long from 'long';
import { SignalService as Proto } from '../protobuf'; import { SignalService as Proto } from '../protobuf';
import * as log from '../logging/log'; import * as log from '../logging/log';
import { missingCaseError } from './missingCaseError'; import { missingCaseError } from './missingCaseError';
@ -39,6 +40,7 @@ export function callingMessageToProto(
offer: offer offer: offer
? { ? {
...offer, ...offer,
callId: Long.fromValue(offer.callId),
type: offer.type as number, type: offer.type as number,
opaque: bufferToProto(offer.opaque), opaque: bufferToProto(offer.opaque),
} }
@ -46,6 +48,7 @@ export function callingMessageToProto(
answer: answer answer: answer
? { ? {
...answer, ...answer,
callId: Long.fromValue(answer.callId),
opaque: bufferToProto(answer.opaque), opaque: bufferToProto(answer.opaque),
} }
: undefined, : undefined,
@ -53,6 +56,7 @@ export function callingMessageToProto(
? iceCandidates.map(candidate => { ? iceCandidates.map(candidate => {
return { return {
...candidate, ...candidate,
callId: Long.fromValue(candidate.callId),
opaque: bufferToProto(candidate.opaque), opaque: bufferToProto(candidate.opaque),
}; };
}) })
@ -60,13 +64,20 @@ export function callingMessageToProto(
legacyHangup: legacyHangup legacyHangup: legacyHangup
? { ? {
...legacyHangup, ...legacyHangup,
callId: Long.fromValue(legacyHangup.callId),
type: legacyHangup.type as number, type: legacyHangup.type as number,
} }
: undefined, : undefined,
busy, busy: busy
? {
...busy,
callId: Long.fromValue(busy.callId),
}
: undefined,
hangup: hangup hangup: hangup
? { ? {
...hangup, ...hangup,
callId: Long.fromValue(hangup.callId),
type: hangup.type as number, type: hangup.type as number,
} }
: undefined, : undefined,

View file

@ -2269,10 +2269,10 @@
ws "^8.4.2" ws "^8.4.2"
zod "^3.20.2" zod "^3.20.2"
"@signalapp/ringrtc@2.25.2": "@signalapp/ringrtc@2.26.2":
version "2.25.2" version "2.26.2"
resolved "https://registry.yarnpkg.com/@signalapp/ringrtc/-/ringrtc-2.25.2.tgz#6e6e32fe3e507f1ead7cd287d53eb35d1f9b5ef9" resolved "https://registry.yarnpkg.com/@signalapp/ringrtc/-/ringrtc-2.26.2.tgz#6ca91cd4b2d3ed545eb87c4aaddcb3f8735ad85a"
integrity sha512-3uy0e7gdPCkPFQGO7d74+wJYdPM/eAwvyW/tqnZ2FAqS2ybjF3XyoP9UI+jmrz8UF+IWGeu1ZZqy96XuxgJlfA== integrity sha512-Z80SrSuZl8EufG5cS6PEKo+vYYTKQ6mXD7Ybc1L8ambIYf2PsmLDI++ZN+NsEQVFXPQr9nwie/oQJGi145ffLQ==
dependencies: dependencies:
tar "^6.1.0" tar "^6.1.0"