Make push notifications for calendar reminders opt-in
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
This commit is contained in:
parent
daf89e6b34
commit
88f6d1c20e
|
@ -41,4 +41,13 @@ $('#caldavSendRemindersNotifications').change(function() {
|
||||||
var val = $(this)[0].checked;
|
var val = $(this)[0].checked;
|
||||||
|
|
||||||
OCP.AppConfig.setValue('dav', 'sendEventReminders', val ? 'yes' : 'no');
|
OCP.AppConfig.setValue('dav', 'sendEventReminders', val ? 'yes' : 'no');
|
||||||
|
|
||||||
|
$('#caldavSendRemindersNotificationsPush').prop('disabled', !val)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#caldavSendRemindersNotificationsPush').change(function() {
|
||||||
|
var val = $(this)[0].checked;
|
||||||
|
|
||||||
|
OCP.AppConfig.setValue('dav', 'sendEventRemindersPush', val ? 'yes' : 'no');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,10 @@ class PushProvider extends AbstractProvider {
|
||||||
public function send(VEvent $vevent,
|
public function send(VEvent $vevent,
|
||||||
string $calendarDisplayName=null,
|
string $calendarDisplayName=null,
|
||||||
array $users=[]):void {
|
array $users=[]):void {
|
||||||
|
if ($this->config->getAppValue('dav', 'sendEventRemindersPush', 'no') !== 'yes') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$eventDetails = $this->extractEventDetails($vevent);
|
$eventDetails = $this->extractEventDetails($vevent);
|
||||||
$eventDetails['calendar_displayname'] = $calendarDisplayName;
|
$eventDetails['calendar_displayname'] = $calendarDisplayName;
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ class CalDAVSettings implements ISettings {
|
||||||
'send_invitations' => $this->config->getAppValue('dav', 'sendInvitations', 'yes'),
|
'send_invitations' => $this->config->getAppValue('dav', 'sendInvitations', 'yes'),
|
||||||
'generate_birthday_calendar' => $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'),
|
'generate_birthday_calendar' => $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'),
|
||||||
'send_reminders_notifications' => $this->config->getAppValue('dav', 'sendEventReminders', 'yes'),
|
'send_reminders_notifications' => $this->config->getAppValue('dav', 'sendEventReminders', 'yes'),
|
||||||
|
'send_reminders_notifications_push' => $this->config->getAppValue('dav', 'sendEventRemindersPush', 'no'),
|
||||||
];
|
];
|
||||||
|
|
||||||
return new TemplateResponse('dav', 'settings-admin-caldav', $parameters);
|
return new TemplateResponse('dav', 'settings-admin-caldav', $parameters);
|
||||||
|
|
|
@ -93,4 +93,10 @@ script('dav', [
|
||||||
<br>
|
<br>
|
||||||
<em><?php p($l->t('Notifications will be send through background jobs, so these need to happen often enough.')); ?></em>
|
<em><?php p($l->t('Notifications will be send through background jobs, so these need to happen often enough.')); ?></em>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<input type="checkbox" name="caldav_send_reminders_notifications_push" id="caldavSendRemindersNotificationsPush" class="checkbox"
|
||||||
|
<?php ($_['send_reminders_notifications_push'] === 'yes') ? print_unescaped('checked="checked"') : null ?>
|
||||||
|
<?php ($_['send_reminders_notifications'] === 'yes') ? null : print_unescaped('disabled="disabled"') ?> />
|
||||||
|
<label for="caldavSendRemindersNotificationsPush"><?php p($l->t('Enable notifications for events via push')); ?></label>
|
||||||
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -63,6 +63,7 @@ class PushProviderTest extends AbstractNotificationProviderTest {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->config = $this->createMock(IConfig::class);
|
||||||
$this->manager = $this->createMock(IManager::class);
|
$this->manager = $this->createMock(IManager::class);
|
||||||
$this->timeFactory = $this->createMock(ITimeFactory::class);
|
$this->timeFactory = $this->createMock(ITimeFactory::class);
|
||||||
|
|
||||||
|
@ -80,7 +81,38 @@ class PushProviderTest extends AbstractNotificationProviderTest {
|
||||||
$this->assertEquals(PushProvider::NOTIFICATION_TYPE, 'DISPLAY');
|
$this->assertEquals(PushProvider::NOTIFICATION_TYPE, 'DISPLAY');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNotSend(): void {
|
||||||
|
$this->config->expects($this->once())
|
||||||
|
->method('getAppValue')
|
||||||
|
->with('dav', 'sendEventRemindersPush', 'no')
|
||||||
|
->willReturn('no');
|
||||||
|
|
||||||
|
$this->manager->expects($this->never())
|
||||||
|
->method('createNotification');
|
||||||
|
$this->manager->expects($this->never())
|
||||||
|
->method('notify');
|
||||||
|
|
||||||
|
$user1 = $this->createMock(IUser::class);
|
||||||
|
$user1->method('getUID')
|
||||||
|
->willReturn('uid1');
|
||||||
|
$user2 = $this->createMock(IUser::class);
|
||||||
|
$user2->method('getUID')
|
||||||
|
->willReturn('uid2');
|
||||||
|
$user3 = $this->createMock(IUser::class);
|
||||||
|
$user3->method('getUID')
|
||||||
|
->willReturn('uid3');
|
||||||
|
|
||||||
|
$users = [$user1, $user2, $user3];
|
||||||
|
|
||||||
|
$this->provider->send($this->vcalendar->VEVENT, $this->calendarDisplayName, $users);
|
||||||
|
}
|
||||||
|
|
||||||
public function testSend(): void {
|
public function testSend(): void {
|
||||||
|
$this->config->expects($this->once())
|
||||||
|
->method('getAppValue')
|
||||||
|
->with('dav', 'sendEventRemindersPush', 'no')
|
||||||
|
->willReturn('yes');
|
||||||
|
|
||||||
$user1 = $this->createMock(IUser::class);
|
$user1 = $this->createMock(IUser::class);
|
||||||
$user1->method('getUID')
|
$user1->method('getUID')
|
||||||
->willReturn('uid1');
|
->willReturn('uid1');
|
||||||
|
|
Loading…
Reference in New Issue