diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2022-06-08 18:02:19 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2022-06-08 18:02:19 +0300 |
commit | 745504fbb63d9560b21e18e249e16891fe30f736 (patch) | |
tree | 0a0a1500c34a99e0f51820aa57bea8cfc1644b5b /lib/Command | |
parent | e3f17d93669619c0000645f18bfcbf6ee2f06925 (diff) |
Turn off background/cli classification training of opt-ed outfix/no-classification-no-training
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/Command')
-rw-r--r-- | lib/Command/TrainAccount.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Command/TrainAccount.php b/lib/Command/TrainAccount.php index 59000ec30..b6d80031d 100644 --- a/lib/Command/TrainAccount.php +++ b/lib/Command/TrainAccount.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace OCA\Mail\Command; +use OCA\Mail\Contracts\IUserPreferences; use OCA\Mail\Service\AccountService; use OCA\Mail\Service\Classification\ImportanceClassifier; use OCA\Mail\Support\ConsoleLoggerDecorator; @@ -45,17 +46,22 @@ class TrainAccount extends Command { /** @var ImportanceClassifier */ private $classifier; + /** @var IUserPreferences */ + private $preferences; + /** @var LoggerInterface */ private $logger; public function __construct(AccountService $service, ImportanceClassifier $classifier, + IUserPreferences $preferences, LoggerInterface $logger) { parent::__construct(); $this->accountService = $service; $this->classifier = $classifier; $this->logger = $logger; + $this->preferences = $preferences; } /** @@ -79,6 +85,11 @@ class TrainAccount extends Command { $output->writeln("<error>account $accountId does not exist</error>"); return 1; } + if ($this->preferences->getPreference($account->getUserId(), 'tag-classified-messages') === 'false') { + $output->writeln("<info>classification is turned off for account $accountId</info>"); + return 2; + } + $consoleLogger = new ConsoleLoggerDecorator( $this->logger, $output |