add leave of closed group to new sending pipeline

pull/1183/head
Audric Ackermann 5 years ago
parent 34cec0be34
commit ff7ca5a0d5
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -1924,7 +1924,6 @@
}
if (this.get('type') === 'group') {
const groupNumbers = this.getRecipients();
this.set({ left: true });
await window.Signal.Data.updateConversation(this.id, this.attributes, {
@ -1944,12 +1943,17 @@
});
message.set({ id });
message.send(
this.wrapSend(
textsecure.messaging.leaveGroup(this.id, groupNumbers, {})
)
// FIXME what about public groups?
const quitGroup = {
timestamp: Date.now(),
groupId: this.id,
};
const quitGroupMessage = new new libsession.Messages.Outgoing.ClosedGroupLeaveMessage(
quitGroup
);
await libsession.getMessageQueue().sendToGroup(quitGroupMessage);
this.updateTextInputState();
}
},

@ -1222,14 +1222,6 @@ MessageSender.prototype = {
textsecure.messaging.updateMediumGroup([sender], proto);
},
leaveGroup(groupId, groupNumbers, options) {
const proto = new textsecure.protobuf.DataMessage();
proto.group = new textsecure.protobuf.GroupContext();
proto.group.id = stringToArrayBuffer(groupId);
proto.group.type = textsecure.protobuf.GroupContext.Type.QUIT;
return this.sendGroupProto(groupNumbers, proto, Date.now(), options);
},
async sendExpirationTimerUpdateToGroup(
groupId,
groupNumbers,
@ -1331,7 +1323,6 @@ textsecure.MessageSender = function MessageSenderWrapper(username, password) {
this.setGroupName = sender.setGroupName.bind(sender);
this.setGroupAvatar = sender.setGroupAvatar.bind(sender);
this.requestSenderKeys = sender.requestSenderKeys.bind(sender);
this.leaveGroup = sender.leaveGroup.bind(sender);
this.sendSyncMessage = sender.sendSyncMessage.bind(sender);
this.getProfile = sender.getProfile.bind(sender);
this.uploadAvatar = sender.uploadAvatar.bind(sender);

@ -0,0 +1,29 @@
import { SignalService } from '../../../../../../protobuf';
import { ClosedGroupMessage, ClosedGroupMessageParams } from './ClosedGroupMessage';
export class ClosedGroupLeaveMessage extends ClosedGroupMessage {
constructor(params: ClosedGroupMessageParams) {
super({
timestamp: params.timestamp,
identifier: params.identifier,
groupId: params.groupId,
});
}
public ttl(): number {
return this.getDefaultTTL();
}
protected groupContextType(): SignalService.GroupContext.Type {
return SignalService.GroupContext.Type.QUIT;
}
protected dataProto(): SignalService.DataMessage {
const messageProto = new SignalService.DataMessage();
messageProto.group = this.groupContext();
return messageProto;
}
}
Loading…
Cancel
Save