mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
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
This commit is contained in:
parent
24a687c106
commit
807f4cbd2a
3 changed files with 25 additions and 6 deletions
|
@ -1247,7 +1247,7 @@
|
||||||
ourDevices.some(devicePubKey => devicePubKey === id);
|
ourDevices.some(devicePubKey => devicePubKey === id);
|
||||||
|
|
||||||
if (isOurSecondaryDevice) {
|
if (isOurSecondaryDevice) {
|
||||||
await conversation.setSecondaryStatus(true);
|
await conversation.setSecondaryStatus(true, ourPrimaryKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conversation.isFriendRequestStatusNone()) {
|
if (conversation.isFriendRequestStatusNone()) {
|
||||||
|
|
|
@ -766,9 +766,15 @@
|
||||||
isSecondaryDevice() {
|
isSecondaryDevice() {
|
||||||
return !!this.get('secondaryStatus');
|
return !!this.get('secondaryStatus');
|
||||||
},
|
},
|
||||||
async setSecondaryStatus(newStatus) {
|
getPrimaryDevicePubKey() {
|
||||||
|
return this.get('getPrimaryDevicePubKey') || this.id;
|
||||||
|
},
|
||||||
|
async setSecondaryStatus(newStatus, primaryDevicePubKey) {
|
||||||
if (this.get('secondaryStatus') !== newStatus) {
|
if (this.get('secondaryStatus') !== newStatus) {
|
||||||
this.set({ secondaryStatus: newStatus });
|
this.set({
|
||||||
|
secondaryStatus: newStatus,
|
||||||
|
primaryDevicePubKey,
|
||||||
|
});
|
||||||
await window.Signal.Data.updateConversation(this.id, this.attributes, {
|
await window.Signal.Data.updateConversation(this.id, this.attributes, {
|
||||||
Conversation: Whisper.Conversation,
|
Conversation: Whisper.Conversation,
|
||||||
});
|
});
|
||||||
|
@ -804,7 +810,17 @@
|
||||||
if (!response) {
|
if (!response) {
|
||||||
return;
|
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(
|
await Promise.all(
|
||||||
pending.map(async request => {
|
pending.map(async request => {
|
||||||
if (request.hasErrors()) {
|
if (request.hasErrors()) {
|
||||||
|
@ -815,7 +831,7 @@
|
||||||
await window.Signal.Data.saveMessage(request.attributes, {
|
await window.Signal.Data.saveMessage(request.attributes, {
|
||||||
Message: Whisper.Message,
|
Message: Whisper.Message,
|
||||||
});
|
});
|
||||||
this.trigger('updateMessage', request);
|
primaryConversation.trigger('updateMessage', request);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -172,7 +172,10 @@
|
||||||
authorisation.secondaryDevicePubKey,
|
authorisation.secondaryDevicePubKey,
|
||||||
'private'
|
'private'
|
||||||
);
|
);
|
||||||
await conversation.setSecondaryStatus(true);
|
await conversation.setSecondaryStatus(
|
||||||
|
true,
|
||||||
|
authorisation.primaryDevicePubKey
|
||||||
|
);
|
||||||
await window.Signal.Data.createOrUpdatePairingAuthorisation(authorisation);
|
await window.Signal.Data.createOrUpdatePairingAuthorisation(authorisation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue