Remove rejected authorisation from database

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

@ -74,6 +74,7 @@ module.exports = {
removeAllContactSignedPreKeys, removeAllContactSignedPreKeys,
createOrUpdatePairingAuthorisation, createOrUpdatePairingAuthorisation,
removePairingAuthorisationForSecondaryPubKey,
getAuthorisationForPubKey, getAuthorisationForPubKey,
getSecondaryDevicesFor, getSecondaryDevicesFor,
getPrimaryDeviceFor, 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) { async function getSecondaryDevicesFor(primaryDevicePubKey) {
const rows = await db.all( const rows = await db.all(
`SELECT secondaryDevicePubKey FROM ${PAIRING_AUTHORISATIONS_TABLE} WHERE primaryDevicePubKey = $primaryDevicePubKey AND isGranted = 1 ORDER BY secondaryDevicePubKey ASC;`, `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 => { Whisper.events.on('devicePairingRequestRejected', async pubKey => {
await window.libloki.storage.removeContactPreKeyBundle(pubKey); await window.libloki.storage.removeContactPreKeyBundle(pubKey);
await window.libloki.storage.removePairingAuthorisationForSecondaryPubKey(pubKey);
}); });
} }

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

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

Loading…
Cancel
Save