From 85c6c9c5b1c699b14009eb245ff9611fc888841d Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 16 Aug 2016 15:09:05 +0200 Subject: [PATCH 1/2] Make activity compatible with 9.2 --- appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index f2ad233c..acf965ba 100755 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -29,7 +29,7 @@ https://github.com/owncloud/activity.git - + From f336f3aa4d2d565fc1e31a928491c8a2a63b96a4 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 16 Aug 2016 15:07:34 +0200 Subject: [PATCH 2/2] Fix activities when owner is a federated share user --- lib/FilesHooks.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/FilesHooks.php b/lib/FilesHooks.php index 0738a524..8f7d875b 100755 --- a/lib/FilesHooks.php +++ b/lib/FilesHooks.php @@ -148,6 +148,11 @@ protected function addNotificationsForFileAction($filePath, $activityType, $subj } list($filePath, $uidOwner, $fileId) = $this->getSourcePathAndOwner($filePath); + if (!$fileId) { + // no owner, possibly deleted or unknown + // skip notifications + return; + } $affectedUsers = $this->getUserPathsFromPath($filePath, $uidOwner); $filteredStreamUsers = $this->userSettings->filterUsersBySetting(array_keys($affectedUsers), 'stream', $activityType); $filteredEmailUsers = $this->userSettings->filterUsersBySetting(array_keys($affectedUsers), 'email', $activityType); @@ -193,11 +198,19 @@ protected function getUserPathsFromPath($path, $uidOwner) { * @return array */ protected function getSourcePathAndOwner($path) { - $uidOwner = Filesystem::getOwner($path); + $currentUserView = Filesystem::getView(); + $uidOwner = $currentUserView->getOwner($path); $fileId = 0; if ($uidOwner !== $this->currentUser) { - Filesystem::initMountPoints($uidOwner); + list($storage, $internalPath) = $currentUserView->resolvePath($path); + if ($storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) { + // for federated shares we don't have access to the remote user, use the current one + // which will also make it use the matching local "shared::" federated share storage instead + $uidOwner = $this->currentUser; + } else { + Filesystem::initMountPoints($uidOwner); + } } $info = Filesystem::getFileInfo($path); if ($info !== false) {