Skip to content

Commit

Permalink
fix(message-summary): respect admin config
Browse files Browse the repository at this point in the history
Signed-off-by: Hamza Mahjoubi <[email protected]>
  • Loading branch information
hamza221 committed Jan 27, 2025
1 parent 1c46bab commit 8b127ae
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/Listener/NewMessagesSummarizeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

namespace OCA\Mail\Listener;

use OCA\Mail\AppInfo\Application;
use OCA\Mail\Contracts\IMailManager;
use OCA\Mail\Events\NewMessagesSynchronized;
use OCA\Mail\Exception\ServiceException;
use OCA\Mail\IMAP\IMAPClientFactory;
use OCA\Mail\Service\AiIntegrations\AiIntegrationsService;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IConfig;
use Psr\Log\LoggerInterface;

/**
Expand All @@ -28,6 +30,7 @@ public function __construct(
private IMAPClientFactory $imapFactory,
private AiIntegrationsService $aiService,
private IMailManager $mailManager,
private IConfig $config,
) {
}

Expand All @@ -38,10 +41,12 @@ public function handle(Event $event): void {
}

try {
$this->aiService->summarizeMessages(
$event->getAccount(),
$event->getMessages(),
);
if ($this->config->getAppValue(Application::APP_ID, 'llm_processing', 'no') === 'yes') {
$this->aiService->summarizeMessages(
$event->getAccount(),
$event->getMessages(),
);

Check warning on line 48 in lib/Listener/NewMessagesSummarizeListener.php

View check run for this annotation

Codecov / codecov/patch

lib/Listener/NewMessagesSummarizeListener.php#L44-L48

Added lines #L44 - L48 were not covered by tests
}
} catch (ServiceException $e) {
$this->logger->error('Could not initiate a message summarize task(s): ' . $e->getMessage(), [
'exception' => $e,
Expand Down

0 comments on commit 8b127ae

Please sign in to comment.