mirror of
https://github.com/nextcloud/passman.git
synced 2025-03-03 10:53:35 +08:00
Dont create new requests for a credential, when target user has pending requests for that credential
This commit is contained in:
parent
00149bb912
commit
eb915e065e
3 changed files with 26 additions and 2 deletions
|
@ -110,6 +110,13 @@ class ShareController extends ApiController {
|
|||
//@TODO add expire_views
|
||||
$credential = $this->credentialService->getCredentialById($item_id, $this->userId->getUID());
|
||||
$credential_owner = $credential->getUserId();
|
||||
|
||||
$first_vault = $vaults[0];
|
||||
$shareRequests = $this->shareService->getPendingShareRequests($item_guid, $first_vault['user_id']);
|
||||
if(count($shareRequests) > 0){
|
||||
return new JSONResponse(array('error'=> 'User got already pending requests'));
|
||||
}
|
||||
|
||||
$result = $this->shareService->createBulkRequests($item_id, $item_guid, $vaults, $permissions, $credential_owner);
|
||||
if ($credential) {
|
||||
$processed_users = array();
|
||||
|
@ -130,8 +137,6 @@ class ShareController extends ApiController {
|
|||
array_push($processed_users, $target_user);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return new JSONResponse($result);
|
||||
}
|
||||
|
@ -377,6 +382,7 @@ class ShareController extends ApiController {
|
|||
$acl = $this->shareService->getACL($user_id, $item_guid);
|
||||
$acl->setPermissions($permission);
|
||||
$this->shareService->updateCredentialACL($acl);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -77,4 +77,14 @@ class ShareRequestMapper extends Mapper {
|
|||
$q = "SELECT * FROM *PREFIX*" . self::TABLE_NAME . " WHERE item_guid = ?";
|
||||
return $this->findEntities($q, [$item_guid]);
|
||||
}
|
||||
|
||||
public function updateShareRequest(ShareRequest $shareRequest){
|
||||
return $this->update($shareRequest);
|
||||
}
|
||||
|
||||
public function getPendingShareRequests($item_guid, $user_id){
|
||||
$q = "SELECT * FROM *PREFIX*" . self::TABLE_NAME . " WHERE item_guid = ? and target_user_id= ?";
|
||||
return $this->findEntities($q, [$item_guid, $user_id]);
|
||||
}
|
||||
|
||||
}
|
|
@ -252,4 +252,12 @@ class ShareService {
|
|||
public function updateCredentialACL(SharingACL $sharingACL){
|
||||
return $this->sharingACL->updateCredentialACL($sharingACL);
|
||||
}
|
||||
|
||||
public function updateCredentialShareRequest(ShareRequest $shareRequest){
|
||||
return $this->shareRequest->updateShareRequest($shareRequest);
|
||||
}
|
||||
|
||||
public function getPendingShareRequests($item_guid, $user_id){
|
||||
return $this->shareRequest->getPendingShareRequests($item_guid, $user_id);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue