DeleteExpiredOpenLocalEditor.php 926 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Files\BackgroundJob;
  8. use OCA\Files\Db\OpenLocalEditorMapper;
  9. use OCP\AppFramework\Utility\ITimeFactory;
  10. use OCP\BackgroundJob\TimedJob;
  11. /**
  12. * Delete all expired "Open local editor" token
  13. */
  14. class DeleteExpiredOpenLocalEditor extends TimedJob {
  15. protected OpenLocalEditorMapper $mapper;
  16. public function __construct(
  17. ITimeFactory $time,
  18. OpenLocalEditorMapper $mapper
  19. ) {
  20. parent::__construct($time);
  21. $this->mapper = $mapper;
  22. // Run every 12h
  23. $this->interval = 12 * 3600;
  24. $this->setTimeSensitivity(self::TIME_INSENSITIVE);
  25. }
  26. /**
  27. * Makes the background job do its work
  28. *
  29. * @param array $argument unused argument
  30. */
  31. public function run($argument): void {
  32. $this->mapper->deleteExpiredTokens($this->time->getTime());
  33. }
  34. }