diff --git a/package.json b/package.json index cb8a63117..a892ce583 100644 --- a/package.json +++ b/package.json @@ -151,7 +151,7 @@ "redux-ts-utils": "3.2.2", "reselect": "4.0.0", "rimraf": "2.6.2", - "ringrtc": "https://github.com/signalapp/signal-ringrtc-node.git#432139dfeb2bcdf96118f3a6554c7c58da42d042", + "ringrtc": "https://github.com/signalapp/signal-ringrtc-node.git#8b028d8f1ea0c5936cac1742bb425b7ed0b25d35", "rotating-file-stream": "2.1.5", "sanitize-filename": "1.6.3", "sanitize.css": "11.0.0", diff --git a/ts/services/calling.ts b/ts/services/calling.ts index 62da38984..2bc6aa9e8 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -63,6 +63,7 @@ import { } from '../Crypto'; import { dropNull, shallowDropNull } from '../util/dropNull'; import { getOwn } from '../util/getOwn'; +import { isNormalNumber } from '../util/isNormalNumber'; import * as durations from '../util/durations'; import { handleMessageSend } from '../util/handleMessageSend'; import { @@ -1742,13 +1743,27 @@ export class CallingClass { private handleAutoEndedIncomingCallRequest( remoteUserId: UserId, - reason: CallEndedReason + reason: CallEndedReason, + ageInSeconds: number ) { const conversation = window.ConversationController.get(remoteUserId); if (!conversation) { return; } - this.addCallHistoryForAutoEndedIncomingCall(conversation, reason); + + // This is extra defensive, just in case RingRTC passes us a bad value. (It probably + // won't.) + const ageInMilliseconds = + isNormalNumber(ageInSeconds) && ageInSeconds >= 0 + ? ageInSeconds * durations.SECOND + : 0; + const endedTime = Date.now() - ageInMilliseconds; + + this.addCallHistoryForAutoEndedIncomingCall( + conversation, + reason, + endedTime + ); } private attachToCall(conversation: ConversationModel, call: Call): void { @@ -1966,7 +1981,8 @@ export class CallingClass { private addCallHistoryForAutoEndedIncomingCall( conversation: ConversationModel, - _reason: CallEndedReason + _reason: CallEndedReason, + endedTime: number ) { conversation.addCallHistory({ callMode: CallMode.Direct, @@ -1977,7 +1993,7 @@ export class CallingClass { // Since the user didn't decline, make sure it shows up as a missed call instead wasDeclined: false, acceptedTime: undefined, - endedTime: Date.now(), + endedTime, }); } diff --git a/yarn.lock b/yarn.lock index 5dee350c0..ac22f064e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15827,9 +15827,9 @@ rimraf@^3.0.0, rimraf@^3.0.2, rimraf@~3.0.2: dependencies: glob "^7.1.3" -"ringrtc@https://github.com/signalapp/signal-ringrtc-node.git#432139dfeb2bcdf96118f3a6554c7c58da42d042": - version "2.13.0" - resolved "https://github.com/signalapp/signal-ringrtc-node.git#432139dfeb2bcdf96118f3a6554c7c58da42d042" +"ringrtc@https://github.com/signalapp/signal-ringrtc-node.git#8b028d8f1ea0c5936cac1742bb425b7ed0b25d35": + version "2.13.1" + resolved "https://github.com/signalapp/signal-ringrtc-node.git#8b028d8f1ea0c5936cac1742bb425b7ed0b25d35" ripemd160@^2.0.0, ripemd160@^2.0.1: version "2.0.1"