diff --git a/js/conversation_controller.js b/js/conversation_controller.js index 625ec40c4e..faa616f57d 100644 --- a/js/conversation_controller.js +++ b/js/conversation_controller.js @@ -198,10 +198,13 @@ return { wrap, sendOptions }; }, - async getAllGroupsInvolvingId(id) { - const groups = await window.Signal.Data.getAllGroupsInvolvingId(id, { - ConversationCollection: Whisper.ConversationCollection, - }); + async getAllGroupsInvolvingId(conversationId) { + const groups = await window.Signal.Data.getAllGroupsInvolvingId( + conversationId, + { + ConversationCollection: Whisper.ConversationCollection, + } + ); return groups.map(group => conversations.add(group)); }, loadPromise() { diff --git a/js/keychange_listener.js b/js/keychange_listener.js index f9b541d447..f913618edd 100644 --- a/js/keychange_listener.js +++ b/js/keychange_listener.js @@ -14,16 +14,18 @@ throw new Error('KeyChangeListener requires a SignalProtocolStore'); } - signalProtocolStore.on('keychange', async id => { + signalProtocolStore.on('keychange', async identifier => { const conversation = await ConversationController.getOrCreateAndWait( - id, + identifier, 'private' ); - conversation.addKeyChange(id); + conversation.addKeyChange(identifier); - const groups = await ConversationController.getAllGroupsInvolvingId(id); + const groups = await ConversationController.getAllGroupsInvolvingId( + conversation.id + ); _.forEach(groups, group => { - group.addKeyChange(id); + group.addKeyChange(identifier); }); }); }, diff --git a/test/keychange_listener_test.js b/test/keychange_listener_test.js index 6cb7da08bf..3007718bc2 100644 --- a/test/keychange_listener_test.js +++ b/test/keychange_listener_test.js @@ -37,7 +37,9 @@ describe('KeyChangeListener', () => { await window.Signal.Data.removeAllMessagesInConversation(convo.id, { MessageCollection: Whisper.MessageCollection, }); - await window.Signal.Data.saveConversation(convo.id); + await window.Signal.Data.removeConversation(convo.id, { + Conversation: Whisper.Conversation, + }); }); it('generates a key change notice in the private conversation with this contact', done => { @@ -52,29 +54,42 @@ describe('KeyChangeListener', () => { }); describe('When we have a group with this contact', () => { + let groupConvo; let convo; before(async () => { convo = ConversationController.dangerouslyCreateAndAdd({ + id: phoneNumberWithKeyChange, + type: 'private', + }); + groupConvo = ConversationController.dangerouslyCreateAndAdd({ id: 'groupId', type: 'group', - members: [phoneNumberWithKeyChange], + members: [convo.id], }); await window.Signal.Data.saveConversation(convo.attributes, { Conversation: Whisper.Conversation, }); + await window.Signal.Data.saveConversation(groupConvo.attributes, { + Conversation: Whisper.Conversation, + }); }); after(async () => { - await window.Signal.Data.removeAllMessagesInConversation(convo.id, { + await window.Signal.Data.removeAllMessagesInConversation(groupConvo.id, { MessageCollection: Whisper.MessageCollection, }); - await window.Signal.Data.saveConversation(convo.id); + await window.Signal.Data.removeConversation(groupConvo.id, { + Conversation: Whisper.Conversation, + }); + await window.Signal.Data.removeConversation(convo.id, { + Conversation: Whisper.Conversation, + }); }); it('generates a key change notice in the group conversation with this contact', done => { - const original = convo.addKeyChange; - convo.addKeyChange = keyChangedId => { + const original = groupConvo.addKeyChange; + groupConvo.addKeyChange = keyChangedId => { assert.equal(address.getName(), keyChangedId); - convo.addKeyChange = original; + groupConvo.addKeyChange = original; done(); }; diff --git a/ts/util/lint/exceptions.json b/ts/util/lint/exceptions.json index 95be90125c..d590b23b4e 100644 --- a/ts/util/lint/exceptions.json +++ b/ts/util/lint/exceptions.json @@ -164,7 +164,7 @@ "rule": "jQuery-load(", "path": "js/conversation_controller.js", "line": " async load() {", - "lineNumber": 215, + "lineNumber": 218, "reasonCategory": "falseMatch", "updated": "2020-03-24T20:06:31.391Z" }, @@ -172,7 +172,7 @@ "rule": "jQuery-load(", "path": "js/conversation_controller.js", "line": " this._initialPromise = load();", - "lineNumber": 257, + "lineNumber": 260, "reasonCategory": "falseMatch", "updated": "2020-03-24T20:06:31.391Z" },