mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Fix misuse of getAllDevicePubKeysForPrimaryPubKey and rename some vars
This commit is contained in:
parent
bce18b7ae6
commit
030264c689
2 changed files with 13 additions and 14 deletions
|
@ -1235,14 +1235,18 @@
|
|||
if (activeAt !== null) {
|
||||
activeAt = activeAt || Date.now();
|
||||
}
|
||||
const ourAuthorisations = await libloki.storage.getPrimaryDeviceMapping(
|
||||
window.storage.get('primaryDevicePubKey')
|
||||
const ourPrimaryKey = window.storage.get('primaryDevicePubKey');
|
||||
const ourDevices = await libloki.storage.getAllDevicePubKeysForPrimaryPubKey(
|
||||
ourPrimaryKey
|
||||
);
|
||||
const isSecondaryDevice =
|
||||
ourAuthorisations &&
|
||||
ourAuthorisations.some(auth => auth.secondaryDevicePubKey === id);
|
||||
// TODO: We should probably just *not* send any secondary devices and
|
||||
// just load them all and send FRs when we get the mapping
|
||||
const isOurSecondaryDevice =
|
||||
id !== ourPrimaryKey &&
|
||||
ourDevices &&
|
||||
ourDevices.some(devicePubKey => devicePubKey === id);
|
||||
|
||||
if (isSecondaryDevice) {
|
||||
if (isOurSecondaryDevice) {
|
||||
await conversation.setSecondaryStatus(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -1104,13 +1104,13 @@ MessageReceiver.prototype.extend({
|
|||
window.log.info(
|
||||
`Received pairing authorisation from ${primaryDevicePubKey}`
|
||||
);
|
||||
await libloki.storage.savePairingAuthorisation(pairingAuthorisation);
|
||||
// Set current device as secondary.
|
||||
// This will ensure the authorisation is sent
|
||||
// along with each friend request.
|
||||
window.storage.remove('secondaryDeviceStatus');
|
||||
window.storage.put('isSecondaryDevice', true);
|
||||
window.storage.put('primaryDevicePubKey', primaryDevicePubKey);
|
||||
await libloki.storage.savePairingAuthorisation(pairingAuthorisation);
|
||||
const primaryConversation = await ConversationController.getOrCreateAndWait(
|
||||
primaryDevicePubKey,
|
||||
'private'
|
||||
|
@ -1464,16 +1464,11 @@ MessageReceiver.prototype.extend({
|
|||
async handleSyncMessage(envelope, syncMessage) {
|
||||
const ourNumber = textsecure.storage.user.getNumber();
|
||||
// NOTE: Maybe we should be caching this list?
|
||||
const ourAuthorisations = await libloki.storage.getPrimaryDeviceMapping(
|
||||
const ourDevices = await libloki.storage.getAllDevicePubKeysForPrimaryPubKey(
|
||||
window.storage.get('primaryDevicePubKey')
|
||||
);
|
||||
const validSyncSender =
|
||||
ourAuthorisations &&
|
||||
ourAuthorisations.some(
|
||||
auth =>
|
||||
auth.secondaryDevicePubKey === ourNumber ||
|
||||
auth.primaryDevicePubKey === ourNumber
|
||||
);
|
||||
ourDevices && ourDevices.some(devicePubKey => devicePubKey === ourNumber);
|
||||
if (!validSyncSender) {
|
||||
throw new Error(
|
||||
"Received sync message from a device we aren't paired with"
|
||||
|
|
Loading…
Reference in a new issue