Improve safety number logic in group conversations

This commit is contained in:
Scott Nonnenberg 2020-06-09 09:50:36 -07:00
parent 06333aef10
commit 55f4cd591c
4 changed files with 38 additions and 18 deletions

View file

@ -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();
};