Skip to content

Commit

Permalink
feat: Allow a configurable background sync interval
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst committed Jun 7, 2023
1 parent 3e276f5 commit 89e009e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions doc/admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ Depending on your mail host, it may be necessary to increase your IMAP and/or SM
'app.mail.sieve.timeout' => 2
```

### Background sync interval

Configure how often Mail keeps users' mailboxes updated in the background in seconds. Defaults to 3600.

```php
'app.mail.background-sync-interval' => 7200,
```

### Use php-mail for sending mail
You can use the php-mail function to send mails. This is needed for some webhosters (1&1 (1und1)):
```php
Expand Down
12 changes: 10 additions & 2 deletions lib/BackgroundJob/SyncJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\BackgroundJob\TimedJob;
use OCP\IConfig;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
use Throwable;
use function max;
use function sprintf;

class SyncJob extends TimedJob {
Expand All @@ -54,7 +56,8 @@ public function __construct(ITimeFactory $time,
MailboxSync $mailboxSync,
ImapToDbSynchronizer $syncService,
LoggerInterface $logger,
IJobList $jobList) {
IJobList $jobList,
IConfig $config) {
parent::__construct($time);

$this->userManager = $userManager;
Expand All @@ -64,7 +67,12 @@ public function __construct(ITimeFactory $time,
$this->logger = $logger;
$this->jobList = $jobList;

$this->setInterval(3600);
$this->setInterval(
max(
5 * 60,
$config->getSystemValueInt('app.mail.background-sync-interval', 3600)
),
);
$this->setTimeSensitivity(self::TIME_SENSITIVE);
}

Expand Down

0 comments on commit 89e009e

Please sign in to comment.