From 4dc125de79c081173d7789b1a5b2909e47ee6471 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 16 Aug 2016 16:40:57 +0200 Subject: [PATCH] Use the last known user instead of erroring --- lib/FilesHooks.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/FilesHooks.php b/lib/FilesHooks.php index 94dcc9c94..247c479ef 100755 --- a/lib/FilesHooks.php +++ b/lib/FilesHooks.php @@ -149,6 +149,11 @@ protected function addNotificationsForFileAction($filePath, $activityType, $subj } list($filePath, $uidOwner, $fileId) = $this->getSourcePathAndOwner($filePath); + if ($fileId === 0) { + // Could not find the file for the owner ... + return; + } + $affectedUsers = $this->getUserPathsFromPath($filePath, $uidOwner); $filteredStreamUsers = $this->userSettings->filterUsersBySetting(array_keys($affectedUsers), 'stream', $activityType); $filteredEmailUsers = $this->userSettings->filterUsersBySetting(array_keys($affectedUsers), 'email', $activityType); @@ -194,12 +199,22 @@ protected function getUserPathsFromPath($path, $uidOwner) { * @return array */ protected function getSourcePathAndOwner($path) { - $uidOwner = Filesystem::getOwner($path); + $view = Filesystem::getView(); + $uidOwner = $view->getOwner($path); $fileId = 0; if ($uidOwner !== $this->currentUser) { - Filesystem::initMountPoints($uidOwner); + /** @var \OCP\Files\Storage\IStorage $storage */ + list($storage,) = $view->resolvePath($path); + if (!$storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) { + Filesystem::initMountPoints($uidOwner); + } else { + // Probably a remote user, let's try to at least generate activities + // for the current user + $uidOwner = $this->currentUser; + } } + $info = Filesystem::getFileInfo($path); if ($info !== false) { $ownerView = new View('/' . $uidOwner . '/files');