mirror of
https://github.com/nextcloud/passman.git
synced 2025-10-06 19:45:54 +08:00
Decline sharing request
This commit is contained in:
parent
b56bda459a
commit
a727fd814d
5 changed files with 33 additions and 1 deletions
|
@ -52,6 +52,7 @@ return [
|
|||
['name' => 'share#applyIntermediateShare', 'url' => '/api/v2/sharing/share', 'verb' => 'POST'],
|
||||
['name' => 'share#savePendingRequest', 'url' => '/api/v2/sharing/save', 'verb' => 'POST'],
|
||||
['name' => 'share#getPendingRequests', 'url' => '/api/v2/sharing/pending', 'verb' => 'GET'],
|
||||
['name' => 'share#deleteShareRequest', 'url' => '/api/v2/sharing/decline/{share_request_id}', 'verb' => 'DELETE'],
|
||||
|
||||
|
||||
//Internal API
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace OCA\Passman\Controller;
|
||||
|
||||
use OCA\Passman\Db\ShareRequest;
|
||||
use OCA\Passman\Db\Vault;
|
||||
use OCA\Passman\Service\CredentialService;
|
||||
use OCA\Passman\Service\NotificationService;
|
||||
|
@ -180,4 +181,17 @@ class ShareController extends ApiController {
|
|||
return new JSONResponse($results);
|
||||
}
|
||||
|
||||
public function deleteShareRequest($share_request_id){
|
||||
echo $share_request_id;
|
||||
|
||||
$manager = \OC::$server->getNotificationManager();
|
||||
$notification = $manager->createNotification();
|
||||
$notification->setApp('passman')
|
||||
->setObject('passman_share_request', $share_request_id)
|
||||
->setUser($this->userId->getUID());
|
||||
$manager->markProcessed($notification);
|
||||
//@TODO load other requests and delete them by item id.
|
||||
$this->shareService->deleteShareRequestById($share_request_id);
|
||||
}
|
||||
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
namespace OCA\Passman\Db;
|
||||
|
||||
|
||||
use Icewind\SMB\Share;
|
||||
use OCA\Passman\Utility\Utils;
|
||||
use OCP\AppFramework\Db\Mapper;
|
||||
use OCP\IDBConnection;
|
||||
|
@ -52,4 +53,8 @@ class ShareRequestMapper extends Mapper {
|
|||
$q = "SELECT * FROM *PREFIX*". self::TABLE_NAME ." WHERE target_user_id = ?";
|
||||
return $this->findEntities($q, [$user_id]);
|
||||
}
|
||||
|
||||
public function deleteShareRequest(ShareRequest $shareRequest){
|
||||
$this->delete($shareRequest);
|
||||
}
|
||||
}
|
|
@ -64,7 +64,7 @@ class NotificationService {
|
|||
$notification->setApp('passman')
|
||||
->setUser($data['target_user'])
|
||||
->setDateTime(new \DateTime())
|
||||
->setObject('credential', $data['item_id']) // $type and $id
|
||||
->setObject('passman_share_request', $data['req_id']) // $type and $id
|
||||
->setSubject('credential_shared', [$data['from_user'], $data['credential_label']]) // $subject and $parameters
|
||||
->setLink($link)
|
||||
->addAction($declineAction);
|
||||
|
|
|
@ -88,4 +88,16 @@ class ShareService {
|
|||
public function getUserPendingRequests($user_id){
|
||||
return $this->shareRequest->getUserPendingRequests($user_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an share reuqest by id
|
||||
* @param $share_request_id
|
||||
*
|
||||
*/
|
||||
public function deleteShareRequestById($id){
|
||||
$t = new ShareRequest();
|
||||
$t->setId($id);
|
||||
$this->shareRequest->deleteShareRequest($t);
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue