DeleteSchedulingObjects.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\Migration;
  8. use OCA\DAV\BackgroundJob\DeleteOutdatedSchedulingObjects;
  9. use OCA\DAV\CalDAV\CalDavBackend;
  10. use OCP\AppFramework\Utility\ITimeFactory;
  11. use OCP\BackgroundJob\IJobList;
  12. use OCP\Migration\IOutput;
  13. use OCP\Migration\IRepairStep;
  14. class DeleteSchedulingObjects implements IRepairStep {
  15. public function __construct(
  16. private IJobList $jobList,
  17. private ITimeFactory $time,
  18. private CalDavBackend $calDavBackend,
  19. ) {
  20. }
  21. public function getName(): string {
  22. return 'Handle outdated scheduling events';
  23. }
  24. public function run(IOutput $output): void {
  25. $output->info('Cleaning up old scheduling events');
  26. $time = $this->time->getTime() - (60 * 60);
  27. $this->calDavBackend->deleteOutdatedSchedulingObjects($time, 50000);
  28. if (!$this->jobList->has(DeleteOutdatedSchedulingObjects::class, null)) {
  29. $output->info('Adding background job to delete old scheduling objects');
  30. $this->jobList->add(DeleteOutdatedSchedulingObjects::class, null);
  31. }
  32. }
  33. }