Skip to content

Commit

Permalink
groupfolder activities on move/rename
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl authored and backportbot-nextcloud[bot] committed Jun 8, 2023
1 parent 1d9925b commit 017f276
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/FilesHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,16 @@ public function fileMove($oldPath, $newPath) {
$this->moveCase = false;
return;
}
$this->oldAccessList = $this->getUserPathsFromPath($this->oldParentPath, $this->oldParentOwner);

$oldAccessList = $this->getUserPathsFromPath($this->oldParentPath, $this->oldParentOwner);

// file can be shared using GroupFolders, including ACL check
if ($this->config->getSystemValueBool('activity_use_cached_mountpoints', false)) {
[, , $oldFileId] = $this->getSourcePathAndOwner($oldPath);
$oldAccessList['users'] = array_merge($oldAccessList['users'], $this->getAffectedUsersFromCachedMounts($oldFileId));
}

$this->oldAccessList = $oldAccessList;
}


Expand Down Expand Up @@ -416,6 +425,12 @@ protected function fileRenaming($oldPath, $newPath) {
$this->generateRemoteActivity($renameRemotes, Files::TYPE_FILE_CHANGED, time(), $this->currentUser->getCloudId());

$affectedUsers = $accessList['users'];

// file can be shared using GroupFolders, including ACL check
if ($this->config->getSystemValueBool('activity_use_cached_mountpoints', false)) {
$affectedUsers = array_merge($affectedUsers, $this->getAffectedUsersFromCachedMounts($fileId));
}

[$filteredEmailUsers, $filteredNotificationUsers] = $this->getFileChangeActivitySettings($fileId, array_keys($affectedUsers));

foreach ($affectedUsers as $user => $path) {
Expand Down Expand Up @@ -465,6 +480,12 @@ protected function fileMoving($oldPath, $newPath) {
$affectedUsers = $accessList['users'];
$oldUsers = $this->oldAccessList['users'];

// file can be shared using GroupFolders, including ACL check
if ($this->config->getSystemValueBool('activity_use_cached_mountpoints', false)) {
$this->userMountCache->clear(); // clear cache for new data
$affectedUsers = array_merge($affectedUsers, $this->getAffectedUsersFromCachedMounts($fileId));
}

$beforeUsers = array_keys($oldUsers);
$afterUsers = array_keys($affectedUsers);

Expand Down

0 comments on commit 017f276

Please sign in to comment.