1
0

EventReminderJob.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\BackgroundJob;
  8. use OCA\DAV\CalDAV\Reminder\ReminderService;
  9. use OCP\AppFramework\Utility\ITimeFactory;
  10. use OCP\BackgroundJob\TimedJob;
  11. use OCP\IConfig;
  12. class EventReminderJob extends TimedJob {
  13. /** @var ReminderService */
  14. private $reminderService;
  15. /** @var IConfig */
  16. private $config;
  17. public function __construct(ITimeFactory $time,
  18. ReminderService $reminderService,
  19. IConfig $config) {
  20. parent::__construct($time);
  21. $this->reminderService = $reminderService;
  22. $this->config = $config;
  23. // Run every 5 minutes
  24. $this->setInterval(5 * 60);
  25. $this->setTimeSensitivity(self::TIME_SENSITIVE);
  26. }
  27. /**
  28. * @throws \OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException
  29. * @throws \OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException
  30. * @throws \OC\User\NoUserException
  31. */
  32. public function run($argument):void {
  33. if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') {
  34. return;
  35. }
  36. if ($this->config->getAppValue('dav', 'sendEventRemindersMode', 'backgroundjob') !== 'backgroundjob') {
  37. return;
  38. }
  39. $this->reminderService->processReminders();
  40. }
  41. }