fix: regular messages correctly sync again

pull/2971/head
William Grant 2 years ago
parent 17f8431f59
commit 60aac9be85

@ -1011,7 +1011,6 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
}
const { dataMessage } = content;
// TODO maybe we need to account for lastDisappearingMessageChangeTimestamp?
if (
dataMessage &&
(dataMessage.body?.length ||
@ -1028,32 +1027,23 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
// );
const expireUpdate = await checkForExpireUpdateInContentMessage(content, conversation, true);
if (
!isEmpty(expireUpdate) &&
!expireUpdate.isOutdated &&
expireUpdate.lastDisappearingMessageChangeTimestamp
) {
const syncMessage = buildSyncMessage(
this.id,
dataMessage as SignalService.DataMessage,
conversation.id,
sentTimestamp,
expireUpdate
);
const syncMessage = buildSyncMessage(
this.id,
dataMessage as SignalService.DataMessage,
conversation.id,
sentTimestamp,
expireUpdate
);
if (syncMessage) {
await getMessageQueue().sendSyncMessage({
namespace: SnodeNamespaces.UserMessages,
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({
sentSync: true,
});
this.set({ sentSync: true });
await this.commit();
}

@ -371,7 +371,7 @@ export const buildSyncMessage = (
syncTarget: string,
sentTimestamp: number,
expireUpdate?: DisappearingMessageUpdate
): VisibleMessage | ExpirationTimerUpdateMessage => {
): VisibleMessage | ExpirationTimerUpdateMessage | null => {
if (
(data as any).constructor.name !== 'DataMessage' &&
!(data instanceof SignalService.DataMessage)
@ -392,17 +392,32 @@ export const buildSyncMessage = (
!isEmpty(expireUpdate) &&
expireUpdate.lastDisappearingMessageChangeTimestamp
) {
const syncExpireTimerMessage = buildSyncExpireTimerMessage(
if (expireUpdate.isOutdated) {
window.log.debug(`WIP: buildSyncMessage: \nexpireUpdate is outdated`);
return null;
}
const expireTimerSyncMessage = buildSyncExpireTimerMessage(
identifier,
expireUpdate,
timestamp,
syncTarget
);
window.log.warn(
`WIP: buildSyncMessage: \nsyncExpireTimerMessage: ${JSON.stringify(syncExpireTimerMessage)}`
`WIP: buildSyncMessage: \nexpireTimerSyncMessage: ${JSON.stringify(expireTimerSyncMessage)}`
);
return syncExpireTimerMessage;
return expireTimerSyncMessage;
}
return buildSyncVisibleMessage(identifier, dataMessage, timestamp, syncTarget);
const visibleSyncMessage = buildSyncVisibleMessage(
identifier,
dataMessage,
timestamp,
syncTarget
);
window.log.warn(
`WIP: buildSyncMessage: \nvisibleSyncMessage: ${JSON.stringify(visibleSyncMessage)}`
);
return visibleSyncMessage;
};

Loading…
Cancel
Save