summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php66
-rw-r--r--apps/dav/lib/Migration/RegenerateBirthdayCalendars.php19
2 files changed, 69 insertions, 16 deletions
diff --git a/apps/dav/lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php b/apps/dav/lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php
new file mode 100644
index 00000000000..e20547053c5
--- /dev/null
+++ b/apps/dav/lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php
@@ -0,0 +1,66 @@
+<?php
+/**
+ * @copyright 2019 Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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\DAV\BackgroundJob;
+
+use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\BackgroundJob\IJobList;
+use OCP\BackgroundJob\QueuedJob;
+use OCP\IUser;
+use OCP\IUserManager;
+
+class RegisterRegenerateBirthdayCalendars extends QueuedJob {
+
+ /** @var IUserManager */
+ private $userManager;
+
+ /** @var IJobList */
+ private $jobList;
+
+ /**
+ * RegisterRegenerateBirthdayCalendars constructor.
+ *
+ * @param ITimeFactory $time
+ * @param IUserManager $userManager
+ * @param IJobList $jobList
+ */
+ public function __construct(ITimeFactory $time,
+ IUserManager $userManager,
+ IJobList $jobList) {
+ parent::__construct($time);
+ $this->userManager = $userManager;
+ $this->jobList = $jobList;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function run($argument) {
+ $this->userManager->callForSeenUsers(function(IUser $user) {
+ $this->jobList->add(GenerateBirthdayCalendarBackgroundJob::class, [
+ 'userId' => $user->getUID(),
+ 'purgeBeforeGenerating' => true
+ ]);
+ });
+ }
+
+} \ No newline at end of file
diff --git a/apps/dav/lib/Migration/RegenerateBirthdayCalendars.php b/apps/dav/lib/Migration/RegenerateBirthdayCalendars.php
index 263e6d00db4..492ae876e8a 100644
--- a/apps/dav/lib/Migration/RegenerateBirthdayCalendars.php
+++ b/apps/dav/lib/Migration/RegenerateBirthdayCalendars.php
@@ -22,19 +22,14 @@
*/
namespace OCA\DAV\Migration;
-use OCA\DAV\BackgroundJob\GenerateBirthdayCalendarBackgroundJob;
+use OCA\DAV\BackgroundJob\RegisterRegenerateBirthdayCalendars;
use OCP\BackgroundJob\IJobList;
use OCP\IConfig;
-use OCP\IUser;
-use OCP\IUserManager;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
class RegenerateBirthdayCalendars implements IRepairStep {
- /** @var IUserManager */
- private $userManager;
-
/** @var IJobList */
private $jobList;
@@ -42,14 +37,11 @@ class RegenerateBirthdayCalendars implements IRepairStep {
private $config;
/**
- * @param IUserManager $userManager,
* @param IJobList $jobList
* @param IConfig $config
*/
- public function __construct(IUserManager $userManager,
- IJobList $jobList,
+ public function __construct(IJobList $jobList,
IConfig $config) {
- $this->userManager = $userManager;
$this->jobList = $jobList;
$this->config = $config;
}
@@ -72,12 +64,7 @@ class RegenerateBirthdayCalendars implements IRepairStep {
}
$output->info('Adding background jobs to regenerate birthday calendar');
- $this->userManager->callForSeenUsers(function(IUser $user) {
- $this->jobList->add(GenerateBirthdayCalendarBackgroundJob::class, [
- 'userId' => $user->getUID(),
- 'purgeBeforeGenerating' => true
- ]);
- });
+ $this->jobList->add(RegisterRegenerateBirthdayCalendars::class);
// if all were done, no need to redo the repair during next upgrade
$this->config->setAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix', 'yes');