Merge pull request #22253 from owncloud/notifications-for-remote-shares

Notifications for remote shares
remotes/origin/users-ajaxloadgroups
Thomas Müller 8 years ago
commit 9a2c517ca8

@ -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();
}

@ -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) {

@ -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'),
];
});
*/

@ -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();
}
});
},
/**

@ -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;
}

@ -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':

Loading…
Cancel
Save