Skip to content

Commit

Permalink
Properly initialize session reset send states
Browse files Browse the repository at this point in the history
Co-authored-by: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com>
  • Loading branch information
automated-signal and EvanHahn-Signal committed Sep 24, 2021
1 parent f1d7830 commit baf445c
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions ts/models/conversations.ts
Expand Up @@ -62,7 +62,7 @@ import { getConversationMembers } from '../util/getConversationMembers';
import { sendReadReceiptsFor } from '../util/sendReadReceiptsFor';
import { updateConversationsWithUuidLookup } from '../updateConversationsWithUuidLookup';
import { ReadStatus } from '../messages/MessageReadStatus';
import { SendStatus } from '../messages/MessageSendState';
import { SendState, SendStatus } from '../messages/MessageSendState';
import * as durations from '../util/durations';
import {
concat,
Expand Down Expand Up @@ -4258,18 +4258,27 @@ export class ConversationModel extends window.Backbone
async endSession(): Promise<void> {
if (isDirectConversation(this.attributes)) {
const now = Date.now();
const model = new window.Whisper.Message(({
const pendingSendState: SendState = {
status: SendStatus.Pending,
updatedAt: now,
};
const messageAttributes: Partial<MessageAttributesType> = {
conversationId: this.id,
type: 'outgoing',
sent_at: now,
received_at: window.Signal.Util.incrementMessageCounter(),
received_at_ms: now,
destination: this.get('e164'),
destinationUuid: this.get('uuid'),
recipients: this.getRecipients(),
sendStateByConversationId: {
[this.id]: pendingSendState,
[window.ConversationController.getOurConversationIdOrThrow()]: pendingSendState,
},
flags: Proto.DataMessage.Flags.END_SESSION,
// TODO: DESKTOP-722
} as unknown) as MessageAttributesType);
};

// TODO: DESKTOP-722
const model = new window.Whisper.Message(
messageAttributes as MessageAttributesType
);

const id = await window.Signal.Data.saveMessage(model.attributes);
model.set({ id });
Expand Down

0 comments on commit baf445c

Please sign in to comment.