Storing primary device pubkey on the conversation model for easier access, ensuring that we accept all the friend requests from the primary conversation rather than the secondary

pull/613/head
Beaudan Brown 5 years ago
parent 24a687c106
commit 807f4cbd2a

@ -1247,7 +1247,7 @@
ourDevices.some(devicePubKey => devicePubKey === id);
if (isOurSecondaryDevice) {
await conversation.setSecondaryStatus(true);
await conversation.setSecondaryStatus(true, ourPrimaryKey);
}
if (conversation.isFriendRequestStatusNone()) {

@ -766,9 +766,15 @@
isSecondaryDevice() {
return !!this.get('secondaryStatus');
},
async setSecondaryStatus(newStatus) {
getPrimaryDevicePubKey() {
return this.get('getPrimaryDevicePubKey') || this.id;
},
async setSecondaryStatus(newStatus, primaryDevicePubKey) {
if (this.get('secondaryStatus') !== newStatus) {
this.set({ secondaryStatus: newStatus });
this.set({
secondaryStatus: newStatus,
primaryDevicePubKey,
});
await window.Signal.Data.updateConversation(this.id, this.attributes, {
Conversation: Whisper.Conversation,
});
@ -804,7 +810,17 @@
if (!response) {
return;
}
const pending = await this.getFriendRequests(direction, status);
const primaryConversation = ConversationController.get(
this.getPrimaryDevicePubKey()
);
// Should never happen
if (!primaryConversation) {
return;
}
const pending = await primaryConversation.getFriendRequests(
direction,
status
);
await Promise.all(
pending.map(async request => {
if (request.hasErrors()) {
@ -815,7 +831,7 @@
await window.Signal.Data.saveMessage(request.attributes, {
Message: Whisper.Message,
});
this.trigger('updateMessage', request);
primaryConversation.trigger('updateMessage', request);
})
);
},

@ -172,7 +172,10 @@
authorisation.secondaryDevicePubKey,
'private'
);
await conversation.setSecondaryStatus(true);
await conversation.setSecondaryStatus(
true,
authorisation.primaryDevicePubKey
);
await window.Signal.Data.createOrUpdatePairingAuthorisation(authorisation);
}

Loading…
Cancel
Save