2019-03-16 15:19:25 +00:00
|
|
|
<?php
|
2022-02-22 10:24:38 +00:00
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-03-16 15:19:25 +00:00
|
|
|
/**
|
2024-05-27 15:39:07 +00:00
|
|
|
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2019-03-16 15:19:25 +00:00
|
|
|
*/
|
|
|
|
namespace OCA\DAV\BackgroundJob;
|
|
|
|
|
|
|
|
use OCA\DAV\CalDAV\Reminder\ReminderService;
|
2022-02-22 10:24:38 +00:00
|
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
|
|
|
use OCP\BackgroundJob\TimedJob;
|
2019-03-16 15:19:25 +00:00
|
|
|
use OCP\IConfig;
|
|
|
|
|
|
|
|
class EventReminderJob extends TimedJob {
|
|
|
|
|
|
|
|
/** @var ReminderService */
|
|
|
|
private $reminderService;
|
|
|
|
|
|
|
|
/** @var IConfig */
|
|
|
|
private $config;
|
|
|
|
|
2022-02-22 10:24:38 +00:00
|
|
|
public function __construct(ITimeFactory $time,
|
2023-11-23 09:22:34 +00:00
|
|
|
ReminderService $reminderService,
|
|
|
|
IConfig $config) {
|
2022-02-22 10:24:38 +00:00
|
|
|
parent::__construct($time);
|
2019-03-16 15:19:25 +00:00
|
|
|
$this->reminderService = $reminderService;
|
|
|
|
$this->config = $config;
|
2022-02-22 10:24:38 +00:00
|
|
|
|
|
|
|
// Run every 5 minutes
|
|
|
|
$this->setInterval(5 * 60);
|
|
|
|
$this->setTimeSensitivity(self::TIME_SENSITIVE);
|
2019-03-16 15:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws \OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException
|
|
|
|
* @throws \OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException
|
|
|
|
* @throws \OC\User\NoUserException
|
|
|
|
*/
|
2022-05-05 22:01:08 +00:00
|
|
|
public function run($argument):void {
|
2019-08-02 14:26:51 +00:00
|
|
|
if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') {
|
|
|
|
return;
|
2019-03-16 15:19:25 +00:00
|
|
|
}
|
2019-08-02 14:26:51 +00:00
|
|
|
|
|
|
|
if ($this->config->getAppValue('dav', 'sendEventRemindersMode', 'backgroundjob') !== 'backgroundjob') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->reminderService->processReminders();
|
2019-03-16 15:19:25 +00:00
|
|
|
}
|
|
|
|
}
|