DeleteExpiredOpenLocalEditor.php 954 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\IJob;
  11. use OCP\BackgroundJob\TimedJob;
  12. /**
  13. * Delete all expired "Open local editor" token
  14. */
  15. class DeleteExpiredOpenLocalEditor extends TimedJob {
  16. protected OpenLocalEditorMapper $mapper;
  17. public function __construct(
  18. ITimeFactory $time,
  19. OpenLocalEditorMapper $mapper
  20. ) {
  21. parent::__construct($time);
  22. $this->mapper = $mapper;
  23. // Run every 12h
  24. $this->interval = 12 * 3600;
  25. $this->setTimeSensitivity(IJob::TIME_INSENSITIVE);
  26. }
  27. /**
  28. * Makes the background job do its work
  29. *
  30. * @param array $argument unused argument
  31. */
  32. public function run($argument): void {
  33. $this->mapper->deleteExpiredTokens($this->time->getTime());
  34. }
  35. }