fix: don't send sync messages for outdated changes

pull/2971/head
William Grant 2 years ago
parent 3d8a664da9
commit 07097b029d

@ -1023,23 +1023,27 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
throw new Error('Cannot trigger syncMessage with unknown convo.'); throw new Error('Cannot trigger syncMessage with unknown convo.');
} }
// TODO things be broken
// debugger;
const expireUpdate = await checkForExpireUpdateInContentMessage(content, conversation); const expireUpdate = await checkForExpireUpdateInContentMessage(content, conversation);
const syncMessage = buildSyncMessage( if (!isEmpty(expireUpdate) && expireUpdate.lastDisappearingMessageChangeTimestamp) {
this.id, const syncMessage = buildSyncMessage(
dataMessage as SignalService.DataMessage, this.id,
conversation.id, dataMessage as SignalService.DataMessage,
sentTimestamp, conversation.id,
expireUpdate sentTimestamp,
); expireUpdate
);
await getMessageQueue().sendSyncMessage({ await getMessageQueue().sendSyncMessage({
namespace: SnodeNamespaces.UserMessages, namespace: SnodeNamespaces.UserMessages,
message: syncMessage, message: syncMessage,
}); });
}
} else {
// NOTE if the expireUpdate is not defined then this settings is most likely out of date so we should not sync it
return;
} }
this.set({ this.set({
sentSync: true, sentSync: true,
}); });

@ -386,11 +386,23 @@ export const buildSyncMessage = (
} }
// don't include our profileKey on syncing message. This is to be done by a ConfigurationMessage now // don't include our profileKey on syncing message. This is to be done by a ConfigurationMessage now
const timestamp = _.toNumber(sentTimestamp); const timestamp = _.toNumber(sentTimestamp);
if (dataMessage.flags === SignalService.DataMessage.Flags.EXPIRATION_TIMER_UPDATE) {
if (!isEmpty(expireUpdate) && expireUpdate.lastDisappearingMessageChangeTimestamp) { if (
return buildSyncExpireTimerMessage(identifier, expireUpdate, timestamp, syncTarget); dataMessage.flags === SignalService.DataMessage.Flags.EXPIRATION_TIMER_UPDATE &&
} !isEmpty(expireUpdate) &&
window.log.warn('WIP: Building Sync Expire Timer Message failed', dataMessage, expireUpdate); expireUpdate.lastDisappearingMessageChangeTimestamp
) {
const syncExpireTimerMessage = buildSyncExpireTimerMessage(
identifier,
expireUpdate,
timestamp,
syncTarget
);
window.log.warn(
`WIP: buildSyncMessage: \nsyncExpireTimerMessage: ${JSON.stringify(syncExpireTimerMessage)}`
);
return syncExpireTimerMessage;
} }
return buildSyncVisibleMessage(identifier, dataMessage, timestamp, syncTarget); return buildSyncVisibleMessage(identifier, dataMessage, timestamp, syncTarget);
}; };

Loading…
Cancel
Save