Remove rejected authorisation from database

pull/519/head
sachaaaaa 6 years ago
parent ea17437a0c
commit f8e9e1d3bd

@ -74,6 +74,7 @@ module.exports = {
removeAllContactSignedPreKeys,
createOrUpdatePairingAuthorisation,
removePairingAuthorisationForSecondaryPubKey,
getAuthorisationForPubKey,
getSecondaryDevicesFor,
getPrimaryDeviceFor,
@ -1412,6 +1413,15 @@ async function createOrUpdatePairingAuthorisation(data) {
);
}
async function removePairingAuthorisationForSecondaryPubKey(pubKey) {
await db.run(
`DELETE FROM ${PAIRING_AUTHORISATIONS_TABLE} WHERE secondaryDevicePubKey = $secondaryDevicePubKey;`,
{
$secondaryDevicePubKey: pubKey,
}
);
}
async function getSecondaryDevicesFor(primaryDevicePubKey) {
const rows = await db.all(
`SELECT secondaryDevicePubKey FROM ${PAIRING_AUTHORISATIONS_TABLE} WHERE primaryDevicePubKey = $primaryDevicePubKey AND isGranted = 1 ORDER BY secondaryDevicePubKey ASC;`,

@ -823,6 +823,7 @@
Whisper.events.on('devicePairingRequestRejected', async pubKey => {
await window.libloki.storage.removeContactPreKeyBundle(pubKey);
await window.libloki.storage.removePairingAuthorisationForSecondaryPubKey(pubKey);
});
}

@ -90,6 +90,7 @@ module.exports = {
removeAllContactSignedPreKeys,
createOrUpdatePairingAuthorisation,
removePairingAuthorisationForSecondaryPubKey,
getGrantAuthorisationForPubKey,
getAuthorisationForPubKey,
getSecondaryDevicesFor,
@ -607,6 +608,13 @@ async function createOrUpdatePairingAuthorisation(data) {
});
}
async function removePairingAuthorisationForSecondaryPubKey(pubKey) {
if (!pubKey){
return;
}
await channels.removePairingAuthorisationForSecondaryPubKey(pubKey);
}
async function getGrantAuthorisationForPubKey(pubKey) {
const authorisation = await channels.getAuthorisationForPubKey(pubKey, {
granted: true,

@ -117,6 +117,10 @@
return window.Signal.Data.createOrUpdatePairingAuthorisation(authorisation);
}
function removePairingAuthorisationForSecondaryPubKey(pubKey) {
return window.Signal.Data.removePairingAuthorisationForSecondaryPubKey(pubKey);
}
function getGrantAuthorisationForSecondaryPubKey(secondaryPubKey) {
return window.Signal.Data.getGrantAuthorisationForPubKey(secondaryPubKey);
}
@ -141,6 +145,7 @@
removeContactPreKeyBundle,
verifyFriendRequestAcceptPreKey,
savePairingAuthorisation,
removePairingAuthorisationForSecondaryPubKey,
getGrantAuthorisationForSecondaryPubKey,
getAuthorisationForSecondaryPubKey,
getAllDevicePubKeysForPrimaryPubKey,

Loading…
Cancel
Save