0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-03-15 16:55:23 +00:00
nextcloud_server/apps/files_reminders/lib/BackgroundJob/ScheduledNotifications.php
Andy Scherzinger 8d8891c5bc
chore: Add SPDX header
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
2024-05-30 15:49:33 +02:00

42 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\FilesReminders\BackgroundJob;
use OCA\FilesReminders\Db\ReminderMapper;
use OCA\FilesReminders\Service\ReminderService;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\Job;
use Psr\Log\LoggerInterface;
class ScheduledNotifications extends Job {
public function __construct(
ITimeFactory $time,
protected ReminderMapper $reminderMapper,
protected ReminderService $reminderService,
protected LoggerInterface $logger,
) {
parent::__construct($time);
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function run($argument) {
$reminders = $this->reminderMapper->findOverdue();
foreach ($reminders as $reminder) {
try {
$this->reminderService->send($reminder);
} catch (DoesNotExistException $e) {
$this->logger->debug('Could not send notification for reminder with id ' . $reminder->getId());
}
}
}
}