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
fix(settings): ensure we handle file_created, file_deleted and file_r…
…estored as file_changed

Signed-off-by: skjnldsv <[email protected]>
  • Loading branch information
skjnldsv authored and backportbot[bot] committed Mar 26, 2025
commit 284ff8db2d6d117c620ecc930143e775132306ad
15 changes: 13 additions & 2 deletions lib/UserSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace OCA\Activity;

use OCA\Activity\Extension\Files;
use OCP\Activity\ActivitySettings;
use OCP\Activity\Exceptions\SettingNotFoundException;
use OCP\Activity\IManager;
Expand Down Expand Up @@ -173,9 +174,14 @@ public function getNotificationTypes() {
$return = array_map(function (ActivitySettings $setting) {
return $setting->getIdentifier();
}, $settings);
if (array_search('file_changed', $return) !== false) {
array_push($return, 'file_created', 'file_deleted', 'file_restored');

// TYPE_FILE_CHANGED is used to group all file changes together
// But we still differentiate between file_created, file_deleted and file_restored
// so let's add them to the list.
if (array_search(Files::TYPE_FILE_CHANGED, $return) !== false) {
array_push($return, Files::TYPE_SHARE_CREATED, Files::TYPE_SHARE_DELETED, Files::TYPE_SHARE_RESTORED);
}

return $return;
}

Expand All @@ -197,6 +203,11 @@ public function filterUsersBySetting($users, $method, $type) {
return [];
}

// file_created, file_deleted and file_restored are grouped under file_changed
if ($type === Files::TYPE_SHARE_CREATED || $type === Files::TYPE_SHARE_DELETED || $type === Files::TYPE_SHARE_RESTORED) {
$type = Files::TYPE_FILE_CHANGED;
}

$filteredUsers = [];
$potentialUsers = $this->config->getUserValueForUsers('activity', 'notify_' . $method . '_' . $type, $users);
foreach ($potentialUsers as $user => $value) {
Expand Down
Loading