Merge pull request #1235 from Bilb/closed-group-update-sync

handle sync for closed groups update as we do for regular messages
pull/1243/head
Audric Ackermann 5 years ago committed by GitHub
commit 49164f069e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1704,7 +1704,17 @@
const expirationTimerMessage = new libsession.Messages.Outgoing.ExpirationTimerUpdateMessage(
expireUpdate
);
// special case when we are the only member of a closed group
const ourNumber = textsecure.storage.user.getNumber();
const primary = await libsession.Protocols.MultiDeviceProtocol.getPrimaryDevice(
ourNumber
);
if (
this.get('members').length === 1 &&
this.get('members')[0] === primary.key
) {
return message.sendSyncMessageOnly(expirationTimerMessage);
}
await libsession.getMessageQueue().sendToGroup(expirationTimerMessage);
}
return message;
@ -1890,6 +1900,7 @@
const updateParams = {
// if we do set an identifier here, be sure to not sync the message two times in msg.handleMessageSentSuccess()
identifier: messageId,
timestamp: now,
groupId: id,
name: name || this.getName(),
@ -1901,7 +1912,11 @@
updateParams
);
await this.sendClosedGroupMessageWithSync(groupUpdateMessage, recipients);
await this.sendClosedGroupMessage(
groupUpdateMessage,
recipients,
message
);
if (groupUpdate.joined && groupUpdate.joined.length) {
const expireUpdate = {
@ -2002,6 +2017,7 @@
// FIXME what about public groups?
const quitGroup = {
identifier: id,
timestamp: now,
groupId: this.id,
// if we do set an identifier here, be sure to not sync it a second time in handleMessageSentSuccess()
@ -2010,13 +2026,13 @@
quitGroup
);
await this.sendClosedGroupMessageWithSync(quitGroupMessage);
await this.sendClosedGroupMessage(quitGroupMessage, undefined, message);
this.updateTextInputState();
}
},
async sendClosedGroupMessageWithSync(message, recipients) {
async sendClosedGroupMessage(message, recipients, dbMessage) {
const {
ClosedGroupMessage,
ClosedGroupChatMessage,
@ -2043,6 +2059,11 @@
const otherMembers = (members || []).filter(
member => !primary.isEqual(member)
);
// we are the only member in here
if (members.length === 1 && members[0] === primary.key) {
dbMessage.sendSyncMessageOnly(message);
return;
}
const sendPromises = otherMembers.map(member => {
const memberPubKey = libsession.Types.PubKey.cast(member);
return libsession
@ -2050,16 +2071,6 @@
.sendUsingMultiDevice(memberPubKey, message);
});
await Promise.all(sendPromises);
// Send the sync message to our devices
const syncMessage = new libsession.Messages.Outgoing.SentSyncMessage({
timestamp: Date.now(),
identifier: message.identifier,
destination: message.groupId,
dataMessage: message.dataProto(),
});
await libsession.getMessageQueue().sendSyncMessage(syncMessage);
} catch (e) {
window.log.error(e);
}

@ -1245,7 +1245,7 @@
);
const { dataMessage } = contentDecoded;
if (dataMessage) {
this.sendSyncMessage(dataMessage);
await this.sendSyncMessage(dataMessage);
}
} else if (shouldMarkMessageAsSynced) {
this.set({ synced: true });

Loading…
Cancel
Save