diff --git a/apps/files_sharing/api/remote.php b/apps/files_sharing/api/remote.php index 06b2e6c1687ec051ef81b6be7f2787958dfa0f6c..4b7192994a75e5cdefa13ebabbb2170ab7e2a45c 100644 --- a/apps/files_sharing/api/remote.php +++ b/apps/files_sharing/api/remote.php @@ -63,7 +63,7 @@ class Remote { \OC_User::getUser() ); - if ($externalManager->acceptShare($params['id'])) { + if ($externalManager->acceptShare((int) $params['id'])) { return new \OC_OCS_Result(); } @@ -86,7 +86,7 @@ class Remote { \OC_User::getUser() ); - if ($externalManager->declineShare($params['id'])) { + if ($externalManager->declineShare((int) $params['id'])) { return new \OC_OCS_Result(); } diff --git a/apps/files_sharing/api/server2server.php b/apps/files_sharing/api/server2server.php index e1195cb95734a6bf575021fa71201b3ccdae3217..a27b3a3bd85528e36b301c9c7bdbe1afb3663778 100644 --- a/apps/files_sharing/api/server2server.php +++ b/apps/files_sharing/api/server2server.php @@ -81,6 +81,7 @@ class Server2Server { try { $externalManager->addShare($remote, $token, '', $name, $owner, false, $shareWith, $remoteId); + $shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external'); $user = $owner . '@' . $this->cleanupRemote($remote); @@ -88,30 +89,27 @@ class Server2Server { Activity::FILES_SHARING_APP, Activity::SUBJECT_REMOTE_SHARE_RECEIVED, array($user, trim($name, '/')), '', array(), '', '', $shareWith, Activity::TYPE_REMOTE_SHARE, Activity::PRIORITY_LOW); - /** - * FIXME $urlGenerator = \OC::$server->getURLGenerator(); $notificationManager = \OC::$server->getNotificationManager(); $notification = $notificationManager->createNotification(); $notification->setApp('files_sharing') ->setUser($shareWith) - ->setTimestamp(time()) - ->setObject('remote_share', $remoteId) + ->setDateTime(new \DateTime()) + ->setObject('remote_share', $shareId) ->setSubject('remote_share', [$user, trim($name, '/')]); $declineAction = $notification->createAction(); $declineAction->setLabel('decline') - ->setLink($urlGenerator->getAbsoluteURL('/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/' . $remoteId), 'DELETE'); + ->setLink($urlGenerator->getAbsoluteURL('/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId), 'DELETE'); $notification->addAction($declineAction); $acceptAction = $notification->createAction(); $acceptAction->setLabel('accept') - ->setLink($urlGenerator->getAbsoluteURL('/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/' . $remoteId), 'POST'); + ->setLink($urlGenerator->getAbsoluteURL('/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId), 'POST'); $notification->addAction($acceptAction); $notificationManager->notify($notification); - */ return new \OC_OCS_Result(); } catch (\Exception $e) { diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php index 7a418d179db5938fd34264bc6919f05eb56dd518..29202c15b22f3d79b4935dccbc554c975727e806 100644 --- a/apps/files_sharing/appinfo/app.php +++ b/apps/files_sharing/appinfo/app.php @@ -114,12 +114,14 @@ if ($config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') { } } -/** - * FIXME $manager = \OC::$server->getNotificationManager(); $manager->registerNotifier(function() { return new \OCA\Files_Sharing\Notifier( \OC::$server->getL10NFactory() ); +}, function() use ($l) { + return [ + 'id' => 'files_sharing', + 'name' => $l->t('Federated sharing'), + ]; }); - */ diff --git a/apps/files_sharing/js/external.js b/apps/files_sharing/js/external.js index 45a6ef027586b1e76b59c6862d164db65cfff9d5..0ca8213168e45bc6ec979b35c08b1b887bb0ac49 100644 --- a/apps/files_sharing/js/external.js +++ b/apps/files_sharing/js/external.js @@ -69,9 +69,21 @@ filesApp: null, attach: function(filesApp) { + var self = this; this.filesApp = filesApp; this.processIncomingShareFromUrl(); - this.processSharesToConfirm(); + + if (!$('#header').find('div.notifications').length) { + // No notification app, display the modal + this.processSharesToConfirm(); + } + + $('body').on('OCA.Notification.Action', function(e) { + if (e.notification.app === 'files_sharing' && e.notification.object_type === 'remote_share' && e.action.type === 'POST') { + // User accepted a remote share reload + self.filesApp.fileList.reload(); + } + }); }, /** diff --git a/apps/files_sharing/lib/external/manager.php b/apps/files_sharing/lib/external/manager.php index ea49348737fee761105bc41a6359db780878e60b..21729d326e58cf92c40ac2a6fe0e9525ef78478a 100644 --- a/apps/files_sharing/lib/external/manager.php +++ b/apps/files_sharing/lib/external/manager.php @@ -194,7 +194,7 @@ class Manager { \OC_Hook::emit('OCP\Share', 'federated_share_added', ['server' => $share['remote']]); - //FIXME $this->scrapNotification($share['remote_id']); + $this->scrapNotification($id); return true; } @@ -217,7 +217,7 @@ class Manager { $removeShare->execute(array($id, $this->uid)); $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); - //FIXME $this->scrapNotification($share['remote_id']); + $this->scrapNotification($id); return true; } diff --git a/apps/files_sharing/lib/notifier.php b/apps/files_sharing/lib/notifier.php index 802f22e44c551ea33245b448a5dbc91763c73d4e..27e4e2565f2968a2255e55f07e3a79df872d4ffe 100644 --- a/apps/files_sharing/lib/notifier.php +++ b/apps/files_sharing/lib/notifier.php @@ -55,7 +55,7 @@ class Notifier implements INotifier { case 'remote_share': $params = $notification->getSubjectParameters(); $notification->setParsedSubject( - (string) $l->t('You received %2$s as a remote share from %1$s', $params) + (string) $l->t('You received "/%2$s" as a remote share from %1$s', $params) ); // Deal with the actions for a known subject @@ -64,7 +64,8 @@ class Notifier implements INotifier { case 'accept': $action->setParsedLabel( (string) $l->t('Accept') - ); + ) + ->setPrimary(true); break; case 'decline':