diff --git a/lib/BackgroundJob/PreviewEnhancementProcessingJob.php b/lib/BackgroundJob/PreviewEnhancementProcessingJob.php index d5a60d6b95..ad685413be 100644 --- a/lib/BackgroundJob/PreviewEnhancementProcessingJob.php +++ b/lib/BackgroundJob/PreviewEnhancementProcessingJob.php @@ -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; @@ -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; @@ -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); }