Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/files_sharing/api/remote.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function acceptShare($params) {
\OC_User::getUser()
);

if ($externalManager->acceptShare($params['id'])) {
if ($externalManager->acceptShare((int) $params['id'])) {
return new \OC_OCS_Result();
}

Expand All @@ -86,7 +86,7 @@ public static function declineShare($params) {
\OC_User::getUser()
);

if ($externalManager->declineShare($params['id'])) {
if ($externalManager->declineShare((int) $params['id'])) {
return new \OC_OCS_Result();
}

Expand Down
12 changes: 5 additions & 7 deletions apps/files_sharing/api/server2server.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,37 +81,35 @@ public function createShare($params) {

try {
$externalManager->addShare($remote, $token, '', $name, $owner, false, $shareWith, $remoteId);
$shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external');

$user = $owner . '@' . $this->cleanupRemote($remote);

\OC::$server->getActivityManager()->publishActivity(
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) {
Expand Down
8 changes: 5 additions & 3 deletions apps/files_sharing/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,14 @@ function() {
}
}

/**
* 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'),
];
});
*/
14 changes: 13 additions & 1 deletion apps/files_sharing/js/external.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could put that in an else block (optional)

if (e.notification.app === 'files_sharing' && e.notification.object_type === 'remote_share' && e.action.type === 'POST') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

underscore case (object_type) is usually not accepted in the JS coding style, but I guess this comes from the original JSON structure, so ok to keep

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's json

// User accepted a remote share reload
self.filesApp.fileList.reload();
}
});
},

/**
Expand Down
4 changes: 2 additions & 2 deletions apps/files_sharing/lib/external/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function acceptShare($id) {

\OC_Hook::emit('OCP\Share', 'federated_share_added', ['server' => $share['remote']]);

//FIXME $this->scrapNotification($share['remote_id']);
$this->scrapNotification($id);
return true;
}

Expand All @@ -217,7 +217,7 @@ public function declineShare($id) {
$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;
}

Expand Down
5 changes: 3 additions & 2 deletions apps/files_sharing/lib/notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function prepare(INotification $notification, $languageCode) {
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
Expand All @@ -64,7 +64,8 @@ public function prepare(INotification $notification, $languageCode) {
case 'accept':
$action->setParsedLabel(
(string) $l->t('Accept')
);
)
->setPrimary(true);
break;

case 'decline':
Expand Down