diff --git a/lib/Backgroundjobs/Cleanup.php b/lib/Backgroundjobs/Cleanup.php index 1c70223eef..593cd7e3ab 100644 --- a/lib/Backgroundjobs/Cleanup.php +++ b/lib/Backgroundjobs/Cleanup.php @@ -7,17 +7,17 @@ namespace OCA\Richdocuments\Backgroundjobs; -use OCA\Richdocuments\Db\WopiMapper; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\TimedJob; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; class Cleanup extends TimedJob { + private const EXPIRY_GRACE_PERIOD_SECONDS = 60; + public function __construct( ITimeFactory $time, private IDBConnection $db, - private WopiMapper $wopiMapper, ) { parent::__construct($time); @@ -29,7 +29,7 @@ protected function run($argument) { // Expire template mappings for file creation $query = $this->db->getQueryBuilder(); $query->delete('richdocuments_template') - ->where($query->expr()->lte('timestamp', $query->createNamedParameter(time() - 60, IQueryBuilder::PARAM_INT))); + ->where($query->expr()->lte('timestamp', $query->createNamedParameter(time() - self::EXPIRY_GRACE_PERIOD_SECONDS, IQueryBuilder::PARAM_INT))); $query->executeStatement(); // Expired WOPI access tokens @@ -37,10 +37,9 @@ protected function run($argument) { } private function cleanUpWopiTokens() { - $tokenIds = $this->wopiMapper->getExpiredTokenIds(1000); $query = $this->db->getQueryBuilder(); $query->delete('richdocuments_wopi') - ->where($query->expr()->in('id', $query->createNamedParameter($tokenIds, IQueryBuilder::PARAM_INT_ARRAY))); + ->where($query->expr()->lt('expiry', $query->createNamedParameter(time() - self::EXPIRY_GRACE_PERIOD_SECONDS, IQueryBuilder::PARAM_INT))); $query->executeStatement(); } }