Skip to content
Merged
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
19 changes: 17 additions & 2 deletions lib/FilesHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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');
Expand Down