mirror of
https://github.com/nextcloud/passman.git
synced 2025-10-09 13:07:13 +08:00
Return 404 on most sharing api calls if the data is not found instead of errors
This commit is contained in:
parent
bca3cefd0c
commit
f26416233d
1 changed files with 56 additions and 43 deletions
|
@ -188,24 +188,16 @@ class ShareController extends ApiController {
|
||||||
return new JSONResponse($result);
|
return new JSONResponse($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @NoAdminRequired
|
|
||||||
* @param $credential
|
|
||||||
*/
|
|
||||||
public function share($credential) {
|
|
||||||
|
|
||||||
$link = '';
|
|
||||||
$this->activityService->add(
|
|
||||||
'item_shared', array($credential->label, $this->userId),
|
|
||||||
'', array(),
|
|
||||||
$link, $this->userId, Activity::TYPE_ITEM_ACTION);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function savePendingRequest($item_guid, $target_vault_guid, $final_shared_key) {
|
public function savePendingRequest($item_guid, $target_vault_guid, $final_shared_key) {
|
||||||
$sr = $this->shareService->getRequestByGuid($item_guid, $target_vault_guid);
|
try {
|
||||||
|
$sr = $this->shareService->getRequestByGuid($item_guid, $target_vault_guid);
|
||||||
|
}
|
||||||
|
catch (DoesNotExistException $ex){
|
||||||
|
return new NotFoundResponse();
|
||||||
|
}
|
||||||
|
|
||||||
$manager = \OC::$server->getNotificationManager();
|
$manager = \OC::$server->getNotificationManager();
|
||||||
$notification = $manager->createNotification();
|
$notification = $manager->createNotification();
|
||||||
|
@ -233,15 +225,20 @@ class ShareController extends ApiController {
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function getPendingRequests() {
|
public function getPendingRequests() {
|
||||||
$requests = $this->shareService->getUserPendingRequests($this->userId->getUID());
|
try {
|
||||||
$results = array();
|
$requests = $this->shareService->getUserPendingRequests($this->userId->getUID());
|
||||||
foreach ($requests as $request){
|
$results = array();
|
||||||
$result = $request->jsonSerialize();
|
foreach ($requests as $request) {
|
||||||
$c = $this->credentialService->getCredentialLabelById($request->getItemId());
|
$result = $request->jsonSerialize();
|
||||||
$result['credential_label'] = $c->getLabel();
|
$c = $this->credentialService->getCredentialLabelById($request->getItemId());
|
||||||
array_push($results, $result);
|
$result['credential_label'] = $c->getLabel();
|
||||||
}
|
array_push($results, $result);
|
||||||
return new JSONResponse($results);
|
}
|
||||||
|
return new JSONResponse($results);
|
||||||
|
}
|
||||||
|
catch (DoesNotExistException $ex){
|
||||||
|
return new NotFoundResponse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -250,7 +247,12 @@ class ShareController extends ApiController {
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function getRevisions($item_guid){
|
public function getRevisions($item_guid){
|
||||||
return new JSONResponse($this->shareService->getItemHistory($this->userId, $item_guid));
|
try {
|
||||||
|
return new JSONResponse($this->shareService->getItemHistory($this->userId, $item_guid));
|
||||||
|
}
|
||||||
|
catch (DoesNotExistException $ex){
|
||||||
|
return new NotFoundResponse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -258,7 +260,12 @@ class ShareController extends ApiController {
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function getVaultItems($vault_guid){
|
public function getVaultItems($vault_guid){
|
||||||
return new JSONResponse($this->shareService->getSharedItems($this->userId->getUID(), $vault_guid));
|
try {
|
||||||
|
return new JSONResponse($this->shareService->getSharedItems($this->userId->getUID(), $vault_guid));
|
||||||
|
}
|
||||||
|
catch (DoesNotExistException $ex){
|
||||||
|
return new NotFoundResponse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -267,27 +274,33 @@ class ShareController extends ApiController {
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function deleteShareRequest($share_request_id){
|
public function deleteShareRequest($share_request_id){
|
||||||
$sr = $this->shareService->getShareRequestById($share_request_id);
|
try{
|
||||||
$notification = array(
|
|
||||||
'from_user' => ucfirst($this->userId->getDisplayName()),
|
$sr = $this->shareService->getShareRequestById($share_request_id);
|
||||||
'credential_label' => $this->credentialService->getCredentialLabelById($sr->getItemId())->getLabel(),
|
$notification = array(
|
||||||
'target_user' => $sr->getFromUserId(),
|
'from_user' => ucfirst($this->userId->getDisplayName()),
|
||||||
'req_id' => $sr->getId()
|
'credential_label' => $this->credentialService->getCredentialLabelById($sr->getItemId())->getLabel(),
|
||||||
);
|
'target_user' => $sr->getFromUserId(),
|
||||||
$this->notificationService->credentialDeclinedSharedNotification(
|
'req_id' => $sr->getId()
|
||||||
$notification
|
);
|
||||||
);
|
$this->notificationService->credentialDeclinedSharedNotification(
|
||||||
|
$notification
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
$manager = \OC::$server->getNotificationManager();
|
$manager = \OC::$server->getNotificationManager();
|
||||||
$notification = $manager->createNotification();
|
$notification = $manager->createNotification();
|
||||||
$notification->setApp('passman')
|
$notification->setApp('passman')
|
||||||
->setObject('passman_share_request', $share_request_id)
|
->setObject('passman_share_request', $share_request_id)
|
||||||
->setUser($this->userId->getUID());
|
->setUser($this->userId->getUID());
|
||||||
$manager->markProcessed($notification);
|
$manager->markProcessed($notification);
|
||||||
|
|
||||||
$this->shareService->cleanItemRequestsForUser($sr);
|
$this->shareService->cleanItemRequestsForUser($sr);
|
||||||
return new JSONResponse(array('result'=> true));
|
return new JSONResponse(array('result'=> true));
|
||||||
|
}
|
||||||
|
catch (DoesNotExistException $ex){
|
||||||
|
return new NotFoundResponse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue