diff --git a/app/Domains/EmailParser/Client.php b/app/Domains/EmailParser/Client.php index ca83fcb1..5dec1507 100644 --- a/app/Domains/EmailParser/Client.php +++ b/app/Domains/EmailParser/Client.php @@ -85,7 +85,7 @@ public function handle(int $limit = 10): void } } - public function getEmails(string $slug , int $limit = 10): array + public function getEmails(string $slug, int $limit = 10): array { $mail = []; diff --git a/app/Domains/Sources/EmailSource.php b/app/Domains/Sources/EmailSource.php index e19eb626..a1d6515f 100644 --- a/app/Domains/Sources/EmailSource.php +++ b/app/Domains/Sources/EmailSource.php @@ -40,8 +40,9 @@ public function handle(Source $source): void $mailsComingIn = Client::getEmails($source->slug); $this->source = $this->checkForChat($source); - if(empty($mailsComingIn)) { - Log::info('No mails coming in Source ' . $source->id); + if (empty($mailsComingIn)) { + Log::info('No mails coming in Source '.$source->id); + return; } else { foreach ($mailsComingIn as $mailDto) { @@ -114,10 +115,5 @@ public function handle(Source $source): void } } - - - - - } } diff --git a/tests/Feature/EmailSourceTest.php b/tests/Feature/EmailSourceTest.php index 155afa3e..7177c9b7 100644 --- a/tests/Feature/EmailSourceTest.php +++ b/tests/Feature/EmailSourceTest.php @@ -122,7 +122,7 @@ public function test_uses_orchestrate() 'from' => 'foo@var.com', 'subject' => 'This is it', 'header' => 'This is header', - 'body' => "Test", + 'body' => 'Test', ]); Client::shouldReceive('getEmails')->once()->andReturn([ @@ -178,14 +178,13 @@ public function tests_creates_chat_and_message() 'from' => 'foo@var.com', 'subject' => 'This is it', 'header' => 'This is header', - 'body' => "Test", + 'body' => 'Test', ]); Client::shouldReceive('getEmails')->once()->andReturn([ $dto, ]); - LlmDriverFacade::shouldReceive('driver->setToolType->chat')->once()->andReturn( CompletionResponse::from([ 'content' => 'foo bar', @@ -236,14 +235,13 @@ public function test_repeat_tasks() 'from' => 'foo@var.com', 'subject' => 'This is it', 'header' => 'This is header', - 'body' => "Test", + 'body' => 'Test', ]); Client::shouldReceive('getEmails')->once()->andReturn([ $dto, ]); - LlmDriverFacade::shouldReceive('driver->setToolType->chat')->never(); $body = <<<'BODY' @@ -256,7 +254,6 @@ public function test_repeat_tasks() BODY; - SourceTask::factory()->create([ 'source_id' => $source->id, 'task_key' => md5($dto->getContent()), @@ -286,15 +283,13 @@ public function test_no_action_required() 'from' => 'foo@var.com', 'subject' => 'This is it', 'header' => 'This is header', - 'body' => "Test", + 'body' => 'Test', ]); Client::shouldReceive('getEmails')->once()->andReturn([ $dto, ]); - - LlmDriverFacade::shouldReceive('driver->setToolType->chat')->once()->andReturn( CompletionResponse::from([ 'content' => 'False',