Improve safety number logic in group conversations
This commit is contained in:
parent
06333aef10
commit
55f4cd591c
4 changed files with 38 additions and 18 deletions
|
@ -198,10 +198,13 @@
|
||||||
|
|
||||||
return { wrap, sendOptions };
|
return { wrap, sendOptions };
|
||||||
},
|
},
|
||||||
async getAllGroupsInvolvingId(id) {
|
async getAllGroupsInvolvingId(conversationId) {
|
||||||
const groups = await window.Signal.Data.getAllGroupsInvolvingId(id, {
|
const groups = await window.Signal.Data.getAllGroupsInvolvingId(
|
||||||
ConversationCollection: Whisper.ConversationCollection,
|
conversationId,
|
||||||
});
|
{
|
||||||
|
ConversationCollection: Whisper.ConversationCollection,
|
||||||
|
}
|
||||||
|
);
|
||||||
return groups.map(group => conversations.add(group));
|
return groups.map(group => conversations.add(group));
|
||||||
},
|
},
|
||||||
loadPromise() {
|
loadPromise() {
|
||||||
|
|
|
@ -14,16 +14,18 @@
|
||||||
throw new Error('KeyChangeListener requires a SignalProtocolStore');
|
throw new Error('KeyChangeListener requires a SignalProtocolStore');
|
||||||
}
|
}
|
||||||
|
|
||||||
signalProtocolStore.on('keychange', async id => {
|
signalProtocolStore.on('keychange', async identifier => {
|
||||||
const conversation = await ConversationController.getOrCreateAndWait(
|
const conversation = await ConversationController.getOrCreateAndWait(
|
||||||
id,
|
identifier,
|
||||||
'private'
|
'private'
|
||||||
);
|
);
|
||||||
conversation.addKeyChange(id);
|
conversation.addKeyChange(identifier);
|
||||||
|
|
||||||
const groups = await ConversationController.getAllGroupsInvolvingId(id);
|
const groups = await ConversationController.getAllGroupsInvolvingId(
|
||||||
|
conversation.id
|
||||||
|
);
|
||||||
_.forEach(groups, group => {
|
_.forEach(groups, group => {
|
||||||
group.addKeyChange(id);
|
group.addKeyChange(identifier);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -37,7 +37,9 @@ describe('KeyChangeListener', () => {
|
||||||
await window.Signal.Data.removeAllMessagesInConversation(convo.id, {
|
await window.Signal.Data.removeAllMessagesInConversation(convo.id, {
|
||||||
MessageCollection: Whisper.MessageCollection,
|
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 => {
|
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', () => {
|
describe('When we have a group with this contact', () => {
|
||||||
|
let groupConvo;
|
||||||
let convo;
|
let convo;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
convo = ConversationController.dangerouslyCreateAndAdd({
|
convo = ConversationController.dangerouslyCreateAndAdd({
|
||||||
|
id: phoneNumberWithKeyChange,
|
||||||
|
type: 'private',
|
||||||
|
});
|
||||||
|
groupConvo = ConversationController.dangerouslyCreateAndAdd({
|
||||||
id: 'groupId',
|
id: 'groupId',
|
||||||
type: 'group',
|
type: 'group',
|
||||||
members: [phoneNumberWithKeyChange],
|
members: [convo.id],
|
||||||
});
|
});
|
||||||
await window.Signal.Data.saveConversation(convo.attributes, {
|
await window.Signal.Data.saveConversation(convo.attributes, {
|
||||||
Conversation: Whisper.Conversation,
|
Conversation: Whisper.Conversation,
|
||||||
});
|
});
|
||||||
|
await window.Signal.Data.saveConversation(groupConvo.attributes, {
|
||||||
|
Conversation: Whisper.Conversation,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
after(async () => {
|
after(async () => {
|
||||||
await window.Signal.Data.removeAllMessagesInConversation(convo.id, {
|
await window.Signal.Data.removeAllMessagesInConversation(groupConvo.id, {
|
||||||
MessageCollection: Whisper.MessageCollection,
|
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 => {
|
it('generates a key change notice in the group conversation with this contact', done => {
|
||||||
const original = convo.addKeyChange;
|
const original = groupConvo.addKeyChange;
|
||||||
convo.addKeyChange = keyChangedId => {
|
groupConvo.addKeyChange = keyChangedId => {
|
||||||
assert.equal(address.getName(), keyChangedId);
|
assert.equal(address.getName(), keyChangedId);
|
||||||
convo.addKeyChange = original;
|
groupConvo.addKeyChange = original;
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@
|
||||||
"rule": "jQuery-load(",
|
"rule": "jQuery-load(",
|
||||||
"path": "js/conversation_controller.js",
|
"path": "js/conversation_controller.js",
|
||||||
"line": " async load() {",
|
"line": " async load() {",
|
||||||
"lineNumber": 215,
|
"lineNumber": 218,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2020-03-24T20:06:31.391Z"
|
"updated": "2020-03-24T20:06:31.391Z"
|
||||||
},
|
},
|
||||||
|
@ -172,7 +172,7 @@
|
||||||
"rule": "jQuery-load(",
|
"rule": "jQuery-load(",
|
||||||
"path": "js/conversation_controller.js",
|
"path": "js/conversation_controller.js",
|
||||||
"line": " this._initialPromise = load();",
|
"line": " this._initialPromise = load();",
|
||||||
"lineNumber": 257,
|
"lineNumber": 260,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2020-03-24T20:06:31.391Z"
|
"updated": "2020-03-24T20:06:31.391Z"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue