12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- declare(strict_types=1);
- namespace OC\Security\Bruteforce;
- use OCP\AppFramework\Utility\ITimeFactory;
- use OCP\BackgroundJob\TimedJob;
- use OCP\DB\QueryBuilder\IQueryBuilder;
- use OCP\IDBConnection;
- class CleanupJob extends TimedJob {
- public function __construct(
- ITimeFactory $time,
- private IDBConnection $connection,
- ) {
- parent::__construct($time);
-
- $this->setInterval(60 * 60 * 24);
- $this->setTimeSensitivity(self::TIME_INSENSITIVE);
- }
- protected function run($argument): void {
-
- $time = $this->time->getTime() - (48 * 3600);
- $qb = $this->connection->getQueryBuilder();
- $qb->delete('bruteforce_attempts')
- ->where($qb->expr()->lt('occurred', $qb->createNamedParameter($time), IQueryBuilder::PARAM_INT));
- $qb->executeStatement();
- }
- }
|