diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-09-10 15:26:36 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-09-10 15:26:36 +0200 |
commit | fb717f254fe81065912c13e0907ba374c8167f98 (patch) | |
tree | 1a34b7c8bed92bb5686d73a1521998b2057276cf /apps/files_sharing/api | |
parent | 89cd9295600f6707579240f3f010d4b75a2d85cd (diff) | |
parent | 38001d824b142ca9c47f2afafce91ab8b76f1a9a (diff) | |
download | nextcloud-server-fb717f254fe81065912c13e0907ba374c8167f98.tar.gz nextcloud-server-fb717f254fe81065912c13e0907ba374c8167f98.zip |
Merge pull request #18699 from owncloud/notification-manager
Notification manager
Diffstat (limited to 'apps/files_sharing/api')
-rw-r--r-- | apps/files_sharing/api/remote.php | 4 | ||||
-rw-r--r-- | apps/files_sharing/api/server2server.php | 23 |
2 files changed, 26 insertions, 1 deletions
diff --git a/apps/files_sharing/api/remote.php b/apps/files_sharing/api/remote.php index f6cb0a29d8b..0f6d2dc265a 100644 --- a/apps/files_sharing/api/remote.php +++ b/apps/files_sharing/api/remote.php @@ -38,6 +38,7 @@ class Remote { Filesystem::getMountManager(), Filesystem::getLoader(), \OC::$server->getHTTPHelper(), + \OC::$server->getNotificationManager(), \OC_User::getUser() ); @@ -56,6 +57,7 @@ class Remote { Filesystem::getMountManager(), Filesystem::getLoader(), \OC::$server->getHTTPHelper(), + \OC::$server->getNotificationManager(), \OC_User::getUser() ); @@ -78,6 +80,7 @@ class Remote { Filesystem::getMountManager(), Filesystem::getLoader(), \OC::$server->getHTTPHelper(), + \OC::$server->getNotificationManager(), \OC_User::getUser() ); @@ -87,5 +90,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 4328e3830ba..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 ); @@ -82,6 +83,28 @@ class Server2Server { Activity::FILES_SHARING_APP, Activity::SUBJECT_REMOTE_SHARE_RECEIVED, array($user, trim($name, '/')), '', array(), '', '', $shareWith, Activity::TYPE_REMOTE_SHARE, Activity::PRIORITY_LOW); + $urlGenerator = \OC::$server->getURLGenerator(); + + $notificationManager = \OC::$server->getNotificationManager(); + $notification = $notificationManager->createNotification(); + $notification->setApp('files_sharing') + ->setUser($shareWith) + ->setTimestamp(time()) + ->setObject('remote_share', $remoteId) + ->setSubject('remote_share', [$user, trim($name, '/')]); + + $acceptAction = $notification->createAction(); + $acceptAction->setLabel('accept') + ->setLink($urlGenerator->getAbsoluteURL('/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/' . $remoteId), 'POST'); + $declineAction = $notification->createAction(); + $declineAction->setLabel('decline') + ->setLink($urlGenerator->getAbsoluteURL('/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/' . $remoteId), 'DELETE'); + + $notification->addAction($acceptAction) + ->addAction($declineAction); + + $notificationManager->notify($notification); + return new \OC_OCS_Result(); } catch (\Exception $e) { \OCP\Util::writeLog('files_sharing', 'server can not add remote share, ' . $e->getMessage(), \OCP\Util::ERROR); |