Skip to content

Commit 0486918

Browse files
nickvergessenChristophWurst
authored andcommitted
Remove self setting checking which can not be set anymore
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent 1c9f7be commit 0486918

8 files changed

Lines changed: 14 additions & 54 deletions

File tree

lib/Consumer.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,8 @@ public function receive(IEvent $event) {
7373
$this->notificationGenerator->sendNotificationForEvent($event, $activityId);
7474
}
7575

76-
// User is not the author or wants to see their own actions
77-
$createEmail = !$selfAction || $this->userSettings->getUserSetting($event->getAffectedUser(), 'setting', 'selfemail');
78-
79-
// Add activity to mail queue
80-
if ($emailSetting !== false && $createEmail) {
76+
// Add activity to mail queue and user is not the author
77+
if ($emailSetting !== false && !$selfAction) {
8178
$latestSend = $event->getTimestamp() + $emailSetting;
8279
$this->data->storeMail($event, $latestSend);
8380
}

lib/Data.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,6 @@ public function get(GroupHelper $groupHelper, UserSettings $userSettings, $user,
188188
$query->andWhere($query->expr()->neq('user', $query->createNamedParameter($user)));
189189

190190
} else if ($filter === 'filter') {
191-
if (!$userSettings->getUserSetting($user, 'setting', 'self')) {
192-
$query->andWhere($query->expr()->orX(
193-
$query->expr()->neq('user', $query->createNamedParameter($user)),
194-
$query->expr()->notIn('type', $query->createNamedParameter([
195-
'file_created',
196-
'file_changed',
197-
'file_deleted',
198-
'file_restored',
199-
], IQueryBuilder::PARAM_STR_ARRAY))
200-
));
201-
}
202-
203191
$query->andWhere($query->expr()->eq('object_type', $query->createNamedParameter($objectType)));
204192
$query->andWhere($query->expr()->eq('object_id', $query->createNamedParameter($objectId)));
205193
}

lib/FilesHooks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ protected function addNotificationsForUser($user, $subject, $subjectParams, $fil
11881188
}
11891189

11901190
// Add activity to mail queue
1191-
if ($emailSetting !== false && (!$selfAction || $this->userSettings->getUserSetting($this->currentUser->getUID(), 'setting', 'selfemail'))) {
1191+
if ($emailSetting !== false && !$selfAction) {
11921192
$latestSend = time() + $emailSetting;
11931193
$this->activityData->storeMail($event, $latestSend);
11941194
}

lib/Settings/Admin.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@ public function getForm() {
128128

129129
'setting_batchtime' => $settingBatchTime,
130130

131-
'notify_self' => $this->userSettings->getConfigSetting('setting', 'self'),
132-
'notify_selfemail' => $this->userSettings->getConfigSetting('setting', 'selfemail'),
133-
134131
'methods' => [
135132
IExtension::METHOD_MAIL => $this->l10n->t('Mail'),
136133
IExtension::METHOD_NOTIFICATION => $this->l10n->t('Push'),

lib/Settings/Personal.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@ public function getForm() {
154154

155155
'setting_batchtime' => $settingBatchTime,
156156

157-
'notify_self' => $this->userSettings->getUserSetting($this->user, 'setting', 'self'),
158-
'notify_selfemail' => $this->userSettings->getUserSetting($this->user, 'setting', 'selfemail'),
159-
160157
'methods' => $methods,
161158

162159
'activity_digest_enabled' => $this->userSettings->getUserSetting($this->user, 'setting', 'activity_digest')

tests/ConsumerTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,8 @@ protected function setUp(): void {
8686
->willReturnMap([
8787
['affectedUser', 'notification', 'type', true],
8888
['affectedUser2', 'notification', 'type', true],
89-
['affectedUser', 'setting', 'self', true],
90-
['affectedUser2', 'setting', 'self', false],
9189
['affectedUser', 'email', 'type', true],
9290
['affectedUser2', 'email', 'type', true],
93-
['affectedUser', 'setting', 'selfemail', true],
94-
['affectedUser2', 'setting', 'selfemail', false],
9591
['affectedUser', 'setting', 'batchtime', 10],
9692
['affectedUser2', 'setting', 'batchtime', 10],
9793
]);
@@ -187,7 +183,7 @@ public function testReceiveEmail(string $type, string $author, string $affectedU
187183
->setObject('', 0 , 'file')
188184
->setLink('link');
189185

190-
if ($expected === false) {
186+
if ($expected === false || $author === $affectedUser) {
191187
$this->data->expects($this->never())
192188
->method('storeMail');
193189
} else {

tests/FilesHooksTest.php

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,6 @@ public function dataShareNotificationForOriginalOwners(): array {
851851
return [
852852
[false, false, 'owner', '', 1],
853853
[true, false, 'owner', '', 1],
854-
[true, true, 'owner', null, 1],
855854
[true, true, 'owner', '', 1],
856855
[true, true, 'owner', 'owner', 1],
857856
[true, true, 'owner', 'sharee', 2],
@@ -966,17 +965,15 @@ public function testShareNotificationForSharer(?string $path): void {
966965

967966
public function dataAddNotificationsForUser(): array {
968967
return [
969-
['user', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, true, false, Files_Sharing::TYPE_SHARED, false, false, 'files_sharing', false, false],
970-
['user', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, true, false, Files_Sharing::TYPE_SHARED, true, false, 'files_sharing', true, false],
971-
['notAuthor', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, true, false, Files::TYPE_SHARE_CREATED, false, false, 'files', true, false],
972-
['notAuthor', 'subject', ['parameter'], 0, 'path/subpath', 'path', true, true, false, Files::TYPE_SHARE_CREATED, false, false, 'files', true, false],
973-
974-
['user', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, false, true, Files_Sharing::TYPE_SHARED, false, false, 'files_sharing', false, false],
975-
['user', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, false, true, Files_Sharing::TYPE_SHARED, false, true, 'files_sharing', false, true],
976-
['notAuthor', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, false, true, Files::TYPE_SHARE_CREATED, false, false, 'files', false, true],
977-
['notAuthor', 'subject', ['parameter'], 0, 'path/subpath', 'path', true, false, true, Files::TYPE_SHARE_CREATED, false, false, 'files', false, true],
978-
['notAuthor', 'subject', ['parameter'], 0, 'path/subpath', 'path', true, false, true, Files::TYPE_SHARE_CREATED, false, false, 'files', false, true],
979-
['notAuthor', 'subject', ['parameter'], 0, 'path/subpath', 'path/subpath', false, false, true, Files::TYPE_SHARE_CREATED, false, false, 'files', false, true],
968+
['user', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, true, false, Files_Sharing::TYPE_SHARED, 'files_sharing', false],
969+
['user', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, true, false, Files_Sharing::TYPE_SHARED, 'files_sharing', false],
970+
['notAuthor', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, true, false, Files::TYPE_SHARE_CREATED, 'files', false],
971+
['notAuthor', 'subject', ['parameter'], 0, 'path/subpath', 'path', true, true, false, Files::TYPE_SHARE_CREATED, 'files', false],
972+
973+
['user', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, false, true, Files_Sharing::TYPE_SHARED, 'files_sharing', false],
974+
['notAuthor', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, false, true, Files::TYPE_SHARE_CREATED, 'files', true],
975+
['notAuthor', 'subject', ['parameter'], 0, 'path/subpath', 'path', true, false, true, Files::TYPE_SHARE_CREATED, 'files', true],
976+
['notAuthor', 'subject', ['parameter'], 0, 'path/subpath', 'path/subpath', false, false, true, Files::TYPE_SHARE_CREATED, 'files', true],
980977
];
981978
}
982979

@@ -993,20 +990,10 @@ public function dataAddNotificationsForUser(): array {
993990
* @param bool $notification
994991
* @param bool $email
995992
* @param string $type
996-
* @param bool $selfSetting
997-
* @param bool $selfEmailSetting
998993
* @param string $app
999-
* @param bool $sentStream
1000994
* @param bool $sentEmail
1001995
*/
1002-
public function testAddNotificationsForUser(string $user, string $subject, array $parameter, int $fileId, string $path, string $urlPath, bool $isFile, bool $notification, bool $email, string $type, bool $selfSetting, bool $selfEmailSetting, string $app, bool $sentStream, bool $sentEmail): void {
1003-
$this->settings->expects($this->any())
1004-
->method('getUserSetting')
1005-
->willReturnMap([
1006-
[$user, 'setting', 'self', $selfSetting],
1007-
[$user, 'setting', 'selfemail', $selfEmailSetting],
1008-
]);
1009-
996+
public function testAddNotificationsForUser(string $user, string $subject, array $parameter, int $fileId, string $path, string $urlPath, bool $isFile, bool $notification, bool $email, string $type, string $app, bool $sentEmail): void {
1010997
$this->urlGenerator->expects($this->once())
1011998
->method('linkToRouteAbsolute')
1012999
->with('files.view.index', ['dir' => $urlPath])

tests/UserSettingsTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ protected function setUp(): void {
4848
public function getDefaultSettingData(): array {
4949
return [
5050
['email', 'type1', false],
51-
['setting', 'self', true],
52-
['setting', 'selfemail', false],
5351
['setting', 'batchtime', 3600],
5452
['setting', 'not-exists', false],
5553
];

0 commit comments

Comments
 (0)