From cace77a629953fa9da697f7c3a155a751e11e242 Mon Sep 17 00:00:00 2001 From: binsky Date: Sat, 17 Oct 2026 23:58:17 +0200 Subject: [PATCH] only open the incoming share request popup for requests of the active vault and hint about requests in other vaults Signed-off-by: binsky --- js/app/controllers/credential.js | 43 +++++++++++++++++++++--- lib/Controller/TranslationController.php | 1 + 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/js/app/controllers/credential.js b/js/app/controllers/credential.js index 962f9f59..71cd55f5 100644 --- a/js/app/controllers/credential.js +++ b/js/app/controllers/credential.js @@ -126,15 +126,49 @@ }); }; - var getPendingShareRequests = function () { + /** + * Tell the user which of their other vaults have pending share requests. + * A share request can only be accepted in the vault it was made for (the shared key is encrypted + * with that vault's sharing key), so vaults created after the share was made have none. + */ + var notifyAboutShareRequestsInOtherVaults = function (shareRequests) { + var vaultGuids = []; + for (var i = 0; i < shareRequests.length; i++) { + if (vaultGuids.indexOf(shareRequests[i].target_vault_guid) === -1) { + vaultGuids.push(shareRequests[i].target_vault_guid); + } + } + VaultService.getVaults().then(function (vaults) { + var vaultNames = []; + for (var v = 0; v < vaults.length; v++) { + if (vaultGuids.indexOf(vaults[v].guid) !== -1) { + vaultNames.push(vaults[v].name); + } + } + if (vaultNames.length > 0) { + NotificationService.showNotification($translate.instant('sharereq.other.vaults') + ' ' + vaultNames.join(', '), 10000); + } + }); + }; + + var getPendingShareRequests = function (notifyOtherVaults) { ShareService.getPendingRequests().then(function (shareRequests) { - if (shareRequests.length > 0) { + if (!shareRequests || shareRequests.length === 0) { + return; + } + // the popup only lists the requests of the active vault, so only open it if there are any + var activeVaultRequests = shareRequests.filter(function (request) { + return request.target_vault_id === $scope.active_vault.vault_id; + }); + if (activeVaultRequests.length > 0) { $scope.incoming_share_requests = shareRequests; jQuery('.share_popup').dialog({ width: 800, modal: true, dialogClass: 'shareincoming-dialog' }); + } else if (notifyOtherVaults) { + notifyAboutShareRequestsInOtherVaults(shareRequests); } }); }; @@ -149,10 +183,11 @@ } else { fetchCredentials(); } - getPendingShareRequests(); + // hint about requests in other vaults once when opening the vault, not on every refresh + getPendingShareRequests(true); refresh_data_interval = $interval(function () { fetchCredentials(); - getPendingShareRequests(); + getPendingShareRequests(false); }, 60000 * 5); } diff --git a/lib/Controller/TranslationController.php b/lib/Controller/TranslationController.php index 7fd9c581..fbb10690 100644 --- a/lib/Controller/TranslationController.php +++ b/lib/Controller/TranslationController.php @@ -352,6 +352,7 @@ public function getLanguageStrings() { 'sharereq.title' => $this->trans->t('You have incoming share requests.'), 'sharereq.line1' => $this->trans->t('If you want to put the credential in another vault,'), 'sharereq.line2' => $this->trans->t('log out of this vault and log into the vault you want the shared credential in.'), + 'sharereq.other.vaults' => $this->trans->t('You have incoming share requests in other vaults:'), 'permissions' => $this->trans->t('Permissions'), 'received.from' => $this->trans->t('Received from'), 'date' => $this->trans->t('Date'),