2020-01-23 03:05:45 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
/**
|
2024-05-27 11:39:07 -04:00
|
|
|
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2020-01-23 03:05:45 -05:00
|
|
|
*/
|
|
|
|
|
namespace OCA\ContactsInteraction\BackgroundJob;
|
|
|
|
|
|
|
|
|
|
use OCA\ContactsInteraction\Db\RecentContactMapper;
|
|
|
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
|
|
|
|
use OCP\BackgroundJob\TimedJob;
|
|
|
|
|
|
|
|
|
|
class CleanupJob extends TimedJob {
|
|
|
|
|
|
2023-07-08 12:56:32 -04:00
|
|
|
public function __construct(
|
|
|
|
|
ITimeFactory $time,
|
|
|
|
|
private RecentContactMapper $mapper,
|
|
|
|
|
) {
|
2020-01-23 03:05:45 -05:00
|
|
|
parent::__construct($time);
|
|
|
|
|
|
2022-01-31 15:23:07 -05:00
|
|
|
$this->setInterval(24 * 60 * 60);
|
2024-10-07 11:36:55 -04:00
|
|
|
$this->setTimeSensitivity(self::TIME_INSENSITIVE);
|
2020-01-23 03:05:45 -05:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-16 08:27:15 -04:00
|
|
|
protected function run(mixed $argument): void {
|
2020-01-23 03:05:45 -05:00
|
|
|
$time = $this->time->getDateTime();
|
|
|
|
|
$time->modify('-7days');
|
|
|
|
|
$this->mapper->cleanUp($time->getTimestamp());
|
|
|
|
|
}
|
|
|
|
|
}
|