mirror of
https://github.com/nextcloud/passman.git
synced 2025-01-03 22:11:46 +08:00
Decline from notification works!
This commit is contained in:
parent
8e74ab471a
commit
5809b23811
3 changed files with 24 additions and 4 deletions
|
@ -182,16 +182,18 @@ class ShareController extends ApiController {
|
|||
}
|
||||
|
||||
public function deleteShareRequest($share_request_id){
|
||||
echo $share_request_id;
|
||||
|
||||
$sr = $this->shareService->getSharingRequestById($share_request_id);
|
||||
$share_requests = $this->shareService->getShareRequestsByItemId($sr->getItemId());
|
||||
foreach ($share_requests as $share_request){
|
||||
$this->shareService->deleteShareRequestById($share_request->getId());
|
||||
}
|
||||
$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);
|
||||
return new JSONResponse(array('result'=>true));
|
||||
}
|
||||
|
||||
}
|
|
@ -57,4 +57,14 @@ class ShareRequestMapper extends Mapper {
|
|||
public function deleteShareRequest(ShareRequest $shareRequest){
|
||||
$this->delete($shareRequest);
|
||||
}
|
||||
|
||||
public function getSharingRequestById($id){
|
||||
$q = "SELECT * FROM *PREFIX*" . self::TABLE_NAME . " WHERE id = ?";
|
||||
return $this->findEntity($q, [$id]);
|
||||
}
|
||||
|
||||
public function getShareRequestsByItemId($item_id){
|
||||
$q = "SELECT * FROM *PREFIX*" . self::TABLE_NAME . " WHERE item_id = ?";
|
||||
return $this->findEntities($q, [$item_id]);
|
||||
}
|
||||
}
|
|
@ -100,4 +100,12 @@ class ShareService {
|
|||
$this->shareRequest->deleteShareRequest($t);
|
||||
|
||||
}
|
||||
|
||||
public function getSharingRequestById($id){
|
||||
return $this->shareRequest->getSharingRequestById($id);
|
||||
}
|
||||
|
||||
public function getShareRequestsByItemId($item_id){
|
||||
return $this->shareRequest->getShareRequestsByItemId($item_id);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue