diff options
author | dartcafe <github@dartcafe.de> | 2019-12-27 10:37:27 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2019-12-27 10:37:27 +0300 |
commit | 600a3c4ca62e8150e9aa6105ed8bc7851765459c (patch) | |
tree | 7b916c80a4367450b36f33a71f9ad129e8c702e7 /lib/Cron | |
parent | 1b1ae6acb5bf4100dbc878cdff5bc0874286ffaf (diff) |
Notifications moved to cron
Diffstat (limited to 'lib/Cron')
-rw-r--r-- | lib/Cron/NotificationCron.php | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/Cron/NotificationCron.php b/lib/Cron/NotificationCron.php new file mode 100644 index 00000000..75f41cff --- /dev/null +++ b/lib/Cron/NotificationCron.php @@ -0,0 +1,65 @@ +<?php +/** + * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com> + * + * @author René Gieling <github@dartcafe.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Polls\Cron; + +use OCP\ILogger; +use OC\BackgroundJob\TimedJob; + +use OCA\Polls\Service\MailService; + +class NotificationCron extends TimedJob { + + /** @var MailService*/ + private $mailService; + private $logger; + + /** @param MailService $mailService + */ + public function __construct( + ILogger $logger, + MailService $mailService + ) { + $this->logger = $logger; + $this->setInterval(60); + $this->mailService = $mailService; + } + + /** + * getByToken + * Get pollId by token + * @NoAdminRequired + * @NoCSRFRequired + * @PublicPage + * @param string $token + * @return DataResponse + */ + protected function run($arguments) { + if ($this->mailService->sendNotifications()) { + $this->logger->debug('Notifications sent'); + } else { + $this->logger->alert('error while sending notifications'); + } + } + +} |