fix: improved backwards compatibility

pull/2660/head
William Grant 1 year ago
parent ac844af691
commit f122c206da

@ -167,7 +167,7 @@ message DataMessage {
repeated bytes members = 5;
repeated bytes admins = 6;
repeated KeyPairWrapper wrappers = 7;
optional uint32 expirationTimer = 8;
optional uint32 expirationTimer = 8;
}

@ -395,9 +395,10 @@ export async function innerHandleSwarmContentMessage(
}
if (content.dataMessage) {
const dataMessage = content.dataMessage;
// because typescript is funky with incoming protobufs
if (content.dataMessage.profileKey && content.dataMessage.profileKey.length === 0) {
content.dataMessage.profileKey = null;
if (dataMessage.profileKey && dataMessage.profileKey.length === 0) {
dataMessage.profileKey = null;
}
perfStart(`handleSwarmDataMessage-${envelope.id}`);
@ -406,7 +407,15 @@ export async function innerHandleSwarmContentMessage(
const expirationType =
DisappearingMessageConversationSetting[content.expirationType] || 'off';
const expireTimer = content.expirationTimer || 0;
let expireTimer = content.expirationTimer || 0;
// TODO in the future we will remove the dataMessage expireTimer
// Backwards compatibility for Disappearing Messages in old clients
if (dataMessage.expireTimer) {
// TODO Trigger banner in UI?
expireTimer = dataMessage.expireTimer;
window.log.info(`WIP: Received outdated disappearing message data message`, content);
}
// NOTE In the protobuf this is a long
const lastDisappearingMessageChangeTimestamp =
@ -422,7 +431,7 @@ export async function innerHandleSwarmContentMessage(
await handleSwarmDataMessage(
envelope,
sentAtTimestamp,
content.dataMessage as SignalService.DataMessage,
dataMessage as SignalService.DataMessage,
messageHash,
senderConversationModel,
expireUpdate

@ -346,7 +346,6 @@ export async function handleMessageJob(
'serverTimestamp'
) || messageModel.get('timestamp')} in conversation ${conversation.idForLogging()}`
);
const sendingDeviceConversation = await getConversationController().getOrCreateAndWait(
source,
ConversationTypeEnum.PRIVATE
@ -371,18 +370,6 @@ export async function handleMessageJob(
}
if (messageModel.isExpirationTimerUpdate()) {
// TODO in the future we will remove the dataMessage expireTimer and the expirationTimerUpdate
// Backwards compatibility for Disappearing Messages in old clients
if (regularDataMessage.expireTimer) {
const expirationTimerUpdate = messageModel.get('expirationTimerUpdate');
if (!isEmpty(expirationTimerUpdate)) {
messageModel.set({
expirationType: expirationTimerUpdate?.expirationType,
expireTimer: expirationTimerUpdate?.expireTimer,
});
}
}
// TODO account for lastDisappearingMessageChangeTimestamp
let expirationType = messageModel.get('expirationType');
const expireTimer = messageModel.get('expireTimer');

Loading…
Cancel
Save