Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2021-06-04 14:08:13 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-06-04 14:08:13 +0300
commite451ad6781fad09729f6cd0f06f24a750871b94e (patch)
treef572dbca5beda0676e89c442350b1243d47900dc /lib/BackgroundJob
parentddbe05b1c36b55b16bef8ad20097de52621848a2 (diff)
Do not run background syncs for disabled users
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/BackgroundJob')
-rw-r--r--lib/BackgroundJob/SyncJob.php19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/BackgroundJob/SyncJob.php b/lib/BackgroundJob/SyncJob.php
index b74e47c14..077d86339 100644
--- a/lib/BackgroundJob/SyncJob.php
+++ b/lib/BackgroundJob/SyncJob.php
@@ -33,11 +33,16 @@ use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\BackgroundJob\TimedJob;
+use OCP\IUserManager;
use Psr\Log\LoggerInterface;
use Throwable;
+use function sprintf;
class SyncJob extends TimedJob {
+ /** @var IUserManager */
+ private $userManager;
+
/** @var AccountService */
private $accountService;
@@ -54,6 +59,7 @@ class SyncJob extends TimedJob {
private $jobList;
public function __construct(ITimeFactory $time,
+ IUserManager $userManager,
AccountService $accountService,
MailboxSync $mailboxSync,
ImapToDbSynchronizer $syncService,
@@ -61,13 +67,14 @@ class SyncJob extends TimedJob {
IJobList $jobList) {
parent::__construct($time);
+ $this->userManager = $userManager;
$this->accountService = $accountService;
$this->syncService = $syncService;
$this->mailboxSync = $mailboxSync;
$this->logger = $logger;
+ $this->jobList = $jobList;
$this->setInterval(3600);
- $this->jobList = $jobList;
}
protected function run($argument) {
@@ -81,6 +88,16 @@ class SyncJob extends TimedJob {
return;
}
+ $user = $this->userManager->get($account->getUserId());
+ if ($user === null || !$user->isEnabled()) {
+ $this->logger->debug(sprintf(
+ 'Account %d of user %s could not be found or was disabled, skipping background sync',
+ $account->getId(),
+ $account->getUserId()
+ ));
+ return;
+ }
+
$dbAccount = $account->getMailAccount();
if (!is_null($dbAccount->getProvisioningId()) && $dbAccount->getInboundPassword() === null) {
$this->logger->info("Ignoring cron sync for provisioned account that has no password set yet");