Skip to content

Commit 2432e92

Browse files
lubo92Wolfgang Lubowski
authored andcommitted
feat(preview-enhancement): make background-job interval configurable
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. AI-assisted: Claude Code (Claude Opus 4.7) Signed-off-by: Wolfgang Lubowski <w.lub92@gmail.com>
1 parent de964d8 commit 2432e92

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

lib/BackgroundJob/PreviewEnhancementProcessingJob.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@
1414
use OCP\AppFramework\Utility\ITimeFactory;
1515
use OCP\BackgroundJob\IJobList;
1616
use OCP\BackgroundJob\TimedJob;
17+
use OCP\IConfig;
1718
use OCP\IUserManager;
1819
use Psr\Log\LoggerInterface;
20+
use function max;
1921
use function sprintf;
2022

2123
class PreviewEnhancementProcessingJob extends TimedJob {
24+
private const DEFAULT_INTERVAL = 3600;
25+
private const MIN_INTERVAL = 60;
26+
2227
private IUserManager $userManager;
2328
private AccountService $accountService;
2429
private LoggerInterface $logger;
@@ -30,7 +35,8 @@ public function __construct(ITimeFactory $time,
3035
AccountService $accountService,
3136
PreprocessingService $preprocessingService,
3237
LoggerInterface $logger,
33-
IJobList $jobList) {
38+
IJobList $jobList,
39+
IConfig $config) {
3440
parent::__construct($time);
3541

3642
$this->userManager = $userManager;
@@ -39,7 +45,16 @@ public function __construct(ITimeFactory $time,
3945
$this->jobList = $jobList;
4046
$this->preprocessingService = $preprocessingService;
4147

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

0 commit comments

Comments
 (0)