diff --git a/lib/Controller/PublicViewController.php b/lib/Controller/PublicViewController.php index 14ed9101c1..e39eaf514b 100644 --- a/lib/Controller/PublicViewController.php +++ b/lib/Controller/PublicViewController.php @@ -89,6 +89,7 @@ private function publicIndex(string $token):PublicTemplateResponse { $defaultShowTasks = $this->config->getAppValue($this->appName, 'showTasks', 'yes'); $defaultTasksSidebar = $this->config->getAppValue($this->appName, 'tasksSidebar', 'yes'); $defaultCanSubscribeLink = $this->config->getAppValue('dav', 'allow_calendar_link_subscriptions', 'yes'); + $defaultSendInvitations = $this->config->getAppValue('dav', 'sendInvitations', 'yes'); $appVersion = $this->config->getAppValue($this->appName, 'installed_version', ''); @@ -110,6 +111,7 @@ private function publicIndex(string $token):PublicTemplateResponse { $this->initialStateService->provideInitialState($this->appName, 'hide_event_export', false); $this->initialStateService->provideInitialState($this->appName, 'can_subscribe_link', $defaultCanSubscribeLink); $this->initialStateService->provideInitialState($this->appName, 'show_resources', false); + $this->initialStateService->provideInitialState($this->appName, 'send_invitations', $defaultSendInvitations); return new PublicTemplateResponse($this->appName, 'main', [ 'share_url' => $this->getShareURL(), diff --git a/lib/Controller/ViewController.php b/lib/Controller/ViewController.php index d12c65befc..106daa93a3 100644 --- a/lib/Controller/ViewController.php +++ b/lib/Controller/ViewController.php @@ -46,7 +46,6 @@ public function __construct( * @return TemplateResponse */ public function index():TemplateResponse { - $this->calendarInitialStateService->run(); return new TemplateResponse($this->appName, 'main'); } diff --git a/lib/Service/CalendarInitialStateService.php b/lib/Service/CalendarInitialStateService.php index 20516b4f2b..a74aa7c194 100644 --- a/lib/Service/CalendarInitialStateService.php +++ b/lib/Service/CalendarInitialStateService.php @@ -74,6 +74,7 @@ public function run(): void { $forceEventAlarmType = false; } $canSubscribeLink = $this->config->getAppValue('dav', 'allow_calendar_link_subscriptions', 'yes') === 'yes'; + $sendInvitations = $this->config->getAppValue('dav', 'sendInvitations', 'yes') === 'yes'; $showResources = $this->config->getAppValue($this->appName, 'showResources', 'yes') === 'yes'; $publicCalendars = $this->config->getAppValue($this->appName, 'publicCalendars', ''); @@ -119,6 +120,7 @@ public function run(): void { $this->initialStateService->provideInitialState('tasks_enabled', $tasksEnabled); $this->initialStateService->provideInitialState('hide_event_export', $hideEventExport); $this->initialStateService->provideInitialState('force_event_alarm_type', $forceEventAlarmType); + $this->initialStateService->provideInitialState('send_invitations', $sendInvitations); if (!is_null($this->userId)) { $this->initialStateService->provideInitialState('appointmentConfigs', $this->appointmentConfigService->getAllAppointmentConfigurations($this->userId)); } diff --git a/src/components/Editor/Invitees/InviteesListItem.vue b/src/components/Editor/Invitees/InviteesListItem.vue index e7566a0f1c..86e7db5c79 100644 --- a/src/components/Editor/Invitees/InviteesListItem.vue +++ b/src/components/Editor/Invitees/InviteesListItem.vue @@ -49,6 +49,7 @@ {{ $t('calendar', 'Request reply') }} @@ -127,6 +128,7 @@ import AvatarParticipationStatus from '@/components/Editor/AvatarParticipationSt import AttendeeDisplay from '@/components/Editor/Invitees/AttendeeDisplay.vue' import { getAttendeeDetails } from '@/services/attendeeDetails.js' import useCalendarObjectInstanceStore from '@/store/calendarObjectInstance.js' +import useSettingsStore from '@/store/settings.js' import { removeMailtoPrefix } from '@/utils/attendee.js' export default { @@ -184,6 +186,7 @@ export default { computed: { ...mapStores(useCalendarObjectInstanceStore), ...mapState(useCalendarObjectInstanceStore, ['calendarObjectInstance']), + ...mapState(useSettingsStore, ['sendInvitations']), /** * @return {string} */ diff --git a/src/store/settings.js b/src/store/settings.js index 10009a9746..73a1a00a69 100644 --- a/src/store/settings.js +++ b/src/store/settings.js @@ -41,6 +41,7 @@ export default defineStore('settings', { timezone: 'automatic', hideEventExport: false, forceEventAlarmType: false, + sendInvitations: true, canSubscribeLink: true, showResources: true, // user-defined Nextcloud settings @@ -347,8 +348,9 @@ export default defineStore('settings', { * @param {string} data.attachmentsFolder Default user's attachments folder * @param {boolean} data.showResources Show or hide the resources tab * @param {string} data.publicCalendars The list of public calendars configured by the administrator + * @param {boolean} data.sendInvitations Whether or not sending invitation e-mails is enabled */ - loadSettingsFromServer({ appVersion, eventLimit, firstRun, showWeekNumbers, showTasks, showWeekends, skipPopover, slotDuration, defaultReminder, defaultReminderPartDay, defaultReminderFullDay, talkEnabled, tasksEnabled, timezone, hideEventExport, forceEventAlarmType, disableAppointments, tasksSidebar, canSubscribeLink, attachmentsFolder, showResources, publicCalendars }) { + loadSettingsFromServer({ appVersion, eventLimit, firstRun, showWeekNumbers, showTasks, showWeekends, skipPopover, slotDuration, defaultReminder, defaultReminderPartDay, defaultReminderFullDay, talkEnabled, tasksEnabled, timezone, hideEventExport, forceEventAlarmType, disableAppointments, tasksSidebar, canSubscribeLink, attachmentsFolder, showResources, publicCalendars, sendInvitations }) { logInfo(` Initial settings: - AppVersion: ${appVersion} @@ -373,6 +375,7 @@ Initial settings: - attachmentsFolder: ${attachmentsFolder} - ShowResources: ${showResources} - PublicCalendars: ${publicCalendars} + - SendInvitations: ${sendInvitations} `) this.appVersion = appVersion @@ -397,6 +400,7 @@ Initial settings: this.attachmentsFolder = attachmentsFolder this.showResources = showResources this.publicCalendars = publicCalendars + this.sendInvitations = sendInvitations }, /** diff --git a/src/views/Calendar.vue b/src/views/Calendar.vue index 183f203461..b1889c4714 100644 --- a/src/views/Calendar.vue +++ b/src/views/Calendar.vue @@ -347,6 +347,7 @@ export default { showResources: loadState('calendar', 'show_resources', true), publicCalendars: loadState('calendar', 'publicCalendars', []), tasksSidebar: loadState('calendar', 'tasks_sidebar', true), + sendInvitations: loadState('calendar', 'send_invitations'), }) this.settingsStore.initializeCalendarJsConfig() diff --git a/tests/javascript/unit/store/settings.test.js b/tests/javascript/unit/store/settings.test.js index 34c62f3fd9..3542483464 100644 --- a/tests/javascript/unit/store/settings.test.js +++ b/tests/javascript/unit/store/settings.test.js @@ -60,6 +60,7 @@ describe('store/settings test suite', () => { showResources: true, publicCalendars: null, searchQuery: '', + sendInvitations: true, }) }) @@ -91,6 +92,7 @@ describe('store/settings test suite', () => { attachmentsFolder: '/Calendar', showResources: true, publicCalendars: null, + sendInvitations: true, } settingsStore.$state = state @@ -119,6 +121,7 @@ describe('store/settings test suite', () => { attachmentsFolder: '/Attachments', showResources: true, publicCalendars: null, + sendInvitations: true, } settingsStore.loadSettingsFromServer(settings) @@ -148,6 +151,7 @@ Initial settings: - attachmentsFolder: /Attachments - ShowResources: true - PublicCalendars: null + - SendInvitations: true `) expect(settingsStore.$state).toEqual({ appVersion: '2.1.0', @@ -176,6 +180,7 @@ Initial settings: showResources: true, publicCalendars: null, searchQuery: '', + sendInvitations: true, }) }) diff --git a/tests/php/unit/Controller/PublicViewControllerTest.php b/tests/php/unit/Controller/PublicViewControllerTest.php index 4c66344711..66815d461a 100644 --- a/tests/php/unit/Controller/PublicViewControllerTest.php +++ b/tests/php/unit/Controller/PublicViewControllerTest.php @@ -48,7 +48,7 @@ protected function setUp():void { } public function testPublicIndexWithBranding():void { - $this->config->expects(self::exactly(12)) + $this->config->expects(self::exactly(13)) ->method('getAppValue') ->willReturnMap([ ['calendar', 'eventLimit', 'yes', 'no'], @@ -62,6 +62,7 @@ public function testPublicIndexWithBranding():void { ['calendar', 'showTasks', 'yes', 'yes'], ['calendar', 'tasksSidebar', 'yes', 'yes'], ['dav', 'allow_calendar_link_subscriptions', 'yes', 'defaultCanSubscribeLink'], + ['dav', 'sendInvitations', 'yes', 'defaultSendInvitations'], ['calendar', 'installed_version', '', '1.0.0'] ]); @@ -87,7 +88,7 @@ public function testPublicIndexWithBranding():void { ->with('imagePath456') ->willReturn('absoluteImagePath456'); - $this->initialStateService->expects(self::exactly(18)) + $this->initialStateService->expects(self::exactly(19)) ->method('provideInitialState') ->willReturnMap([ ['calendar', 'app_version', '1.0.0'], @@ -108,6 +109,7 @@ public function testPublicIndexWithBranding():void { ['calendar', 'hide_event_export', false], ['calendar', 'can_subscribe_link', 'defaultCanSubscribeLink'], ['calendar', 'show_resources', false], + ['calendar', 'send_invitations', 'defaultSendInvitations'], ]); $response = $this->controller->publicIndexWithBranding(''); @@ -132,7 +134,7 @@ public function testRedirectionIfRequestedWithAcceptCalendarHeader(): void { } public function testPublicIndexForEmbedding():void { - $this->config->expects(self::exactly(12)) + $this->config->expects(self::exactly(13)) ->method('getAppValue') ->willReturnMap([ ['calendar', 'eventLimit', 'yes', 'yes'], @@ -146,6 +148,7 @@ public function testPublicIndexForEmbedding():void { ['calendar', 'showTasks', 'yes', 'defaultShowTasks'], ['calendar', 'tasksSidebar', 'yes', 'defaulttasksSidebar'], ['dav', 'allow_calendar_link_subscriptions', 'yes', 'defaultCanSubscribeLink'], + ['dav', 'sendInvitations', 'yes', 'defaultSendInvitations'], ['calendar', 'installed_version', '', '1.0.0'] ]); $this->request->expects(self::once()) @@ -189,11 +192,12 @@ public function testPublicIndexForEmbedding():void { ['calendar', 'hide_event_export', false], ['calendar', 'can_subscribe_link', 'defaultCanSubscribeLink'], ['calendar', 'show_resources', false], + ['calendar', 'send_invitations', 'defaultSendInvitations'], ['calendar', 'is_embed', true], ]; $callIndex = 0; - $this->initialStateService->expects(self::exactly(19)) + $this->initialStateService->expects(self::exactly(20)) ->method('provideInitialState') ->willReturnCallback(function ($appName, $key, $value) use (&$callIndex, $expectedCalls) { $this->assertEquals($expectedCalls[$callIndex][0], $appName); diff --git a/tests/php/unit/Service/CalendarInitialStateServiceTest.php b/tests/php/unit/Service/CalendarInitialStateServiceTest.php index a5a5d5e686..09f84a5367 100755 --- a/tests/php/unit/Service/CalendarInitialStateServiceTest.php +++ b/tests/php/unit/Service/CalendarInitialStateServiceTest.php @@ -104,7 +104,7 @@ public function testRun(): void { $this->groupManager, $this->userManager, ); - $this->config->expects(self::exactly(19)) + $this->config->expects(self::exactly(20)) ->method('getAppValue') ->willReturnMap([ ['calendar', 'eventLimit', 'yes', 'defaultEventLimit'], @@ -124,6 +124,7 @@ public function testRun(): void { ['calendar', 'disableAppointments', 'no', 'no'], ['calendar', 'forceEventAlarmType', '', 'forceEventAlarmType'], ['dav', 'allow_calendar_link_subscriptions', 'yes', 'no'], + ['dav', 'sendInvitations', 'yes', 'yes'], ['calendar', 'showResources', 'yes', 'yes'], ['calendar', 'publicCalendars', ''], ['spreed', 'start_conversations', '[]', '[]'], @@ -175,7 +176,7 @@ public function testRun(): void { ->willReturn([$this->createMock(IResourceBackend::class)]); $this->roomManager->expects(self::never()) ->method('getBackends'); - $this->initialStateService->expects(self::exactly(29)) + $this->initialStateService->expects(self::exactly(30)) ->method('provideInitialState') ->willReturnMap([ ['app_version', '1.0.0'], @@ -198,6 +199,7 @@ public function testRun(): void { ['tasks_enabled', true], ['hide_event_export', true], ['force_event_alarm_type', null], + ['send_invitations', true], ['appointmentConfigs', [new AppointmentConfig()]], ['disable_appointments', false], ['can_subscribe_link', false], @@ -228,7 +230,7 @@ public function testRunAnonymously(): void { $this->groupManager, $this->userManager, ); - $this->config->expects(self::exactly(17)) + $this->config->expects(self::exactly(18)) ->method('getAppValue') ->willReturnMap([ ['calendar', 'eventLimit', 'yes', 'defaultEventLimit'], @@ -248,6 +250,7 @@ public function testRunAnonymously(): void { ['calendar', 'disableAppointments', 'no', 'no'], ['calendar', 'forceEventAlarmType', '', 'forceEventAlarmType'], ['dav', 'allow_calendar_link_subscriptions', 'yes', 'no'], + ['dav', 'sendInvitations', 'yes', 'yes'], ['calendar', 'showResources', 'yes', 'yes'], ['calendar', 'publicCalendars', ''], ]); @@ -293,7 +296,7 @@ public function testRunAnonymously(): void { $this->roomManager->expects(self::once()) ->method('getBackends') ->willReturn([]); - $this->initialStateService->expects(self::exactly(28)) + $this->initialStateService->expects(self::exactly(29)) ->method('provideInitialState') ->willReturnMap([ ['app_version', '1.0.0'], @@ -316,6 +319,7 @@ public function testRunAnonymously(): void { ['tasks_enabled', true], ['hide_event_export', true], ['force_event_alarm_type', null], + ['send_invitations', true], ['disable_appointments', false], ['can_subscribe_link', false], ['show_resources', true], @@ -351,7 +355,7 @@ public function testIndexViewFix(string $savedView, string $expectedView): void $this->groupManager, $this->userManager, ); - $this->config->expects(self::exactly(19)) + $this->config->expects(self::exactly(20)) ->method('getAppValue') ->willReturnMap([ ['calendar', 'eventLimit', 'yes', 'defaultEventLimit'], @@ -371,6 +375,7 @@ public function testIndexViewFix(string $savedView, string $expectedView): void ['calendar', 'disableAppointments', 'no', 'no'], ['calendar', 'forceEventAlarmType', '', 'forceEventAlarmType'], ['dav', 'allow_calendar_link_subscriptions', 'yes', 'no'], + ['dav', 'sendInvitations', 'yes', 'yes'], ['calendar', 'showResources', 'yes', 'yes'], ['calendar', 'publicCalendars', ''], ['spreed', 'start_conversations', '[]', '[]'], @@ -423,7 +428,7 @@ public function testIndexViewFix(string $savedView, string $expectedView): void $this->roomManager->expects(self::once()) ->method('getBackends') ->willReturn([$this->createMock(IRoomBackend::class)]); - $this->initialStateService->expects(self::exactly(29)) + $this->initialStateService->expects(self::exactly(30)) ->method('provideInitialState') ->willReturnMap([ ['app_version', '1.0.0'], @@ -446,6 +451,7 @@ public function testIndexViewFix(string $savedView, string $expectedView): void ['tasks_enabled', false], ['hide_event_export', true], ['force_event_alarm_type', null], + ['send_invitations', true], ['appointmentConfigs', [new AppointmentConfig()]], ['disable_appointments', false], ['can_subscribe_link', false],