diff --git a/ts/background.ts b/ts/background.ts index dd902c610..010dd7735 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -2778,9 +2778,11 @@ export async function startApp(): Promise { } await conversation.updateExpirationTimer(expireTimer, { + // Note: because it's our conversationId, this notification will be marked read. But + // setting this will make 'isSetByOther' check true. + source: window.ConversationController.getOurConversationId(), fromSync: true, receivedAt: ev.receivedAtCounter, - source: window.ConversationController.getOurConversationId(), reason: 'group sync', }); } diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index d69feaa53..d2b6ccb35 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -4428,7 +4428,9 @@ export class ConversationModel extends window.Backbone } } - source = source || window.ConversationController.getOurConversationId(); + const ourConversationId = + window.ConversationController.getOurConversationId(); + source = source || ourConversationId; this.set({ expireTimer }); @@ -4442,8 +4444,13 @@ export class ConversationModel extends window.Backbone // to be above the message that initiated that change, hence the subtraction. const sentAt = (providedSentAt || receivedAtMS) - 1; + const isFromSyncOperation = + reason === 'group sync' || reason === 'contact sync'; + const isFromMe = + window.ConversationController.get(source)?.id === ourConversationId; const isNoteToSelf = isMe(this.attributes); - const shouldBeRead = isNoteToSelf || isInitialSync; + const shouldBeRead = + (isInitialSync && isFromSyncOperation) || isFromMe || isNoteToSelf; const model = new window.Whisper.Message({ conversationId: this.id, diff --git a/ts/models/messages.ts b/ts/models/messages.ts index 6bddb730b..48019a971 100644 --- a/ts/models/messages.ts +++ b/ts/models/messages.ts @@ -2663,7 +2663,7 @@ export class MessageModel extends window.Backbone.Model { // point and these calls will return early. if (dataMessage.expireTimer) { conversation.updateExpirationTimer(dataMessage.expireTimer, { - source, + source: sourceUuid || source, receivedAt: message.get('received_at'), receivedAtMS: message.get('received_at_ms'), sentAt: message.get('sent_at'), @@ -2676,7 +2676,7 @@ export class MessageModel extends window.Backbone.Model { !isEndSession(message.attributes) ) { conversation.updateExpirationTimer(undefined, { - source, + source: sourceUuid || source, receivedAt: message.get('received_at'), receivedAtMS: message.get('received_at_ms'), sentAt: message.get('sent_at'), diff --git a/ts/services/contactSync.ts b/ts/services/contactSync.ts index abf136cb0..c4d89b1a2 100644 --- a/ts/services/contactSync.ts +++ b/ts/services/contactSync.ts @@ -61,6 +61,8 @@ async function updateConversationFromContactSync( // expireTimer isn't in Storage Service so we have to rely on contact sync. await conversation.updateExpirationTimer(details.expireTimer, { + // Note: because it's our conversationId, this notification will be marked read. But + // setting this will make 'isSetByOther' check true. source: window.ConversationController.getOurConversationId(), receivedAt: receivedAtCounter, fromSync: true,