diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2017-07-21 12:07:32 +0200 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2017-07-21 12:07:32 +0200 |
commit | e78040d2502aba01b5dd92497078ac71afab771a (patch) | |
tree | 88b733e37fa5ad8b45ee21766996f3d8ae4baf0c /apps/files_sharing | |
parent | 5e468c0bbaf6b9838a1b92bcb04836dccff7b532 (diff) | |
download | nextcloud-server-e78040d2502aba01b5dd92497078ac71afab771a.tar.gz nextcloud-server-e78040d2502aba01b5dd92497078ac71afab771a.zip |
improved error handling
check if table was updated successfully and only then send a notification
mail and return "true".
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/lib/Controller/RemoteController.php | 12 | ||||
-rw-r--r-- | apps/files_sharing/lib/External/Manager.php | 19 |
2 files changed, 20 insertions, 11 deletions
diff --git a/apps/files_sharing/lib/Controller/RemoteController.php b/apps/files_sharing/lib/Controller/RemoteController.php index 7c7a608ff2d..299b6fe4df7 100644 --- a/apps/files_sharing/lib/Controller/RemoteController.php +++ b/apps/files_sharing/lib/Controller/RemoteController.php @@ -29,6 +29,7 @@ use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSForbiddenException; use OCP\AppFramework\OCS\OCSNotFoundException; use OCP\AppFramework\OCSController; +use OCP\ILogger; use OCP\IRequest; class RemoteController extends OCSController { @@ -36,6 +37,9 @@ class RemoteController extends OCSController { /** @var Manager */ private $externalManager; + /** @var ILogger */ + private $logger; + /** * @NoAdminRequired * @@ -47,10 +51,12 @@ class RemoteController extends OCSController { */ public function __construct($appName, IRequest $request, - Manager $externalManager) { + Manager $externalManager, + ILogger $logger) { parent::__construct($appName, $request); $this->externalManager = $externalManager; + $this->logger = $logger; } /** @@ -78,8 +84,8 @@ class RemoteController extends OCSController { return new DataResponse(); } - // Make sure the user has no notification for something that does not exist anymore. - $this->externalManager->processNotification($id); + $this->logger->error('Could not accept federated share with id: ' . $id, + ['app' => 'files_sharing']); throw new OCSNotFoundException('wrong share ID, share doesn\'t exist.'); } diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index 54d0f9bd0c3..fe4fe492a2b 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -197,6 +197,7 @@ class Manager { public function acceptShare($id) { $share = $this->getShare($id); + $result = false; if ($share) { \OC_Util::setupFS($this->uid); @@ -211,16 +212,18 @@ class Manager { `mountpoint` = ?, `mountpoint_hash` = ? WHERE `id` = ? AND `user` = ?'); - $acceptShare->execute(array(1, $mountPoint, $hash, $id, $this->uid)); - $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'accept'); - - \OC_Hook::emit('OCP\Share', 'federated_share_added', ['server' => $share['remote']]); - - $this->processNotification($id); - return true; + $updated = $acceptShare->execute(array(1, $mountPoint, $hash, $id, $this->uid)); + if ($updated === true) { + $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'accept'); + \OC_Hook::emit('OCP\Share', 'federated_share_added', ['server' => $share['remote']]); + $result = true; + } } - return false; + // Make sure the user has no notification for something that does not exist anymore. + $this->processNotification($id); + + return $result; } /** |