fix: added isOutdated prop to expireUpdate

ignores duplicate setting messages
pull/2971/head
William Grant 2 years ago
parent 07097b029d
commit e8e3ba142e

@ -1025,7 +1025,11 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
const expireUpdate = await checkForExpireUpdateInContentMessage(content, conversation);
if (!isEmpty(expireUpdate) && expireUpdate.lastDisappearingMessageChangeTimestamp) {
if (
!isEmpty(expireUpdate) &&
!expireUpdate.isOutdated &&
expireUpdate.lastDisappearingMessageChangeTimestamp
) {
const syncMessage = buildSyncMessage(
this.id,
dataMessage as SignalService.DataMessage,

@ -487,6 +487,18 @@ export async function innerHandleSwarmContentMessage(
}`
);
if (expireUpdate?.isOutdated) {
// window.log.debug(
// `WIP: innerHandleSwarmContentMessage: This ${
// content.dataMessage.syncTarget ? 'sync' : ''
// } message is outdated. Ignoring it.\n\ncontent:${JSON.stringify(
// content
// )}\n\nexpireUpdate: ${JSON.stringify(expireUpdate)}`
// );
await removeFromCache(envelope);
return;
}
// TODO legacy messages support will be removed in a future release
if (expireUpdate?.isDisappearingMessagesV2Released) {
await checkHasOutdatedDisappearingMessageClient(
@ -498,8 +510,9 @@ export async function innerHandleSwarmContentMessage(
window.log.debug(
`WIP: The legacy message is an expiration timer update. Ignoring it.\ncontent:${JSON.stringify(
content
)}}`
)}\n\nexpireUpdate: ${JSON.stringify(expireUpdate)}`
);
await removeFromCache(envelope);
return;
}
}

@ -436,7 +436,7 @@ export async function handleMessageJob(
window.log.debug(
`WIP: There is a problem with the expiration timer update.\nmessage model: ${JSON.stringify(
messageModel
)}\nexpirationTimerUpdate: ${JSON.stringify(expirationTimerUpdate)}`
)}\n\nexpirationTimerUpdate: ${JSON.stringify(expirationTimerUpdate)}`
);
return;
}
@ -454,7 +454,7 @@ export async function handleMessageJob(
window.log.debug(
`WIP: There is a problem with the expiration timer update. The lastDisappearingMessageChangeTimestamp is missing.\nmessage model: ${JSON.stringify(
messageModel
)}\nexpirationTimerUpdate: ${JSON.stringify(expirationTimerUpdate)}`
)}\n\nexpirationTimerUpdate: ${JSON.stringify(expirationTimerUpdate)}`
);
return;
}

@ -45,6 +45,7 @@ export type DisappearingMessageUpdate = {
isLegacyDataMessage?: boolean;
isDisappearingMessagesV2Released?: boolean;
shouldDisappearButIsntMessage?: boolean;
isOutdated?: boolean;
};
export async function destroyMessagesAndUpdateRedux(
@ -420,6 +421,17 @@ export async function checkForExpireUpdateInContentMessage(
: couldBeLegacyContentMessage &&
dataMessage.flags === SignalService.DataMessage.Flags.EXPIRATION_TIMER_UPDATE;
const expirationTimer = isLegacyDataMessage
? Number(dataMessage.expireTimer)
: content.expirationTimer;
// NOTE we don't use the expirationType directly from the Content Message because we need to resolve it to the correct convo type first in case it is legacy or has errors
const expirationMode = changeToDisappearingMessageConversationType(
convoToUpdate,
DisappearingMessageMode[content.expirationType],
expirationTimer
);
const lastDisappearingMessageChangeTimestamp = content.lastDisappearingMessageChangeTimestamp
? Number(content.lastDisappearingMessageChangeTimestamp)
: undefined;
@ -435,20 +447,17 @@ export async function checkForExpireUpdateInContentMessage(
content
)}\n\nconvoToUpdate: ${JSON.stringify(convoToUpdate)}`
);
return undefined;
return {
expirationType: changeToDisappearingMessageType(
convoToUpdate,
expirationTimer,
expirationMode
),
expirationTimer,
isOutdated: true,
};
}
const expirationTimer = isLegacyDataMessage
? Number(dataMessage.expireTimer)
: content.expirationTimer;
// NOTE we don't use the expirationType directly from the Content Message because we need to resolve it to the correct convo type first in case it is legacy or has errors
const expirationMode = changeToDisappearingMessageConversationType(
convoToUpdate,
DisappearingMessageMode[content.expirationType],
expirationTimer
);
const shouldDisappearButIsntMessage = checkDisappearButIsntMessage(
content,
convoToUpdate,

Loading…
Cancel
Save