|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Thomas Citharel <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* @license AGPL-3.0 |
|
6
|
|
|
* |
|
7
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
8
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
9
|
|
|
* as published by the Free Software Foundation. |
|
10
|
|
|
* |
|
11
|
|
|
* This program is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
* GNU Affero General Public License for more details. |
|
15
|
|
|
* |
|
16
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
17
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
18
|
|
|
* |
|
19
|
|
|
*/ |
|
20
|
|
|
namespace OCA\DAV\BackgroundJob; |
|
21
|
|
|
|
|
22
|
|
|
use OC\BackgroundJob\TimedJob; |
|
23
|
|
|
use OCA\DAV\CalDAV\Reminder\ReminderService; |
|
24
|
|
|
use OCP\IConfig; |
|
25
|
|
|
|
|
26
|
|
|
class EventReminderJob extends TimedJob { |
|
27
|
|
|
|
|
28
|
|
|
/** @var ReminderService */ |
|
29
|
|
|
private $reminderService; |
|
30
|
|
|
|
|
31
|
|
|
/** @var IConfig */ |
|
32
|
|
|
private $config; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* EventReminderJob constructor. |
|
36
|
|
|
* |
|
37
|
|
|
* @param ReminderService $reminderService |
|
38
|
|
|
* @param IConfig $config |
|
39
|
|
|
*/ |
|
40
|
|
|
public function __construct(ReminderService $reminderService, IConfig $config) { |
|
41
|
|
|
$this->reminderService = $reminderService; |
|
42
|
|
|
$this->config = $config; |
|
43
|
|
|
/** Run every 5 minutes */ |
|
44
|
|
|
$this->setInterval(5); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param $arg |
|
49
|
|
|
* @throws \OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException |
|
50
|
|
|
* @throws \OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException |
|
51
|
|
|
* @throws \OC\User\NoUserException |
|
52
|
|
|
*/ |
|
53
|
|
|
public function run($arg):void { |
|
54
|
|
|
if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') { |
|
55
|
|
|
return; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
if ($this->config->getAppValue('dav', 'sendEventRemindersMode', 'backgroundjob') !== 'backgroundjob') { |
|
59
|
|
|
return; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
$this->reminderService->processReminders(); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|