summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/api
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-09-01 17:59:01 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-09-08 09:01:01 +0200
commitd191a0daccfa923dcef4ffa9c020fe01f3caf129 (patch)
tree585e0399cd5f6abb3b57d25ff7a88a19480889a1 /apps/files_sharing/api
parent57c273b2dae918e1b007c1f1d1cd37ec9f6fb248 (diff)
downloadnextcloud-server-d191a0daccfa923dcef4ffa9c020fe01f3caf129.tar.gz
nextcloud-server-d191a0daccfa923dcef4ffa9c020fe01f3caf129.zip
Add notifications for remote shares
Diffstat (limited to 'apps/files_sharing/api')
-rw-r--r--apps/files_sharing/api/server2server.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/apps/files_sharing/api/server2server.php b/apps/files_sharing/api/server2server.php
index 4328e3830ba..d5f1dce5055 100644
--- a/apps/files_sharing/api/server2server.php
+++ b/apps/files_sharing/api/server2server.php
@@ -82,6 +82,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);