DeleteExpiredOpenLocalEditor.php 867 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. public function __construct(
  16. ITimeFactory $time,
  17. protected OpenLocalEditorMapper $mapper,
  18. ) {
  19. parent::__construct($time);
  20. // Run every 12h
  21. $this->interval = 12 * 3600;
  22. $this->setTimeSensitivity(self::TIME_INSENSITIVE);
  23. }
  24. /**
  25. * Makes the background job do its work
  26. *
  27. * @param array $argument unused argument
  28. */
  29. public function run($argument): void {
  30. $this->mapper->deleteExpiredTokens($this->time->getTime());
  31. }
  32. }