diff options
author | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2022-02-24 14:17:43 +0100 |
---|---|---|
committer | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2022-03-21 13:02:46 +0100 |
commit | 73a7ced1fd8cb5c7a0ee74a15890800742d1e455 (patch) | |
tree | a292d5929a0f32a187bd048d756a21fe1cc99434 /apps | |
parent | 84ae0703a3b74c5ce616c7ca690fedebd3a0d3ab (diff) | |
download | nextcloud-server-73a7ced1fd8cb5c7a0ee74a15890800742d1e455.tar.gz nextcloud-server-73a7ced1fd8cb5c7a0ee74a15890800742d1e455.zip |
Fix #31303: Make reminder notification behaviour selectable.
Signed-off-by: Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/CalDAV/Reminder/ReminderService.php | 16 | ||||
-rw-r--r-- | apps/dav/lib/Settings/CalDAVSettings.php | 1 | ||||
-rw-r--r-- | apps/dav/src/settings.js | 4 | ||||
-rw-r--r-- | apps/dav/src/views/CalDavSettings.vue | 29 | ||||
-rw-r--r-- | apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php | 8 |
5 files changed, 54 insertions, 4 deletions
diff --git a/apps/dav/lib/CalDAV/Reminder/ReminderService.php b/apps/dav/lib/CalDAV/Reminder/ReminderService.php index 109fc95e9be..d6901cc4fb0 100644 --- a/apps/dav/lib/CalDAV/Reminder/ReminderService.php +++ b/apps/dav/lib/CalDAV/Reminder/ReminderService.php @@ -33,6 +33,7 @@ namespace OCA\DAV\CalDAV\Reminder; use DateTimeImmutable; use OCA\DAV\CalDAV\CalDavBackend; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\IConfig; use OCP\IGroup; use OCP\IGroupManager; use OCP\IUser; @@ -66,6 +67,9 @@ class ReminderService { /** @var ITimeFactory */ private $timeFactory; + /** @var IConfig */ + private $config; + public const REMINDER_TYPE_EMAIL = 'EMAIL'; public const REMINDER_TYPE_DISPLAY = 'DISPLAY'; public const REMINDER_TYPE_AUDIO = 'AUDIO'; @@ -90,19 +94,22 @@ class ReminderService { * @param IGroupManager $groupManager * @param CalDavBackend $caldavBackend * @param ITimeFactory $timeFactory + * @param IConfig $config */ public function __construct(Backend $backend, NotificationProviderManager $notificationProviderManager, IUserManager $userManager, IGroupManager $groupManager, CalDavBackend $caldavBackend, - ITimeFactory $timeFactory) { + ITimeFactory $timeFactory, + IConfig $config) { $this->backend = $backend; $this->notificationProviderManager = $notificationProviderManager; $this->userManager = $userManager; $this->groupManager = $groupManager; $this->caldavBackend = $caldavBackend; $this->timeFactory = $timeFactory; + $this->config = $config; } /** @@ -145,7 +152,12 @@ class ReminderService { continue; } - $users = $this->getAllUsersWithWriteAccessToCalendar($reminder['calendar_id']); + if ($this->config->getAppValue('dav', 'sendEventRemindersToSharedGroupMembers', 'yes') === 'no') { + $users = $this->getAllUsersWithWriteAccessToCalendar($reminder['calendar_id']); + } else { + $users = []; + } + $user = $this->getUserFromPrincipalURI($reminder['principaluri']); if ($user) { $users[] = $user; diff --git a/apps/dav/lib/Settings/CalDAVSettings.php b/apps/dav/lib/Settings/CalDAVSettings.php index 6e8ab6758e8..6d60b2611e0 100644 --- a/apps/dav/lib/Settings/CalDAVSettings.php +++ b/apps/dav/lib/Settings/CalDAVSettings.php @@ -46,6 +46,7 @@ class CalDAVSettings implements IDelegatedSettings { 'sendInvitations' => 'yes', 'generateBirthdayCalendar' => 'yes', 'sendEventReminders' => 'yes', + 'sendEventRemindersToSharedGroupMembers' => 'yes', 'sendEventRemindersPush' => 'no', ]; diff --git a/apps/dav/src/settings.js b/apps/dav/src/settings.js index a81e11c5257..6744f22ad23 100644 --- a/apps/dav/src/settings.js +++ b/apps/dav/src/settings.js @@ -16,6 +16,10 @@ const CalDavSettingsView = new View({ 'generateBirthdayCalendar' ), sendEventReminders: loadState('dav', 'sendEventReminders'), + sendEventRemindersToSharedGroupMembers: loadState( + 'dav', + 'sendEventRemindersToSharedGroupMembers' + ), sendEventRemindersPush: loadState('dav', 'sendEventRemindersPush'), } }, diff --git a/apps/dav/src/views/CalDavSettings.vue b/apps/dav/src/views/CalDavSettings.vue index 10af947bd3d..f1d39abee42 100644 --- a/apps/dav/src/views/CalDavSettings.vue +++ b/apps/dav/src/views/CalDavSettings.vue @@ -57,7 +57,21 @@ {{ $t('dav', 'Notifications are sent via background jobs, so these must occur often enough.') }} </em> </p> - <p> + <p class="indented"> + <input id="caldavSendEventRemindersToSharedGroupMembers" + v-model="sendEventRemindersToSharedGroupMembers" + type="checkbox" + class="checkbox" + :disabled="!sendEventReminders"> + <label for="caldavSendEventRemindersToSharedGroupMembers"> + {{ $t('dav', 'Send reminder notifications to calendar sharees as well' ) }} + </label> + <br> + <em> + {{ $t('dav', 'Reminders are always sent to organizers and attendees.' ) }} + </em> + </p> + <p class="indented"> <input id="caldavSendEventRemindersPush" v-model="sendEventRemindersPush" type="checkbox" @@ -70,6 +84,12 @@ </div> </template> +<style lang="scss" scoped> + .indented { + padding-left: 28px; + } +</style> + <script> import axios from '@nextcloud/axios' import { generateUrl } from '@nextcloud/router' @@ -118,6 +138,13 @@ export default { sendEventReminders(value) { OCP.AppConfig.setValue('dav', 'sendEventReminders', value ? 'yes' : 'no') }, + sendEventRemindersToSharedGroupMembers(value) { + OCP.AppConfig.setValue( + 'dav', + 'sendEventRemindersToSharedGroupMembers', + value ? 'yes' : 'no' + ) + }, sendEventRemindersPush(value) { OCP.AppConfig.setValue('dav', 'sendEventRemindersPush', value ? 'yes' : 'no') }, diff --git a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php index 660b1a48fd9..39fbf1c79ff 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php @@ -34,6 +34,7 @@ use OCA\DAV\CalDAV\Reminder\INotificationProvider; use OCA\DAV\CalDAV\Reminder\NotificationProviderManager; use OCA\DAV\CalDAV\Reminder\ReminderService; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\IConfig; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserManager; @@ -63,6 +64,9 @@ class ReminderServiceTest extends TestCase { /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */ private $timeFactory; + /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ + private $config; + /** @var ReminderService */ private $reminderService; @@ -194,6 +198,7 @@ EOD; $this->groupManager = $this->createMock(IGroupManager::class); $this->caldavBackend = $this->createMock(CalDavBackend::class); $this->timeFactory = $this->createMock(ITimeFactory::class); + $this->config = $this->createMock(IConfig::class); $this->caldavBackend->method('getShares')->willReturn([]); @@ -202,7 +207,8 @@ EOD; $this->userManager, $this->groupManager, $this->caldavBackend, - $this->timeFactory); + $this->timeFactory, + $this->config); } public function testOnCalendarObjectDelete():void { |