Skip to content

Commit 715ab9b

Browse files
committed
feat: ability to disable sync job by configuration
Signed-off-by: Roberto Guido <info@madbob.org>
1 parent 10b649b commit 715ab9b

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

lib/BackgroundJob/SyncJob.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class SyncJob extends TimedJob {
3232
private IUserManager $userManager;
3333
private IJobList $jobList;
3434
private readonly bool $forcedSyncInterval;
35+
private readonly bool $forcedSkip;
3536

3637
public function __construct(
3738
ITimeFactory $time,
@@ -51,7 +52,15 @@ public function __construct(
5152
$configuredSyncInterval = $config->getSystemValueInt('app.mail.background-sync-interval');
5253
if ($configuredSyncInterval > 0) {
5354
$this->forcedSyncInterval = true;
55+
$this->forcedSkip = false;
5456
} else {
57+
if ($configuredSyncInterval === -1) {
58+
$this->forcedSkip = true;
59+
}
60+
else {
61+
$this->forcedSkip = false;
62+
}
63+
5564
$this->forcedSyncInterval = false;
5665
$configuredSyncInterval = self::DEFAULT_SYNC_INTERVAL;
5766
}
@@ -65,6 +74,10 @@ public function __construct(
6574
*/
6675
#[\Override]
6776
protected function run($argument) {
77+
if ($this->forcedSkip) {
78+
return;
79+
}
80+
6881
$accountId = (int)$argument['accountId'];
6982

7083
try {

0 commit comments

Comments
 (0)