Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 2 additions & 5 deletions lib/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 0 additions & 12 deletions lib/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/FilesHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 0 additions & 3 deletions lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
3 changes: 0 additions & 3 deletions lib/Settings/Personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 1 addition & 5 deletions tests/ConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
]);
Expand Down Expand Up @@ -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 {
Expand Down
33 changes: 10 additions & 23 deletions tests/FilesHooksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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],
];
}

Expand All @@ -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])
Expand Down
2 changes: 0 additions & 2 deletions tests/UserSettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
];
Expand Down