mirror of
https://github.com/nextcloud/passman.git
synced 2025-10-10 13:36:55 +08:00
Merge branch 'deleteCredentialCleanup'
This commit is contained in:
commit
fc3186eeaf
3 changed files with 28 additions and 14 deletions
|
@ -266,6 +266,10 @@ class CredentialController extends ApiController {
|
|||
'item_destroyed_self', array($credential->getLabel()),
|
||||
'', array(),
|
||||
'', $this->userId, Activity::TYPE_ITEM_ACTION);
|
||||
$this->sharingService->unshareCredential($credential->getGuid());
|
||||
foreach($this->credentialRevisionService->getRevisions($credential->getId()) as $revision){
|
||||
$this->credentialRevisionService->deleteRevision($revision->getId(), $this->userId);
|
||||
}
|
||||
} else {
|
||||
$result = false;
|
||||
}
|
||||
|
|
|
@ -213,20 +213,7 @@ class ShareController extends ApiController {
|
|||
* @NoCSRFRequired
|
||||
*/
|
||||
public function unshareCredential($item_guid) {
|
||||
$acl_list = $this->shareService->getCredentialAclList($item_guid);
|
||||
$request_list = $this->shareService->getShareRequestsByGuid($item_guid);
|
||||
foreach ($acl_list as $ACL) {
|
||||
$this->shareService->deleteShareACL($ACL);
|
||||
}
|
||||
foreach ($request_list as $request) {
|
||||
$this->shareService->deleteShareRequest($request);
|
||||
$manager = \OC::$server->getNotificationManager();
|
||||
$notification = $manager->createNotification();
|
||||
$notification->setApp('passman')
|
||||
->setObject('passman_share_request', $request->getId())
|
||||
->setUser($request->getTargetUserId());
|
||||
$manager->markProcessed($notification);
|
||||
}
|
||||
$this->shareService->unshareCredential($item_guid);
|
||||
return new JSONResponse(array('result' => true));
|
||||
}
|
||||
|
||||
|
|
|
@ -315,4 +315,27 @@ class ShareService {
|
|||
public function updatePendingShareRequestsForCredential($item_guid, $user_id, $permissions) {
|
||||
return $this->shareRequest->updatePendingRequestPermissions($item_guid, $user_id, $permissions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up on credential destroyed.
|
||||
* This will delete all ACL's and share requests.
|
||||
* @param string $item_guid
|
||||
*/
|
||||
|
||||
public function unshareCredential($item_guid) {
|
||||
$acl_list = $this->getCredentialAclList($item_guid);
|
||||
$request_list = $this->getShareRequestsByGuid($item_guid);
|
||||
foreach ($acl_list as $ACL) {
|
||||
$this->deleteShareACL($ACL);
|
||||
}
|
||||
foreach ($request_list as $request) {
|
||||
$this->deleteShareRequest($request);
|
||||
$manager = \OC::$server->getNotificationManager();
|
||||
$notification = $manager->createNotification();
|
||||
$notification->setApp('passman')
|
||||
->setObject('passman_share_request', $request->getId())
|
||||
->setUser($request->getTargetUserId());
|
||||
$manager->markProcessed($notification);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue