CleanupInvitationTokenJob.php 833 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\BackgroundJob;
  8. use OCP\AppFramework\Utility\ITimeFactory;
  9. use OCP\BackgroundJob\TimedJob;
  10. use OCP\IDBConnection;
  11. class CleanupInvitationTokenJob extends TimedJob {
  12. public function __construct(
  13. private IDBConnection $db,
  14. ITimeFactory $time,
  15. ) {
  16. parent::__construct($time);
  17. // Run once a day at off-peak time
  18. $this->setInterval(24 * 60 * 60);
  19. $this->setTimeSensitivity(self::TIME_INSENSITIVE);
  20. }
  21. public function run($argument) {
  22. $query = $this->db->getQueryBuilder();
  23. $query->delete('calendar_invitations')
  24. ->where($query->expr()->lt('expiration',
  25. $query->createNamedParameter($this->time->getTime())))
  26. ->execute();
  27. }
  28. }