diff --git a/lib/Consumer.php b/lib/Consumer.php index 681f9112a..abf385ffd 100644 --- a/lib/Consumer.php +++ b/lib/Consumer.php @@ -72,11 +72,8 @@ public function receive(IEvent $event) { $this->notificationGenerator->sendNotificationForEvent($event, $activityId); } - // User is not the author or wants to see their own actions - $createEmail = !$selfAction || $this->userSettings->getUserSetting($event->getAffectedUser(), 'setting', 'selfemail'); - - // Add activity to mail queue - if ($emailSetting !== false && $createEmail) { + // Add activity to mail queue and user is not the author + if ($emailSetting !== false && !$selfAction) { $latestSend = $event->getTimestamp() + $emailSetting; $this->data->storeMail($event, $latestSend); } diff --git a/lib/Data.php b/lib/Data.php index 8fe963f55..e7704947f 100755 --- a/lib/Data.php +++ b/lib/Data.php @@ -185,18 +185,6 @@ public function get(GroupHelper $groupHelper, UserSettings $userSettings, $user, } elseif ($filter === 'by') { $query->andWhere($query->expr()->neq('user', $query->createNamedParameter($user))); } elseif ($filter === 'filter') { - if (!$userSettings->getUserSetting($user, 'setting', 'self')) { - $query->andWhere($query->expr()->orX( - $query->expr()->neq('user', $query->createNamedParameter($user)), - $query->expr()->notIn('type', $query->createNamedParameter([ - 'file_created', - 'file_changed', - 'file_deleted', - 'file_restored', - ], IQueryBuilder::PARAM_STR_ARRAY)) - )); - } - $query->andWhere($query->expr()->eq('object_type', $query->createNamedParameter($objectType))); $query->andWhere($query->expr()->eq('object_id', $query->createNamedParameter($objectId))); } diff --git a/lib/FilesHooks.php b/lib/FilesHooks.php index b97e346f6..1859e8513 100755 --- a/lib/FilesHooks.php +++ b/lib/FilesHooks.php @@ -1190,7 +1190,7 @@ protected function addNotificationsForUser($user, $subject, $subjectParams, $fil } // Add activity to mail queue - if ($emailSetting !== false && (!$selfAction || $this->userSettings->getUserSetting($this->currentUser->getUID(), 'setting', 'selfemail'))) { + if ($emailSetting !== false && !$selfAction) { $latestSend = time() + $emailSetting; $this->activityData->storeMail($event, $latestSend); } diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index 7fbba6e6e..f7cc9045b 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -128,9 +128,6 @@ public function getForm() { 'setting_batchtime' => $settingBatchTime, - 'notify_self' => $this->userSettings->getConfigSetting('setting', 'self'), - 'notify_selfemail' => $this->userSettings->getConfigSetting('setting', 'selfemail'), - 'methods' => [ IExtension::METHOD_MAIL => $this->l10n->t('Mail'), IExtension::METHOD_NOTIFICATION => $this->l10n->t('Push'), diff --git a/lib/Settings/Personal.php b/lib/Settings/Personal.php index 6b2f71b05..47bc48767 100644 --- a/lib/Settings/Personal.php +++ b/lib/Settings/Personal.php @@ -154,9 +154,6 @@ public function getForm() { 'setting_batchtime' => $settingBatchTime, - 'notify_self' => $this->userSettings->getUserSetting($this->user, 'setting', 'self'), - 'notify_selfemail' => $this->userSettings->getUserSetting($this->user, 'setting', 'selfemail'), - 'methods' => $methods, 'activity_digest_enabled' => $this->userSettings->getUserSetting($this->user, 'setting', 'activity_digest') diff --git a/tests/ConsumerTest.php b/tests/ConsumerTest.php index cc188cccb..3196e9b6a 100644 --- a/tests/ConsumerTest.php +++ b/tests/ConsumerTest.php @@ -87,12 +87,8 @@ protected function setUp(): void { ->willReturnMap([ ['affectedUser', 'notification', 'type', true], ['affectedUser2', 'notification', 'type', true], - ['affectedUser', 'setting', 'self', true], - ['affectedUser2', 'setting', 'self', false], ['affectedUser', 'email', 'type', true], ['affectedUser2', 'email', 'type', true], - ['affectedUser', 'setting', 'selfemail', true], - ['affectedUser2', 'setting', 'selfemail', false], ['affectedUser', 'setting', 'batchtime', 10], ['affectedUser2', 'setting', 'batchtime', 10], ]); @@ -188,7 +184,7 @@ public function testReceiveEmail(string $type, string $author, string $affectedU ->setObject('', 0 , 'file') ->setLink('link'); - if ($expected === false) { + if ($expected === false || $author === $affectedUser) { $this->data->expects($this->never()) ->method('storeMail'); } else { diff --git a/tests/FilesHooksTest.php b/tests/FilesHooksTest.php index d55b31ea2..b659fbf4b 100755 --- a/tests/FilesHooksTest.php +++ b/tests/FilesHooksTest.php @@ -852,7 +852,6 @@ public function dataShareNotificationForOriginalOwners(): array { return [ [false, false, 'owner', '', 1], [true, false, 'owner', '', 1], - [true, true, 'owner', null, 1], [true, true, 'owner', '', 1], [true, true, 'owner', 'owner', 1], [true, true, 'owner', 'sharee', 2], @@ -967,17 +966,15 @@ public function testShareNotificationForSharer(?string $path): void { public function dataAddNotificationsForUser(): array { return [ - ['user', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, true, false, Files_Sharing::TYPE_SHARED, false, false, 'files_sharing', false, false], - ['user', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, true, false, Files_Sharing::TYPE_SHARED, true, false, 'files_sharing', true, false], - ['notAuthor', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, true, false, Files::TYPE_SHARE_CREATED, false, false, 'files', true, false], - ['notAuthor', 'subject', ['parameter'], 0, 'path/subpath', 'path', true, true, false, Files::TYPE_SHARE_CREATED, false, false, 'files', true, false], - - ['user', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, false, true, Files_Sharing::TYPE_SHARED, false, false, 'files_sharing', false, false], - ['user', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, false, true, Files_Sharing::TYPE_SHARED, false, true, 'files_sharing', false, true], - ['notAuthor', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, false, true, Files::TYPE_SHARE_CREATED, false, false, 'files', false, true], - ['notAuthor', 'subject', ['parameter'], 0, 'path/subpath', 'path', true, false, true, Files::TYPE_SHARE_CREATED, false, false, 'files', false, true], - ['notAuthor', 'subject', ['parameter'], 0, 'path/subpath', 'path', true, false, true, Files::TYPE_SHARE_CREATED, false, false, 'files', false, true], - ['notAuthor', 'subject', ['parameter'], 0, 'path/subpath', 'path/subpath', false, false, true, Files::TYPE_SHARE_CREATED, false, false, 'files', false, true], + ['user', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, true, false, Files_Sharing::TYPE_SHARED, 'files_sharing', false], + ['user', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, true, false, Files_Sharing::TYPE_SHARED, 'files_sharing', false], + ['notAuthor', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, true, false, Files::TYPE_SHARE_CREATED, 'files', false], + ['notAuthor', 'subject', ['parameter'], 0, 'path/subpath', 'path', true, true, false, Files::TYPE_SHARE_CREATED, 'files', false], + + ['user', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, false, true, Files_Sharing::TYPE_SHARED, 'files_sharing', false], + ['notAuthor', 'subject', ['parameter'], 42, 'path/subpath', 'path', true, false, true, Files::TYPE_SHARE_CREATED, 'files', true], + ['notAuthor', 'subject', ['parameter'], 0, 'path/subpath', 'path', true, false, true, Files::TYPE_SHARE_CREATED, 'files', true], + ['notAuthor', 'subject', ['parameter'], 0, 'path/subpath', 'path/subpath', false, false, true, Files::TYPE_SHARE_CREATED, 'files', true], ]; } @@ -994,20 +991,10 @@ public function dataAddNotificationsForUser(): array { * @param bool $notification * @param bool $email * @param string $type - * @param bool $selfSetting - * @param bool $selfEmailSetting * @param string $app - * @param bool $sentStream * @param bool $sentEmail */ - 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 { - $this->settings->expects($this->any()) - ->method('getUserSetting') - ->willReturnMap([ - [$user, 'setting', 'self', $selfSetting], - [$user, 'setting', 'selfemail', $selfEmailSetting], - ]); - + 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 { $this->urlGenerator->expects($this->once()) ->method('linkToRouteAbsolute') ->with('files.view.index', ['dir' => $urlPath]) diff --git a/tests/UserSettingsTest.php b/tests/UserSettingsTest.php index 2e662e10a..5d4c5c748 100644 --- a/tests/UserSettingsTest.php +++ b/tests/UserSettingsTest.php @@ -47,8 +47,6 @@ protected function setUp(): void { public function getDefaultSettingData(): array { return [ ['email', 'type1', false], - ['setting', 'self', true], - ['setting', 'selfemail', false], ['setting', 'batchtime', 3600], ['setting', 'not-exists', false], ];