fix: fixed legacy disappearing messages on call notifications and others

pull/2660/head
William Grant 2 years ago
parent f7e5719eac
commit e5ecff7ec3

@ -774,6 +774,8 @@ export async function handleDataExtractionNotification(
const envelopeTimestamp = toNumber(timestamp);
const referencedAttachmentTimestamp = toNumber(referencedAttachment);
const expirationType = convo.get('expirationType');
// TODO legacy messages support will be removed in a future release
const isLegacyMode = convo && convo.isPrivate() && expirationType === 'legacy';
await convo.addSingleIncomingMessage({
source,
@ -787,7 +789,10 @@ export async function handleDataExtractionNotification(
expirationType: expirationType !== 'off' ? expirationType : undefined,
expireTimer: convo.get('expireTimer') ? convo.get('expireTimer') : 0,
// TODO should this only be for delete after send?
expirationStartTimestamp: setExpirationStartTimestamp(expirationType),
expirationStartTimestamp:
isLegacyMode || expirationType === 'deleteAfterSend'
? setExpirationStartTimestamp('deleteAfterSend', undefined, isLegacyMode)
: undefined,
});
convo.updateLastMessage();
}

@ -345,7 +345,8 @@ export async function handleMessageJob(
messageModel.set({
expirationStartTimestamp: setExpirationStartTimestamp(
'deleteAfterSend',
messageModel.get('sent_at')
messageModel.get('sent_at'),
messageModel.get('expirationType') === 'legacy'
),
});
}

@ -180,7 +180,10 @@ export async function addUpdateMessage(
group_update: groupUpdate,
expirationType: expirationType || undefined,
expireTimer: expireTimer || 0,
expirationStartTimestamp: setExpirationStartTimestamp(expirationType, sentAt),
// closed groups are always deleteAfterSend
expirationStartTimestamp: expirationType
? setExpirationStartTimestamp('deleteAfterSend', sentAt, expirationType === 'legacy')
: undefined,
};
if (UserUtils.isUsFromCache(sender)) {

@ -147,7 +147,8 @@ async function handleMessageSentSuccess(
fetchedMessage.set({
expirationStartTimestamp: setExpirationStartTimestamp(
'deleteAfterSend',
fetchedMessage.get('sent_at')
fetchedMessage.get('sent_at'),
isLegacySentMode
),
});
}

@ -504,7 +504,9 @@ export async function USER_callRecipient(recipient: string) {
calledConvo.set('active_at', Date.now()); // addSingleOutgoingMessage does the commit for us on the convo
weAreCallerOnCurrentCall = true;
const expirationType = calledConvo.get('expirationType');
// TODO legacy messages support will be removed in a future release
const isLegacyMode = calledConvo.get('expirationType') !== 'legacy';
const expirationType = isLegacyMode ? calledConvo.get('expirationType') : 'deleteAfterSend';
await calledConvo?.addSingleOutgoingMessage({
callNotificationType: 'started-call',
sent_at: now,
@ -512,7 +514,8 @@ export async function USER_callRecipient(recipient: string) {
expireTimer: calledConvo.get('expireTimer') ? calledConvo.get('expireTimer') : 0,
expirationStartTimestamp: setExpirationStartTimestamp(
expirationType,
expirationType === 'deleteAfterSend' ? now : undefined
expirationType === 'deleteAfterSend' ? now : undefined,
isLegacyMode
),
});
@ -804,8 +807,15 @@ export async function USER_acceptIncomingCallRequest(fromSender: string) {
window?.log?.info('incoming call request cannot be accepted as uuid is invalid');
return;
}
window.inboxStore?.dispatch(answerCall({ pubkey: fromSender }));
await openConversationWithMessages({ conversationKey: fromSender, messageId: null });
window.inboxStore?.dispatch(
answerCall({
pubkey: fromSender,
})
);
await openConversationWithMessages({
conversationKey: fromSender,
messageId: null,
});
if (peerConnection) {
throw new Error('USER_acceptIncomingCallRequest: peerConnection is already set.');
}
@ -824,7 +834,10 @@ export async function USER_acceptIncomingCallRequest(fromSender: string) {
}
try {
await peerConnection.setRemoteDescription(
new RTCSessionDescription({ sdp: sdps[0], type: 'offer' })
new RTCSessionDescription({
sdp: sdps[0],
type: 'offer',
})
);
} catch (e) {
window.log?.error(`Error setting RTC Session Description ${e}`);
@ -841,7 +854,11 @@ export async function USER_acceptIncomingCallRequest(fromSender: string) {
const sdp = lastCandidatesFromSender.sdps[index];
const sdpMLineIndex = lastCandidatesFromSender.sdpMLineIndexes[index];
const sdpMid = lastCandidatesFromSender.sdpMids[index];
const candicate = new RTCIceCandidate({ sdpMid, sdpMLineIndex, candidate: sdp });
const candicate = new RTCIceCandidate({
sdpMid,
sdpMLineIndex,
candidate: sdp,
});
await peerConnection.addIceCandidate(candicate);
}
}
@ -849,7 +866,9 @@ export async function USER_acceptIncomingCallRequest(fromSender: string) {
const callerConvo = getConversationController().get(fromSender);
callerConvo.set('active_at', networkTimestamp);
const expirationType = callerConvo.get('expirationType');
// TODO legacy messages support will be removed in a future release
const isLegacyMode = callerConvo.get('expirationType') !== 'legacy';
const expirationType = isLegacyMode ? callerConvo.get('expirationType') : 'deleteAfterSend';
await callerConvo?.addSingleIncomingMessage({
callNotificationType: 'answered-a-call',
source: UserUtils.getOurPubKeyStrFromCache(),
@ -860,7 +879,8 @@ export async function USER_acceptIncomingCallRequest(fromSender: string) {
expireTimer: callerConvo.get('expireTimer') ? callerConvo.get('expireTimer') : 0,
expirationStartTimestamp: setExpirationStartTimestamp(
expirationType,
expirationType === 'deleteAfterSend' ? networkTimestamp : undefined
expirationType === 'deleteAfterSend' ? networkTimestamp : undefined,
isLegacyMode
),
});
await buildAnswerAndSendIt(fromSender);
@ -1181,7 +1201,11 @@ async function addMissedCallMessage(callerPubkey: string, sentAt: number) {
incomingCallConversation.set('active_at', getNowWithNetworkOffset());
}
const expirationType = incomingCallConversation.get('expirationType');
// TODO legacy messages support will be removed in a future release
const isLegacyMode = incomingCallConversation.get('expirationType') !== 'legacy';
const expirationType = isLegacyMode
? incomingCallConversation.get('expirationType')
: 'deleteAfterSend';
await incomingCallConversation?.addSingleIncomingMessage({
callNotificationType: 'missed-call',
source: callerPubkey,
@ -1194,7 +1218,8 @@ async function addMissedCallMessage(callerPubkey: string, sentAt: number) {
: 0,
expirationStartTimestamp: setExpirationStartTimestamp(
expirationType,
expirationType === 'deleteAfterSend' ? sentAt : undefined
expirationType === 'deleteAfterSend' ? sentAt : undefined,
isLegacyMode
),
});
}

@ -282,7 +282,6 @@ export async function checkForExpireUpdate(
convoToUpdate: ConversationModel,
content: SignalService.Content
): Promise<DisappearingMessageUpdate | undefined> {
// debugger;
const dataMessage = content.dataMessage as SignalService.DataMessage;
// We will only support legacy disappearing messages for a short period before disappearing messages v2 is unlocked
const isDisappearingMessagesV2Released = await checkIsFeatureReleased('Disappearing Messages V2');

Loading…
Cancel
Save