diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2015-01-07 12:33:51 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-09-22 13:09:21 +0200 |
commit | 2e1cfe03e9039c6a8257e56e5898a29522c86ea9 (patch) | |
tree | 1cb9fd9d9024919d733b8198281843f32cf4d112 /core/ajax | |
parent | 67231ed9a75eafe5b417e4525e3d80b1a3f8826b (diff) | |
download | nextcloud-server-2e1cfe03e9039c6a8257e56e5898a29522c86ea9.tar.gz nextcloud-server-2e1cfe03e9039c6a8257e56e5898a29522c86ea9.zip |
Publish an activity when sending a share link via email
Diffstat (limited to 'core/ajax')
-rw-r--r-- | core/ajax/share.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php index 69b84564ab1..253095f2980 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -183,6 +183,37 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo $result = $mailNotification->sendLinkShareMail($to_address, $file, $link, $expiration); if(empty($result)) { + // Get the token from the link + $linkParts = explode('/', $link); + $token = array_pop($linkParts); + + // Get the share for the token + $share = \OCP\Share::getShareByToken($token, false); + if ($share !== false) { + $currentUser = \OC::$server->getUserSession()->getUser()->getUID(); + $file = '/' . ltrim($file, '/'); + + // Check whether share belongs to the user and whether the file is the same + if ($share['file_target'] === $file && $share['uid_owner'] === $currentUser) { + + // Get the path for the user + $view = new \OC\Files\View('/' . $currentUser . '/files'); + $fileId = (int) $share['item_source']; + $path = $view->getPath((int) $share['item_source']); + + if ($path !== null) { + $event = \OC::$server->getActivityManager()->generateEvent(); + $event->setApp(\OCA\Files_Sharing\Activity::FILES_SHARING_APP) + ->setType(\OCA\Files_Sharing\Activity::TYPE_SHARED) + ->setAuthor($currentUser) + ->setAffectedUser($currentUser) + ->setObject('files', $fileId, $path) + ->setSubject(\OCA\Files_Sharing\Activity::SUBJECT_SHARED_EMAIL, [$path, $to_address]); + \OC::$server->getActivityManager()->publish($event); + } + } + } + \OCP\JSON::success(); } else { $l = \OC::$server->getL10N('core'); |