diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-09-01 18:56:09 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-09-08 09:01:01 +0200 |
commit | 805f1d0096205d346173ab4c0cf314e1c95eba2f (patch) | |
tree | 1803319672878bfeacf3de7f7bbb8acaca37c1ef /apps | |
parent | d191a0daccfa923dcef4ffa9c020fe01f3caf129 (diff) | |
download | nextcloud-server-805f1d0096205d346173ab4c0cf314e1c95eba2f.tar.gz nextcloud-server-805f1d0096205d346173ab4c0cf314e1c95eba2f.zip |
Scrap the notifications when the share is accepted or declined
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/ajax/external.php | 1 | ||||
-rw-r--r-- | apps/files_sharing/api/remote.php | 5 | ||||
-rw-r--r-- | apps/files_sharing/api/server2server.php | 1 | ||||
-rw-r--r-- | apps/files_sharing/appinfo/application.php | 1 | ||||
-rw-r--r-- | apps/files_sharing/lib/external/manager.php | 24 | ||||
-rw-r--r-- | apps/files_sharing/lib/hooks.php | 1 | ||||
-rw-r--r-- | apps/files_sharing/tests/external/managertest.php | 1 | ||||
-rw-r--r-- | apps/files_sharing/tests/server2server.php | 1 |
8 files changed, 33 insertions, 2 deletions
diff --git a/apps/files_sharing/ajax/external.php b/apps/files_sharing/ajax/external.php index d26a64d3aec..66cfd8e9d1a 100644 --- a/apps/files_sharing/ajax/external.php +++ b/apps/files_sharing/ajax/external.php @@ -52,6 +52,7 @@ $externalManager = new \OCA\Files_Sharing\External\Manager( \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getHTTPHelper(), + \OC::$server->getNotificationManager(), \OC::$server->getUserSession()->getUser()->getUID() ); diff --git a/apps/files_sharing/api/remote.php b/apps/files_sharing/api/remote.php index f6cb0a29d8b..404787c3895 100644 --- a/apps/files_sharing/api/remote.php +++ b/apps/files_sharing/api/remote.php @@ -23,6 +23,7 @@ namespace OCA\Files_Sharing\API; use OC\Files\Filesystem; use OCA\Files_Sharing\External\Manager; +use OCP\Notification\IManager; class Remote { @@ -38,6 +39,7 @@ class Remote { Filesystem::getMountManager(), Filesystem::getLoader(), \OC::$server->getHTTPHelper(), + \OC::$server->getNotificationManager(), \OC_User::getUser() ); @@ -56,6 +58,7 @@ class Remote { Filesystem::getMountManager(), Filesystem::getLoader(), \OC::$server->getHTTPHelper(), + \OC::$server->getNotificationManager(), \OC_User::getUser() ); @@ -78,6 +81,7 @@ class Remote { Filesystem::getMountManager(), Filesystem::getLoader(), \OC::$server->getHTTPHelper(), + \OC::$server->getNotificationManager(), \OC_User::getUser() ); @@ -87,5 +91,4 @@ class Remote { return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist."); } - } diff --git a/apps/files_sharing/api/server2server.php b/apps/files_sharing/api/server2server.php index d5f1dce5055..6ecaea20535 100644 --- a/apps/files_sharing/api/server2server.php +++ b/apps/files_sharing/api/server2server.php @@ -70,6 +70,7 @@ class Server2Server { \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getHTTPHelper(), + \OC::$server->getNotificationManager(), $shareWith ); diff --git a/apps/files_sharing/appinfo/application.php b/apps/files_sharing/appinfo/application.php index 530195c65fa..d0dcadb77e8 100644 --- a/apps/files_sharing/appinfo/application.php +++ b/apps/files_sharing/appinfo/application.php @@ -93,6 +93,7 @@ class Application extends App { \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), $server->getHTTPHelper(), + $server->getNotificationManager(), $uid ); }); diff --git a/apps/files_sharing/lib/external/manager.php b/apps/files_sharing/lib/external/manager.php index 67a26c096c2..18b9c724dea 100644 --- a/apps/files_sharing/lib/external/manager.php +++ b/apps/files_sharing/lib/external/manager.php @@ -28,6 +28,7 @@ namespace OCA\Files_Sharing\External; use OC\Files\Filesystem; use OCP\Files; +use OCP\Notification\IManager; class Manager { const STORAGE = '\OCA\Files_Sharing\External\Storage'; @@ -58,19 +59,26 @@ class Manager { private $httpHelper; /** + * @var IManager + */ + private $notificationManager; + + /** * @param \OCP\IDBConnection $connection * @param \OC\Files\Mount\Manager $mountManager * @param \OCP\Files\Storage\IStorageFactory $storageLoader * @param \OC\HTTPHelper $httpHelper + * @param IManager $notificationManager * @param string $uid */ public function __construct(\OCP\IDBConnection $connection, \OC\Files\Mount\Manager $mountManager, - \OCP\Files\Storage\IStorageFactory $storageLoader, \OC\HTTPHelper $httpHelper, $uid) { + \OCP\Files\Storage\IStorageFactory $storageLoader, \OC\HTTPHelper $httpHelper, IManager $notificationManager, $uid) { $this->connection = $connection; $this->mountManager = $mountManager; $this->storageLoader = $storageLoader; $this->httpHelper = $httpHelper; $this->uid = $uid; + $this->notificationManager = $notificationManager; } /** @@ -206,6 +214,7 @@ class Manager { $acceptShare->execute(array(1, $mountPoint, $hash, $id, $this->uid)); $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'accept'); + $this->scrapNotification($share['remote_id']); return true; } @@ -228,6 +237,7 @@ class Manager { $removeShare->execute(array($id, $this->uid)); $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); + $this->scrapNotification($share['remote_id']); return true; } @@ -235,6 +245,17 @@ class Manager { } /** + * @param int $remoteShare + */ + protected function scrapNotification($remoteShare) { + $filter = $this->notificationManager->createNotification(); + $filter->setApp('files_sharing') + ->setUser($this->uid) + ->setObject('remote_share', (int) $remoteShare); + $this->notificationManager->markProcessed($filter); + } + + /** * inform remote server whether server-to-server share was accepted/declined * * @param string $remote @@ -265,6 +286,7 @@ class Manager { \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getHTTPHelper(), + \OC::$server->getNotificationManager(), $params['user'] ); diff --git a/apps/files_sharing/lib/hooks.php b/apps/files_sharing/lib/hooks.php index 7dd04f2f4a0..1937010f390 100644 --- a/apps/files_sharing/lib/hooks.php +++ b/apps/files_sharing/lib/hooks.php @@ -33,6 +33,7 @@ class Hooks { \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getHTTPHelper(), + \OC::$server->getNotificationManager(), $params['uid']); $manager->removeUserShares($params['uid']); diff --git a/apps/files_sharing/tests/external/managertest.php b/apps/files_sharing/tests/external/managertest.php index df01ea0f738..8e03c67a9a3 100644 --- a/apps/files_sharing/tests/external/managertest.php +++ b/apps/files_sharing/tests/external/managertest.php @@ -50,6 +50,7 @@ class ManagerTest extends TestCase { $this->mountManager, new StorageFactory(), $httpHelper, + \OC::$server->getNotificationManager(), $this->uid ); } diff --git a/apps/files_sharing/tests/server2server.php b/apps/files_sharing/tests/server2server.php index a1c87d73393..a4cc8209a8e 100644 --- a/apps/files_sharing/tests/server2server.php +++ b/apps/files_sharing/tests/server2server.php @@ -154,6 +154,7 @@ class Test_Files_Sharing_S2S_OCS_API extends TestCase { \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getHTTPHelper(), + \OC::$server->getNotificationManager(), $toDelete ); |