fix: outgoing content messages can have an equal changetimestamp

pull/2971/head
William Grant 2 years ago
parent 7c6e6c981a
commit 00ef4a47a2

@ -1023,7 +1023,10 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
throw new Error('Cannot trigger syncMessage with unknown convo.');
}
const expireUpdate = await checkForExpireUpdateInContentMessage(content, conversation);
// window.log.debug(
// `WIP: sendSyncMessage: running checkForExpireUpdateInContentMessage for ${this.id}`
// );
const expireUpdate = await checkForExpireUpdateInContentMessage(content, conversation, true);
if (
!isEmpty(expireUpdate) &&

@ -474,18 +474,23 @@ export async function innerHandleSwarmContentMessage(
if (isEmpty(content.dataMessage.profileKey)) {
content.dataMessage.profileKey = null;
}
// window.log.debug(
// `WIP: innerHandleSwarmContentMessage: running checkForExpireUpdateInContentMessage for ${envelope.id}`
// );
const expireUpdate = await checkForExpireUpdateInContentMessage(
content,
conversationModelForUIUpdate
);
window.log.debug(
`WIP:innerHandleSwarmContentMessage: ${
content.dataMessage.syncTarget ? 'This is a sync message.\n' : ''
} content: ${JSON.stringify(content)} ${
expireUpdate ? `\n\nexpireUpdate: ${JSON.stringify(expireUpdate)}` : ''
}`
);
// window.log.debug(
// `WIP:innerHandleSwarmContentMessage: ${
// content.dataMessage.syncTarget ? 'This is a sync message.\n' : ''
// } content: ${JSON.stringify(content)} ${
// expireUpdate ? `\n\nexpireUpdate: ${JSON.stringify(expireUpdate)}` : ''
// }`
// );
if (expireUpdate?.isOutdated) {
// window.log.debug(

@ -403,7 +403,8 @@ export function checkIsLegacyDisappearingDataMessage(
// TODO legacy messages support will be removed in a future release
export async function checkForExpireUpdateInContentMessage(
content: SignalService.Content,
convoToUpdate: ConversationModel
convoToUpdate: ConversationModel,
isOutgoing?: boolean
): Promise<DisappearingMessageUpdate | undefined> {
const dataMessage = content.dataMessage as SignalService.DataMessage;
// We will only support legacy disappearing messages for a short period before disappearing messages v2 is unlocked
@ -436,17 +437,26 @@ export async function checkForExpireUpdateInContentMessage(
? Number(content.lastDisappearingMessageChangeTimestamp)
: undefined;
// NOTE if we are checking an outgoing content message then the conversation's lastDisappearingMessageChangeTimestamp has just been set to match the content message so it can't be outdated if equal
if (
convoToUpdate.get('lastDisappearingMessageChangeTimestamp') &&
lastDisappearingMessageChangeTimestamp &&
convoToUpdate.get('lastDisappearingMessageChangeTimestamp') >=
lastDisappearingMessageChangeTimestamp
((isOutgoing &&
convoToUpdate.get('lastDisappearingMessageChangeTimestamp') >
lastDisappearingMessageChangeTimestamp) ||
(!isOutgoing &&
convoToUpdate.get('lastDisappearingMessageChangeTimestamp') >=
lastDisappearingMessageChangeTimestamp))
) {
// window.log.info(
// `WIP: checkForExpireUpdateInContentMessage() This is an outdated disappearing message setting. So we will ignore it.\ncontent: ${JSON.stringify(
// content
// )}
// );
window.log.info(
`WIP: checkForExpireUpdateInContentMessage() This is an outdated ${
isOutgoing ? 'outgoing' : 'incoming'
} disappearing message setting. So we will ignore it.\nconvoToUpdate.get('lastDisappearingMessageChangeTimestamp'): ${convoToUpdate.get(
'lastDisappearingMessageChangeTimestamp'
)}\nlastDisappearingMessageChangeTimestamp: ${lastDisappearingMessageChangeTimestamp}\n\ncontent: ${JSON.stringify(
content
)}`
);
return {
expirationType: changeToDisappearingMessageType(

Loading…
Cancel
Save