From 4bbfde56c2ed15d885f0a8500c05ca215ecd86eb Mon Sep 17 00:00:00 2001 From: Wolfgang Lubowski Date: Wed, 22 Apr 2026 21:04:03 +0200 Subject: [PATCH] feat(preview-enhancement): make background-job interval configurable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PreviewEnhancementProcessingJob is what writes the `imip_message` flag onto mail_messages rows. Downstream, IMipMessageJob only picks up messages with that flag set, so the enhancement interval is the ceiling on how long an incoming calendar invitation can take to turn into a CalDAV event. The current hard-coded 3600s is reasonable for bulk-preview enrichment but way too slow for the iMIP pipeline: small Proton/Fastmail/self- hosted installs that want invitations to feel live need something in the 60–300s range. That's a per-setup trade-off (smaller sites have the headroom, larger ones probably do not), so let's expose the knob instead of picking one number. New system config: occ config:system:set app.mail.preview-enhancement-interval \ --value=300 --type=integer When unset, keeps the existing 3600s default. A MIN_INTERVAL=60s floor prevents a misconfigured value from hammering the DB. The job instance is re-created every time the scheduler enqueues it, so the new value takes effect on the next tick — no restart needed. Signed-off-by: Wolfgang Lubowski --- .../PreviewEnhancementProcessingJob.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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); }