Skip to content

Commit 9693221

Browse files
authored
Merge pull request #1948 from nextcloud/backport/1947/stable31
[stable31] fix(settings): ensure we handle file_created, file_deleted and file_restored as file_changed
2 parents 21cc2d8 + 2602b1e commit 9693221

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/UserSettings.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace OCA\Activity;
99

10+
use OCA\Activity\Extension\Files;
1011
use OCP\Activity\ActivitySettings;
1112
use OCP\Activity\Exceptions\SettingNotFoundException;
1213
use OCP\Activity\IManager;
@@ -173,9 +174,14 @@ public function getNotificationTypes() {
173174
$return = array_map(function (ActivitySettings $setting) {
174175
return $setting->getIdentifier();
175176
}, $settings);
176-
if (array_search('file_changed', $return) !== false) {
177-
array_push($return, 'file_created', 'file_deleted', 'file_restored');
177+
178+
// TYPE_FILE_CHANGED is used to group all file changes together
179+
// But we still differentiate between file_created, file_deleted and file_restored
180+
// so let's add them to the list.
181+
if (array_search(Files::TYPE_FILE_CHANGED, $return) !== false) {
182+
array_push($return, Files::TYPE_SHARE_CREATED, Files::TYPE_SHARE_DELETED, Files::TYPE_SHARE_RESTORED);
178183
}
184+
179185
return $return;
180186
}
181187

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

206+
// file_created, file_deleted and file_restored are grouped under file_changed
207+
if ($type === Files::TYPE_SHARE_CREATED || $type === Files::TYPE_SHARE_DELETED || $type === Files::TYPE_SHARE_RESTORED) {
208+
$type = Files::TYPE_FILE_CHANGED;
209+
}
210+
200211
$filteredUsers = [];
201212
$potentialUsers = $this->config->getUserValueForUsers('activity', 'notify_' . $method . '_' . $type, $users);
202213
foreach ($potentialUsers as $user => $value) {

0 commit comments

Comments
 (0)