summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/BackgroundJob
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2019-05-23 11:10:48 +0200
committerGeorg Ehrke <developer@georgehrke.com>2019-05-23 11:24:32 +0200
commit7ec8e6d35b2e0cd2417456772eb2708132460ce7 (patch)
tree50274defe5c67264246b97bb7b13e1428595df1f /apps/dav/lib/BackgroundJob
parente38f55d78811f40b8b1350a0a3098e489703c735 (diff)
downloadnextcloud-server-7ec8e6d35b2e0cd2417456772eb2708132460ce7.tar.gz
nextcloud-server-7ec8e6d35b2e0cd2417456772eb2708132460ce7.zip
Don't run repair step for every individual user, outsource that to background job
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Diffstat (limited to 'apps/dav/lib/BackgroundJob')
-rw-r--r--apps/dav/lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php66
1 files changed, 66 insertions, 0 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