Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions js/app/controllers/credential.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
};
Expand All @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions lib/Controller/TranslationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Loading