Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions lib/BackgroundJob/PreviewEnhancementProcessingJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\BackgroundJob\TimedJob;
use OCP\IConfig;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
use function max;
use function sprintf;

class PreviewEnhancementProcessingJob extends TimedJob {
private const DEFAULT_INTERVAL = 3600;
private const MIN_INTERVAL = 60;

private IUserManager $userManager;
private AccountService $accountService;
private LoggerInterface $logger;
Expand All @@ -30,7 +35,8 @@ public function __construct(ITimeFactory $time,
AccountService $accountService,
PreprocessingService $preprocessingService,
LoggerInterface $logger,
IJobList $jobList) {
IJobList $jobList,
IConfig $config) {
parent::__construct($time);

$this->userManager = $userManager;
Expand All @@ -39,7 +45,16 @@ public function __construct(ITimeFactory $time,
$this->jobList = $jobList;
$this->preprocessingService = $preprocessingService;

$this->setInterval(3600);
// Allow admins to tighten the interval on setups where preview data
// directly gates user-visible behaviour (e.g. the imip_message flag
// that IMipMessageJob depends on to turn incoming invitations into
// calendar events). A floor of MIN_INTERVAL keeps a misconfigured
// value from hammering the DB.
$configured = $config->getSystemValueInt(
'app.mail.preview-enhancement-interval',
self::DEFAULT_INTERVAL,
);
$this->setInterval(max(self::MIN_INTERVAL, $configured));
$this->setTimeSensitivity(self::TIME_SENSITIVE);
}

Expand Down
Loading