Bring back conversation.leaveGroup for GV1 scenarios
This commit is contained in:
parent
04eb7bc995
commit
7b15bddfc9
2 changed files with 55 additions and 7 deletions
|
@ -2793,6 +2793,43 @@ export class ConversationModel extends window.Backbone.Model<
|
|||
}
|
||||
}
|
||||
|
||||
async leaveGroup(): Promise<void> {
|
||||
const now = Date.now();
|
||||
if (this.get('type') === 'group') {
|
||||
const groupIdentifiers = this.getRecipients();
|
||||
this.set({ left: true });
|
||||
window.Signal.Data.updateConversation(this.attributes);
|
||||
|
||||
const model = new Whisper.Message(({
|
||||
group_update: { left: 'You' },
|
||||
conversationId: this.id,
|
||||
type: 'outgoing',
|
||||
sent_at: now,
|
||||
received_at: now,
|
||||
// TODO: DESKTOP-722
|
||||
} as unknown) as MessageAttributesType);
|
||||
|
||||
const id = await window.Signal.Data.saveMessage(model.attributes, {
|
||||
Message: Whisper.Message,
|
||||
});
|
||||
model.set({ id });
|
||||
|
||||
const message = window.MessageController.register(model.id, model);
|
||||
this.addSingleMessage(message);
|
||||
|
||||
const options = this.getSendOptions();
|
||||
message.send(
|
||||
this.wrapSend(
|
||||
window.textsecure.messaging.leaveGroup(
|
||||
this.id,
|
||||
groupIdentifiers,
|
||||
options
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async markRead(
|
||||
newestUnreadDate: number,
|
||||
providedOptions: { readAt?: number; sendReadReceipts: boolean }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue