Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable3.6] Fix: generate event data fails for threads across multiple mailboxes #9563

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/Controller/ThreadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ public function generateEventData(int $id): JSONResponse {
$thread = $this->mailManager->getThread($account, $message->getThreadRootId());
$data = $this->aiIntergrationsService->generateEventData(
$account,
$mailbox,
$message->getThreadRootId(),
$thread,
$this->currentUserId,
Expand Down
5 changes: 3 additions & 2 deletions lib/Service/AiIntegrations/AiIntegrationsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function summarizeThread(Account $account, string $threadId, array $messa
/**
* @param Message[] $messages
*/
public function generateEventData(Account $account, Mailbox $mailbox, string $threadId, array $messages, string $currentUserId): ?EventData {
public function generateEventData(Account $account, string $threadId, array $messages, string $currentUserId): ?EventData {
try {
/** @var IManager $manager */
$manager = $this->container->get(IManager::class);
Expand All @@ -139,7 +139,8 @@ public function generateEventData(Account $account, Mailbox $mailbox, string $th
}
$client = $this->clientFactory->getClient($account);
try {
$messageBodies = array_map(function ($message) use ($client, $account, $mailbox) {
$messageBodies = array_map(function ($message) use ($client, $account, $currentUserId) {
$mailbox = $this->mailManager->getMailbox($currentUserId, $message->getMailboxId());
$imapMessage = $this->mailManager->getImapMessage(
$client,
$account,
Expand Down
12 changes: 4 additions & 8 deletions tests/Unit/Service/AiIntegrationsServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ public function testGenerateEventDataLlmUnavailable(): void {
}

$account = $this->createMock(Account::class);
$mailbox = new Mailbox();
$message1 = new Message();
$message2 = new Message();
$this->container->expects(self::once())
Expand All @@ -252,7 +251,6 @@ public function testGenerateEventDataLlmUnavailable(): void {

$result = $this->aiIntegrationsService->generateEventData(
$account,
$mailbox,
'thread1',
[$message1, $message2],
'user123',
Expand All @@ -267,7 +265,6 @@ public function testGenerateEventDataFreePromptUnavailable(): void {
}

$account = $this->createMock(Account::class);
$mailbox = new Mailbox();
$message1 = new Message();
$message2 = new Message();
$manager = $this->createMock(IManager::class);
Expand All @@ -280,7 +277,6 @@ public function testGenerateEventDataFreePromptUnavailable(): void {

$result = $this->aiIntegrationsService->generateEventData(
$account,
$mailbox,
'thread1',
[$message1, $message2],
'user123',
Expand All @@ -295,11 +291,12 @@ public function testGenerateEventDataInvalidJson(): void {
}

$account = $this->createMock(Account::class);
$mailbox = new Mailbox();
$message1 = new Message();
$message1->setUid(1);
$message1->setMailboxId(123);
$message2 = new Message();
$message2->setUid(2);
$message2->setMailboxId(456);
$manager = $this->createMock(IManager::class);
$this->container->expects(self::once())
->method('get')
Expand All @@ -320,7 +317,6 @@ public function testGenerateEventDataInvalidJson(): void {

$result = $this->aiIntegrationsService->generateEventData(
$account,
$mailbox,
'thread1',
[$message1, $message2],
'user123',
Expand All @@ -335,11 +331,12 @@ public function testGenerateEventData(): void {
}

$account = $this->createMock(Account::class);
$mailbox = new Mailbox();
$message1 = new Message();
$message1->setUid(1);
$message1->setMailboxId(123);
$message2 = new Message();
$message2->setUid(2);
$message2->setMailboxId(456);
$manager = $this->createMock(IManager::class);
$this->container->expects(self::once())
->method('get')
Expand All @@ -360,7 +357,6 @@ public function testGenerateEventData(): void {

$result = $this->aiIntegrationsService->generateEventData(
$account,
$mailbox,
'thread1',
[$message1, $message2],
'user123',
Expand Down
Loading