1
0

DeleteSchedulingObjects.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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(private IJobList $jobList,
  16. private ITimeFactory $time,
  17. private CalDavBackend $calDavBackend
  18. ) {
  19. }
  20. public function getName(): string {
  21. return 'Handle outdated scheduling events';
  22. }
  23. public function run(IOutput $output): void {
  24. $output->info('Cleaning up old scheduling events');
  25. $time = $this->time->getTime() - (60 * 60);
  26. $this->calDavBackend->deleteOutdatedSchedulingObjects($time, 50000);
  27. if (!$this->jobList->has(DeleteOutdatedSchedulingObjects::class, null)) {
  28. $output->info('Adding background job to delete old scheduling objects');
  29. $this->jobList->add(DeleteOutdatedSchedulingObjects::class, null);
  30. }
  31. }
  32. }