EventReminderJob.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 OC\User\NoUserException;
  9. use OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException;
  10. use OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException;
  11. use OCA\DAV\CalDAV\Reminder\ReminderService;
  12. use OCP\AppFramework\Utility\ITimeFactory;
  13. use OCP\BackgroundJob\TimedJob;
  14. use OCP\IConfig;
  15. class EventReminderJob extends TimedJob {
  16. public function __construct(
  17. ITimeFactory $time,
  18. private ReminderService $reminderService,
  19. private IConfig $config,
  20. ) {
  21. parent::__construct($time);
  22. // Run every 5 minutes
  23. $this->setInterval(5 * 60);
  24. $this->setTimeSensitivity(self::TIME_SENSITIVE);
  25. }
  26. /**
  27. * @throws ProviderNotAvailableException
  28. * @throws NotificationTypeDoesNotExistException
  29. * @throws NoUserException
  30. */
  31. public function run($argument):void {
  32. if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') {
  33. return;
  34. }
  35. if ($this->config->getAppValue('dav', 'sendEventRemindersMode', 'backgroundjob') !== 'backgroundjob') {
  36. return;
  37. }
  38. $this->reminderService->processReminders();
  39. }
  40. }