mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Merge pull request #1003 from Mikunj/rollback
Rollback pairing authorisation upload on failure
This commit is contained in:
commit
71caa49a84
|
@ -618,11 +618,27 @@
|
|||
};
|
||||
// Update authorisation in database with the new grant signature
|
||||
await libloki.storage.savePairingAuthorisation(authorisation);
|
||||
await lokiFileServerAPI.updateOurDeviceMapping();
|
||||
await libloki.api.sendPairingAuthorisation(
|
||||
authorisation,
|
||||
secondaryDevicePubKey
|
||||
);
|
||||
|
||||
// Try to upload to the file server and then send a message
|
||||
try {
|
||||
await lokiFileServerAPI.updateOurDeviceMapping();
|
||||
await libloki.api.sendPairingAuthorisation(
|
||||
authorisation,
|
||||
secondaryDevicePubKey
|
||||
);
|
||||
} catch (e) {
|
||||
log.error(
|
||||
'Failed to authorise secondary device: ',
|
||||
e && e.stack ? e.stack : e
|
||||
);
|
||||
// File server upload failed or message sending failed, we should rollback changes
|
||||
await libloki.storage.removePairingAuthorisationForSecondaryPubKey(
|
||||
secondaryDevicePubKey
|
||||
);
|
||||
await lokiFileServerAPI.updateOurDeviceMapping();
|
||||
throw e;
|
||||
}
|
||||
|
||||
// Always be friends with secondary devices
|
||||
await secondaryConversation.setFriendRequestStatus(
|
||||
window.friends.friendRequestStatusEnum.friends,
|
||||
|
|
Loading…
Reference in a new issue