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
16 changes: 14 additions & 2 deletions apps/dav/lib/CalDAV/Reminder/ReminderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use DateTimeImmutable;
use OCA\DAV\CalDAV\CalDavBackend;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUser;
Expand Down Expand Up @@ -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';
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -145,7 +152,12 @@ public function processReminders():void {
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;
Expand Down
1 change: 1 addition & 0 deletions apps/dav/lib/Settings/CalDAVSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class CalDAVSettings implements IDelegatedSettings {
'sendInvitations' => 'yes',
'generateBirthdayCalendar' => 'yes',
'sendEventReminders' => 'yes',
'sendEventRemindersToSharedGroupMembers' => 'yes',
'sendEventRemindersPush' => 'no',
];

Expand Down
4 changes: 4 additions & 0 deletions apps/dav/src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const CalDavSettingsView = new View({
'generateBirthdayCalendar'
),
sendEventReminders: loadState('dav', 'sendEventReminders'),
sendEventRemindersToSharedGroupMembers: loadState(
'dav',
'sendEventRemindersToSharedGroupMembers'
),
sendEventRemindersPush: loadState('dav', 'sendEventRemindersPush'),
}
},
Expand Down
10 changes: 10 additions & 0 deletions apps/dav/src/views/CalDavSettings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('CalDavSettings', () => {
sendInvitations: true,
generateBirthdayCalendar: true,
sendEventReminders: true,
sendEventRemindersToSharedGroupMembers: true,
sendEventRemindersPush: true,
}
},
Expand All @@ -66,6 +67,10 @@ describe('CalDavSettings', () => {
'Send notifications for events'
)
expect(sendEventReminders).toBeChecked()
const sendEventRemindersToSharedGroupMembers = TLUtils.getByLabelText(
'Send reminder notifications to calendar sharees as well'
)
expect(sendEventRemindersToSharedGroupMembers).toBeChecked()
const sendEventRemindersPush = TLUtils.getByLabelText(
'Enable notifications for events via push'
)
Expand Down Expand Up @@ -107,7 +112,10 @@ describe('CalDavSettings', () => {
'sendEventReminders',
'no'
)

expect(sendEventRemindersToSharedGroupMembers).toBeDisabled()
expect(sendEventRemindersPush).toBeDisabled()

OCP.AppConfig.setValue.mockClear()
await userEvent.click(sendEventReminders)
expect(sendEventReminders).toBeChecked()
Expand All @@ -116,6 +124,8 @@ describe('CalDavSettings', () => {
'sendEventReminders',
'yes'
)

expect(sendEventRemindersToSharedGroupMembers).toBeEnabled()
expect(sendEventRemindersPush).toBeEnabled()
})
})
29 changes: 28 additions & 1 deletion apps/dav/src/views/CalDavSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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'
Expand Down Expand Up @@ -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')
},
Expand Down
30 changes: 29 additions & 1 deletion apps/dav/src/views/__snapshots__/CalDavSettings.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,35 @@ exports[`CalDavSettings interactions 1`] = `
</em>
</p>

<p>
<p
class="indented"
>
<input
class="checkbox"
id="caldavSendEventRemindersToSharedGroupMembers"
type="checkbox"
/>

<label
for="caldavSendEventRemindersToSharedGroupMembers"
>

Send reminder notifications to calendar sharees as well

</label>

<br />

<em>

Reminders are always sent to organizers and attendees.

</em>
</p>

<p
class="indented"
>
<input
class="checkbox"
id="caldavSendEventRemindersPush"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -194,6 +198,7 @@ protected function setUp(): void {
$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([]);

Expand All @@ -202,7 +207,8 @@ protected function setUp(): void {
$this->userManager,
$this->groupManager,
$this->caldavBackend,
$this->timeFactory);
$this->timeFactory,
$this->config);
}

public function testOnCalendarObjectDelete():void {
Expand Down
4 changes: 3 additions & 1 deletion apps/dav/tests/unit/Settings/CalDAVSettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ public function testGetForm() {
['dav', 'sendInvitations', 'yes'],
['dav', 'generateBirthdayCalendar', 'yes'],
['dav', 'sendEventReminders', 'yes'],
['dav', 'sendEventRemindersToSharedGroupMembers', 'yes'],
['dav', 'sendEventRemindersPush', 'no'],
)
->will($this->onConsecutiveCalls('yes', 'no', 'yes', 'yes'));
->will($this->onConsecutiveCalls('yes', 'no', 'yes', 'yes', 'yes'));
$this->urlGenerator
->expects($this->once())
->method('linkToDocs')
Expand All @@ -76,6 +77,7 @@ public function testGetForm() {
['sendInvitations', true],
['generateBirthdayCalendar', false],
['sendEventReminders', true],
['sendEventRemindersToSharedGroupMembers', true],
['sendEventRemindersPush', true],
);
$result = $this->settings->getForm();
Expand Down
4 changes: 2 additions & 2 deletions dist/dav-settings-admin-caldav.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dav-settings-admin-caldav.js.map

Large diffs are not rendered by default.