Remove the notification if accepting/declining failed because of 404

This commit is contained in:
Joas Schilling 2016-02-11 10:11:42 +01:00
parent 5165998723
commit 2263b8b693
2 changed files with 10 additions and 4 deletions

View File

@ -67,6 +67,9 @@ class Remote {
return new \OC_OCS_Result(); return new \OC_OCS_Result();
} }
// Make sure the user has no notification for something that does not exist anymore.
$externalManager->processNotification((int) $params['id']);
return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist."); return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist.");
} }
@ -90,12 +93,15 @@ class Remote {
return new \OC_OCS_Result(); return new \OC_OCS_Result();
} }
// Make sure the user has no notification for something that does not exist anymore.
$externalManager->processNotification((int) $params['id']);
return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist."); return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist.");
} }
/** /**
* @param array $share Share with info from the share_external table * @param array $share Share with info from the share_external table
* @return enriched share info with data from the filecache * @return array enriched share info with data from the filecache
*/ */
private static function extendShareInfo($share) { private static function extendShareInfo($share) {
$view = new \OC\Files\View('/' . \OC_User::getUser() . '/files/'); $view = new \OC\Files\View('/' . \OC_User::getUser() . '/files/');

View File

@ -194,7 +194,7 @@ class Manager {
\OC_Hook::emit('OCP\Share', 'federated_share_added', ['server' => $share['remote']]); \OC_Hook::emit('OCP\Share', 'federated_share_added', ['server' => $share['remote']]);
$this->scrapNotification($id); $this->processNotification($id);
return true; return true;
} }
@ -217,7 +217,7 @@ class Manager {
$removeShare->execute(array($id, $this->uid)); $removeShare->execute(array($id, $this->uid));
$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
$this->scrapNotification($id); $this->processNotification($id);
return true; return true;
} }
@ -227,7 +227,7 @@ class Manager {
/** /**
* @param int $remoteShare * @param int $remoteShare
*/ */
protected function scrapNotification($remoteShare) { public function processNotification($remoteShare) {
$filter = $this->notificationManager->createNotification(); $filter = $this->notificationManager->createNotification();
$filter->setApp('files_sharing') $filter->setApp('files_sharing')
->setUser($this->uid) ->setUser($this->uid)