0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-02-14 12:59:20 +00:00
nextcloud_server/apps/dav/lib/BackgroundJob/EventReminderJob.php
provokateurin 381077028a
refactor(apps): Use constructor property promotion when possible
Signed-off-by: provokateurin <kate@provokateurin.de>
2024-10-21 12:37:59 +02:00

49 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\DAV\BackgroundJob;
use OC\User\NoUserException;
use OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException;
use OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException;
use OCA\DAV\CalDAV\Reminder\ReminderService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\IConfig;
class EventReminderJob extends TimedJob {
public function __construct(
ITimeFactory $time,
private ReminderService $reminderService,
private IConfig $config,
) {
parent::__construct($time);
// Run every 5 minutes
$this->setInterval(5 * 60);
$this->setTimeSensitivity(self::TIME_SENSITIVE);
}
/**
* @throws ProviderNotAvailableException
* @throws NotificationTypeDoesNotExistException
* @throws NoUserException
*/
public function run($argument):void {
if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') {
return;
}
if ($this->config->getAppValue('dav', 'sendEventRemindersMode', 'backgroundjob') !== 'backgroundjob') {
return;
}
$this->reminderService->processReminders();
}
}