Decline from notification works!

This commit is contained in:
brantje 2016-10-02 17:37:21 +02:00
parent 8e74ab471a
commit 5809b23811
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F
3 changed files with 24 additions and 4 deletions

View file

@ -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));
}
}

View file

@ -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]);
}
}

View file

@ -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);
}
}