diff --git a/js/background.js b/js/background.js index e9f43c901..03a56e9d1 100644 --- a/js/background.js +++ b/js/background.js @@ -641,6 +641,54 @@ const ev = new Event('message'); ev.confirm = () => {}; + + const convo = await ConversationController.getOrCreateAndWait( + groupId, + 'group' + ); + + if (convo.isClosedGroup()) { + // when removing, remove all pubkeys associated with this + // device to avoid sync delay issues and invalid group settings + + // await window.libloki.storage.getPairedDevicesFor() + const allPubkeys = members; + + // for each pubkey, get its paired devices + + // we want to find all current members, + // and subtract members to get members to remove + // membersToRemove = currentMembers - newMembers + + // membersToAdd + + // first, get members to remove. + // then for each user to remove, find its devices + // if pubkey already in devices to remove, skip + const currentMembers = convo.attributes.members; + + const membersToRemove = currentMembers.filter(member => !_.includes(members, member)); + + console.log('[vince] members:', members); + console.log('[vince] currentMembers:', currentMembers); + console.log('[vince] membersToRemove:', membersToRemove); + + + allPubkeys.forEach(pubkey => { + + }); + const pairedDevices = 5; + + console.log('[vince] this.members:', this.get('members')); + console.log('[vince] providedGroupUpdate:', providedGroupUpdate); + console.log('[vince] groupUpdate:', groupUpdate); + + + console.log('[vince] doUpdateGroup: members:', members); + } + + + ev.data = { source: ourKey, timestamp: Date.now(), @@ -655,11 +703,6 @@ }, }; - const convo = await ConversationController.getOrCreateAndWait( - groupId, - 'group' - ); - if (convo.isPublic()) { const API = await convo.getPublicSendData(); diff --git a/js/conversation_controller.js b/js/conversation_controller.js index 171703716..8f6d2fa6c 100644 --- a/js/conversation_controller.js +++ b/js/conversation_controller.js @@ -165,6 +165,22 @@ // Close group leaving if (conversation.isClosedGroup()) { await conversation.leaveGroup(); + + + const deviceIds = await textsecure.storage.protocol.getDeviceIds(id); + await Promise.all( + deviceIds.map(deviceId => { + const address = new libsignal.SignalProtocolAddress(id, deviceId); + const sessionCipher = new libsignal.SessionCipher( + textsecure.storage.protocol, + address + ); + return sessionCipher.deleteAllSessionsForDevice(); + }) + ); + + + } else if (conversation.isPublic()) { const channelAPI = await conversation.getPublicSendData(); if (channelAPI === null) { diff --git a/js/models/conversations.js b/js/models/conversations.js index 48c6781df..a2ca4a46f 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -2235,6 +2235,10 @@ }); message.set({ id }); + + console.log('[vince] conversations.js --> groupUpdate:', groupUpdate); + + const options = this.getSendOptions(); message.send( this.wrapSend( @@ -2271,31 +2275,33 @@ if (this.get('type') === 'group') { const groupNumbers = this.getRecipients(); this.set({ left: true }); - await window.Signal.Data.updateConversation(this.id, this.attributes, { - Conversation: Whisper.Conversation, - }); - const message = this.messageCollection.add({ - group_update: { left: 'You' }, - conversationId: this.id, - type: 'outgoing', - sent_at: now, - received_at: now, - }); - const id = await window.Signal.Data.saveMessage(message.attributes, { - Message: Whisper.Message, - }); - message.set({ id }); + // await window.Signal.Data.updateConversation(this.id, this.attributes, { + // Conversation: Whisper.Conversation, + // }); - const options = this.getSendOptions(); - message.send( - this.wrapSend( - textsecure.messaging.leaveGroup(this.id, groupNumbers, options) - ) - ); + // const message = this.messageCollection.add({ + // group_update: { left: 'You' }, + // conversationId: this.id, + // type: 'outgoing', + // sent_at: now, + // received_at: now, + // }); + + // const id = await window.Signal.Data.saveMessage(message.attributes, { + // Message: Whisper.Message, + // }); + // message.set({ id }); + + // const options = this.getSendOptions(); + // message.send( + // this.wrapSend( + // textsecure.messaging.leaveGroup(this.id, groupNumbers, options) + // ) + // ); - this.updateTextInputState(); + // this.updateTextInputState(); } }, diff --git a/ts/components/conversation/ConversationHeader.tsx b/ts/components/conversation/ConversationHeader.tsx index ad4cd46be..5f4ad3329 100644 --- a/ts/components/conversation/ConversationHeader.tsx +++ b/ts/components/conversation/ConversationHeader.tsx @@ -508,13 +508,13 @@ export class ConversationHeader extends React.Component { // hasNickname && ( // {i18n('clearNickname')} // ); - const archiveConversationMenuItem = isArchived ? ( - - {i18n('moveConversationToInbox')} - - ) : ( - {i18n('archiveConversation')} - ); + // const archiveConversationMenuItem = isArchived ? ( + // + // {i18n('moveConversationToInbox')} + // + // ) : ( + // {i18n('archiveConversation')} + // ); return ( @@ -526,7 +526,7 @@ export class ConversationHeader extends React.Component { {blockHandlerMenuItem} {/* {changeNicknameMenuItem} {clearNicknameMenuItem} */} - {archiveConversationMenuItem} + {/* {archiveConversationMenuItem} */} ); }