EventReminderJob.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * @author Thomas Citharel <tcit@tcit.fr>
  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. use OC\BackgroundJob\TimedJob;
  22. use OCA\DAV\CalDAV\Reminder\ReminderService;
  23. use OCP\IConfig;
  24. class EventReminderJob extends TimedJob {
  25. /** @var ReminderService */
  26. private $reminderService;
  27. /** @var IConfig */
  28. private $config;
  29. /**
  30. * EventReminderJob constructor.
  31. *
  32. * @param ReminderService $reminderService
  33. * @param IConfig $config
  34. */
  35. public function __construct(ReminderService $reminderService, IConfig $config) {
  36. $this->reminderService = $reminderService;
  37. $this->config = $config;
  38. /** Run every 5 minutes */
  39. $this->setInterval(5);
  40. }
  41. /**
  42. * @param $arg
  43. * @throws \OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException
  44. * @throws \OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException
  45. * @throws \OC\User\NoUserException
  46. */
  47. public function run($arg):void {
  48. if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') {
  49. return;
  50. }
  51. if ($this->config->getAppValue('dav', 'sendEventRemindersMode', 'backgroundjob') !== 'backgroundjob') {
  52. return;
  53. }
  54. $this->reminderService->processReminders();
  55. }
  56. }