From d191a0daccfa923dcef4ffa9c020fe01f3caf129 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 1 Sep 2015 17:59:01 +0200 Subject: Add notifications for remote shares --- apps/files_sharing/api/server2server.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'apps/files_sharing/api') 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); -- cgit v1.2.3