|
81517
|
2829
|
15
|
2026-05-28T08:22:35.024695+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956555024_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentFallsBackToToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertTrue($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"15","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.009640957,"height":0.0},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"64","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.010305851,"height":0.0},"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.00731383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.006981383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentFallsBackToToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentFallsBackToToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"10","depth":4,"bounds":{"left":0.72772604,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7390292,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7463431,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","depth":4,"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-8973480723064585544
|
-2007281816540925037
|
idle
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentFallsBackToToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertTrue($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
81515
|
NULL
|
NULL
|
NULL
|
|
81516
|
2828
|
12
|
2026-05-28T08:22:12.444523+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956532444_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-7228688528716742632
|
2609222811515291121
|
idle
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
iTerm2Shell EditViewSessionScriptsProfilesWindowHelp‹$0100% <7-zshscreenpipe"DOCKERO ₴1DEV (docker)₴2-zshjiminny-worker-processing-5:jiminny-worker-processing-5_00: stoppedworker-analytics:worker-analytics_00: stoppedworker-nudges:worker-nudges_00: stoppedworker-calendar:worker-calendar_00: stoppedworker-crm-sync:worker-crm-sync_00: stoppedworker-es-update:worker-es-update_00:stoppedjiminny-worker-processing-1:jiminny-worker-processing-1_00: stoppedworker-emails:worker-emails_00: stoppedworker-audio:worker-audio_00: stoppedworker:worker_00: stoppedworker-conferences:worker-conferences_00: stoppedartisan-schedule:artisan-schedule_00:stoppedartisan-schedule:artisan-schedule_00: startedjiminny-worker-processing-1:jiminny-worker-processing-1_00: startedjiminny-worker-processing-2:jiminny-worker-processing-2_00: startedjiminny-worker-processing-3:jiminny-worker-processing-3_00: startedjiminny-worker-processing-4:jiminny-worker-processing-4_00: startedjiminny-worker-processing-5:jiminny-worker-processing-5_00: startedjiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: startedworker:worker_00: startedworker-analytics:worker-analytics_00: startedworker-audio:worker-audio_00: startedworker-calendar:worker-calendar_00: startedworker-conferences:worker-conferences_00: startedworker-crm-sync:worker-crm-sync_00: startedworker-crm-update:worker-crm-update_00: startedworker-download:worker-download_00: startedworker-emails:worker-emails_00: startedworker-es-update:worker-es-update_00: startedworker-nudges:worker-nudges_00: startedH3O ₴4-zshWhat's next:Try Docker Debug for seamless, persistent debugging tools in anycontainerorimage + docker debug docker_lamp_1Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $D*5ec2-user@ip-10-30-1...• ÷68• Thu 28 May 11:22:11T81ec2-user@ip-10-30-140-...$7...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81515
|
2829
|
14
|
2026-05-28T08:22:02.908091+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956522908_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
7923424182753190895
|
-8780372176425246254
|
visual_change
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
rapstomCoocFV faVsco.s ~$ JY-20915-fix-missproidet© ServiceTest.php© SyncBatchRedisServiceRaseSercetest oho© CachedCrmServiceDecora© CrmActivityServiceTest.ptc CrmConfigurationSettingsCrmObiectsResolverTest.rDefaultProspectSearchStEmailHelperTest.pho© FieldValueConverterTest.g© LayoutManagerTest.phdC MigrateProviderServiceTe© OpportunityActivityMatchie opportuniysyncstratcoy© ProspectCacheTest.phoc Prosoccsearchstratcoytc ProviderReoistviestohoc Recordseleclortestonoc) ResoivecomoanyNamesvle ttimepenodtertontortocUocareeimon acors werdlntemnaV KosvuromatedceooreCACMMiMneSorooteCack mionuteowrromC AskJiminnyReportServiAutomatedPanorsoah© AutomatedReportsSenAutomatedPadotteSen© AutomatedReportsSenv© AutomatedReportsSen© AutomatedReportsSen© AutomatedReportsSenAutomatedReportsSenv 15c€AntomntedteoortsenC RecicientServiceTest.o 15v (D Mai>DActions•- Otricel•- Resoivers>Dtraits• - Validators© BatchServiceTest.php©EmailActivityServiceTest.rC inboxServiceTest.phpwTeytralavsem.celtest.600mIilMeet ne caneratorIhlwotineatiorDockerfileTextRelayServiceTest.php xfyyminny.ohgJse waunhy ocrvaces nözt lextkeldyoervzeeJse Phrunzt rranework aecizuuces coversulass?use Purunze rranework Accrzoures Uacarrovzderuse lests lesccasesuse kettectzonctassuse hockery.=coverscrasstexRelayserv.ce:.classclass Tex ReLayservacerest excends Testease.Zusagesoublac starc tuncison envi ronmentProv deror arrav aa.nrorectedunction serino wosdnrorecteduncion Teartowidr wosd"iharaprousderenus conment?rousden"public function testIsForCurrentEnvironnentlithMatchingX6n0riginalToHeader(string SdeployRegion,string SexpectedAlias,string sreceprene•: void 1..u#DataProvider"environmentProvider'pooere tuncczon cesclsrorcurrent.nv.ronnen:.wontsrchinox6nonso.mml Tokondenstring SdeployRegionCiino SexoeercoAtrowiino oreczoen): void (..JHpublic function testIsForCurrentEnvironnentLogsRefusedMessageO: void...,public function testisForCurrentEnvironment/gnoresToHeader: voidoubilic function testisFordurrentEnwironnentFal1<BackToToHeaderO= voidconfig::set("J1minny.google_text_host. "txt.J1minny.com"):SmessadeSthiisoscreateMack Ghast Mescade..cllasg)Spayload = Sthis->createMock(MessagePart::class) :Sheaden= SthisoscreateMockMessadePartHeaden.ecllasc)Sheaden-sualue = catchoallOtyt.ssnhnav.comteSpayload->nethod("getHeaders')->willReturn( SheaderSmessage->nethodCgetPayload') ->willReturn(Spayload):SusersMessages = Sthis->createMockGoogle Service\6mail \Resource UsersMessages::class):= custom.log Xlaravel.logSF (iminny@localhost)HS.Jocal jiminny(blocalhost)& console [PROD# consoke leu.console STAcinG(startHistoryId] => 359929correlazon1d: 0095/14/-t328-4017-8a55-961cocca1200race10: 34062130-3912-45ct-95cc-0528268C2t0S-17826-85-78 88:88:54 Locau.AWFU: SnessaachzscoryArna32858correlation.1d:0a95/17-7378-4047-8055-961c8ccalz8ctrace.10:[CREDIT_CARD]-9566-0528268C2405417876-85078 88:852 omuetsts SoaraneARNayh story iwnesi messane.ddedctartHistorydil50:74conneatsonr"asonce toe salugeocedeiihalounoace ae y ooctchaioeusacahhe.Thescoadtcde"12826-85-28 R8-05:201l TocolTwEn: Snessadels stomArray"correlation_id":"c5339dcc-46C1-45a4-81f9-ede8283ab266*,*trace_1d":"627196cf-0a89-465a-ab3e-10e546adfcde")(2826-85-28 88:10:44) local.INFO: SparansArrayhistoryTypes => messageAddecistartHistoryId) => 359929"correlation_id":"86677130-79c8-46a6-bSa4-b13351d287da*,*trace_id":"52cc740a-b685-4b96-abda-8eSab1057ca6"}(2826-85-28 88:10:441 Zocal.INF0: SmessageHistoryOtXeNHeNMStMiCTnodgnttor 1sResdTextRelayScrvico est.oho #L154-188Thought for 1seexKeayeMicesthontDiving"correlation_id":"8667713e-79c8-46a6-bSa4-b13351d287da*, *trace_id*:*S2ec748a-b685-4b96-abda-8eSab1957ea6**12826-85-28 88:15:301 Zocal,INF0: SoaransArravmistorvnvoes => nessagenddecstartHistoryd 8> 359823fconnelation fa"."47777621-4h8e-4703-022d-600ad05cehhe* etoace 3a*.=11h38545-5665-483e-92c2-/88eh7e15ed6)ieihwRheeSetiocTsi Shaccadelstonyconnallatton"*"ctrhhh.-nna-woX-002decaaadoscanhaeconea/etthhasnsesthchxn-82c2./.Rahtcs5erxuAsk anything (Xol@ Code swioTh• Thu 28 May 11:22:02TextRelayServiceTesttix @TextRelayServiceTest.php+2-2AReinctalAcceot allKwindeurlahmehiehensd....
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81513
|
2829
|
13
|
2026-05-28T08:21:41.417349+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956501417_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"15","depth":4,"bounds":{"left":0.37333778,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"64","depth":4,"bounds":{"left":0.3849734,"top":0.10055866,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39694148,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.40425533,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-8529342139328146916
|
-6616856774859115597
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification...
|
81512
|
NULL
|
NULL
|
NULL
|
|
81512
|
2829
|
12
|
2026-05-28T08:21:40.662858+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956500662_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"15","depth":4,"bounds":{"left":0.37333778,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"64","depth":4,"bounds":{"left":0.3849734,"top":0.10055866,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39694148,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.40425533,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-922306399186927406
|
-2005030018943372365
|
typing_pause
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81514
|
2828
|
11
|
2026-05-28T08:21:40.554768+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956500554_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-4528724110787610736
|
2604719229101344208
|
typing_pause
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
iTerm2Shell EditViewSessionScriptsProfilesWindowHelp‹$0100% <7-zshscreenpipe"DOCKERO ₴1DEV (docker)₴2-zshjiminny-worker-processing-5:jiminny-worker-processing-5_00: stoppedworker-analytics:worker-analytics_00: stoppedworker-nudges:worker-nudges_00: stoppedworker-calendar:worker-calendar_00: stoppedworker-crm-sync:worker-crm-sync_00: stoppedworker-es-update:worker-es-update_00:stoppedjiminny-worker-processing-1:jiminny-worker-processing-1_00: stoppedworker-emails:worker-emails_00: stoppedworker-audio:worker-audio_00: stoppedworker:worker_00: stoppedworker-conferences:worker-conferences_00: stoppedartisan-schedule:artisan-schedule_00:stoppedartisan-schedule:artisan-schedule_00: startedjiminny-worker-processing-1:jiminny-worker-processing-1_00: startedjiminny-worker-processing-2:jiminny-worker-processing-2_00: startedjiminny-worker-processing-3:jiminny-worker-processing-3_00: startedjiminny-worker-processing-4:jiminny-worker-processing-4_00: startedjiminny-worker-processing-5:jiminny-worker-processing-5_00: startedjiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: startedworker:worker_00: startedworker-analytics:worker-analytics_00: startedworker-audio:worker-audio_00: startedworker-calendar:worker-calendar_00: startedworker-conferences:worker-conferences_00: startedworker-crm-sync:worker-crm-sync_00: startedworker-crm-update:worker-crm-update_00: startedworker-download:worker-download_00: startedworker-emails:worker-emails_00: startedworker-es-update:worker-es-update_00: startedworker-nudges:worker-nudges_00: startedH3O ₴4-zshWhat's next:Try Docker Debug for seamless, persistent debugging tools in anycontainerorimage + docker debug docker_lamp_1Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $D*5ec2-user@ip-10-30-1...О ₴68• Thu 28 May 11:21:40T81ec2-user@ip-10-30-140-...$7...
|
81510
|
NULL
|
NULL
|
NULL
|
|
81510
|
2828
|
10
|
2026-05-28T08:21:34.155580+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956494155_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"15","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"64","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"10","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","depth":4,"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-3309000170050992813
|
-2007281816540925037
|
typing_pause
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81511
|
2829
|
11
|
2026-05-28T08:21:32.617439+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956492617_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
6445247769588009110
|
-6618793407836651056
|
typing_pause
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
rapstomViewCoocWindowFV faVsco.|s ~$ JY-20915-fix-missProinet v© SyncMailbox.phpmockhrhts© ServiceTest.php© SyncBatchRedisServiceRaseSercetest oho© CachedCrmServiceDecora© CrmActivityServiceTest.ptc CrmConfigurationSettingsCrmObiectsResolverTest.rDefaultProspectSearchStEmailHelperTest.pho© FieldValueConverterTest.gLayoutManagertest.prpC MigrateProviderServiceTe© OpportunityActivityMatchiTextRelsyServiceTest.php x php fiminny.php3.env.productionuse wanhy ocrvaces nözt textkelayseryzeeuse thrunzt rranework aecizuutes coversulassuse Purunze rranework Accrzbures uacarrovzderuse Tests esccaseruse kertectzonctassuse hockery.=coversclassdexRelayserv.ce:.classclass Tex ReLayservacetest excends Testcasac Opportuniysyncstratcoyt© ProspectCacheTest.phoc Prosoccsearchstratcoytc ProviderReoistviestohoc Recordseleclortestono© ResolveCompanyNameByle ttimepenodtertontortocUocareeiman acors werdlntemnav KioskvuromatedceooreCACMMiMneSorooteCackminnucerr.oC AskJiminnyReportServiAutomatedPanorsoah© AutomatedReportsSenAutomatedPadotteSen© AutomatedReportsSenv© AutomatedReportsSenv© AutomatedReportsSen© AutomatedReportsSen© AutomatedReportsSen© AutomatedReportsSenAutomatedReportsSenAutomatedReportsSenC RecicientServiceTest.o184 €216 ₽wiswa>bActions248 ₽Zusagesoubldc starc tuncison envi ronmentProv deror arrav annrorecteduncion sernor wosd.protected function tearbowng: voidt...#baraprousderenusconmenr?rowsden"nubibie functiion testisForfucrentFnwscoonentttMatchsnoY6n0r.osnalToHeaderdstring SdeployRegion,string SexpectedAlias,string Srecipient•: void 1..unataProusden enusconcontProusdentpuoere tuncczon cesclsrorcurrentanv.ronnen:.Nonksrchsingx6non..o.oml.Tokondenstring SdeployRegiontiino SexocercoRtrowiiino oreczorenD: void 4..Hpublic function testIsForCurrentEnvironnentLoqsRefusedMessageO: void...,oublic function testisForCurrentEnvironnent/gnoresToHeaderO: voidi...;public functiion testisFor@urrentEnvironnent@ithEnotyHeadersO= voidf...,oublic functiion testisFor@urrentEnvironnent@ithSxceptzionO= voidf...oublic functsion testisFor@urrentEnvironnentRefectsllrongHostWithMatchingPlusTaqO: voidi...>E Otrice> &a Resolvers>traitspublic function testSyncUsesEuALiasForEuRegion(): void{...}• - Validatorsmuaide sunetion testsunciisasis.acsonlcreosoodt wosora© BatchServiceTest.php@ EmailActivitvServiceTest© InboxServiceTest.phpo Teytcalavsemceltes60dpublic function testSyncwithEnhancedLoggingO: voidi...TAAGpublic function testSyncWithRefusedMessageLogs: voidk....IilMeet ne caneratorM Notificationpublic function testGetHistoryLogsError0nException: voidk..araveliosSF (iminny@localhost)HS.Jocal jiminny@blocalhost)& console [PROD# console EuTconsole STAcinG(startHistoryId] => 359929correlatzon10: 0045/14/-t328-4017-8355-967c0cca1z00race-10: 34082136-3912-450t-95cc-0528268C2t0S-7826-85-28 88:88:54 Local.WFU: Snessagchzscomycorrelation.1d:0av5y74-7378-4017-8055-96c8ccalxoctrace-10:[CREDIT_CARD]-95c6-052826862T05-317876-85078 88:852 omuetsts Soaranelh story wnesi messado.ddedctartHistorydil50:741'correlation_1d:"C5339dcc-46c1-45a4-81f9-ede8285ab266, trace_10: 627196cf-0a89-465a-ab3e-18e546adfcde"}12826-85-28 R8-05:201l TocolTwEn: Snessadels stomArray{"correlation_id":"c5339dcc-46C1-45a4-81f9-ede8283ab266*, "trace_1d":"627196cf-0a09-465a-ab3e-10e546adfcde*)(2826-85-28 88:10:44) local.INFO: SparansArrayhistoryTypes => messageAddecistartHistoryId) => 359929"correlation_id":"86677130-79c8-46a6-bSa4-b13351d287da*,*trace_id":"52cc740a-b685-4b96-abda-8eSab1057ca6"}12826-85-28 88:10:44] Zocal.INF0: SmessageHistoryArratce10:S2ec//48a-0685-4096-a0da-8e5ab85yeao17826-85328 88-157381 ocaunuFl: Soaransmistorvnvoes => nessagenddecstartHistoryd 8> 359823fconnelation fa"."47777621-4h8e-4703-022d-600ad05cehhe* etoace 3a*.-11h38545-5665-483e-92c2-/88eb7c15ed6*})ierhoReeS oesi ShassadelstonyCascadiler henwserwietTO0У L7oo inu comoy tiicirsr+0.Winat about thit. Saeme the a sion ie in cmall. Witistill work and howaYes, this will work correctly. Let me trace through the logic with this exact ema.o incader valtes carchen444700 Syaloryideoeuowon.coephe11 1. Split on &oirt8carchenttocho0LyaPors.cra8808.0o.wot.tdwrinw.conthos,chict:Xwloihy.cos=ssXr9th.osI1 3. Strip plus tag fron local partstoca Base= exolodel"*,catch=a14447700.57706...e"catch-al// 4. Compare alías: 'catch-all' ma= 'catch-all' 7 - returns truSo isforcurrentEnvi ronsentü returns tre and the messace docaeds to oe disoatchedThen in EnailTextRelay job, parseRecipient() uses the To header directly and the regex \d+\.1d+\. [a-zA-20-91(10)@txt\.jiainny\.com extracts 447700152786.359877878118.1005kd34299txt.Jiainny.con- the + prefiobelore tne phoné numbers is stripped oy parsekeciotentintoentities wnich prepends + ilselt anyway.Everything works end-to-end. Now you just need to re-apply the to header fallback fix so these messagesvice,0ho #l187-716rayt PalhuSarica nhrFix is back in place and the temporary headers oresent disgnostic logging is removed. The tests already retlcctthis loo'e trom carier. Youfo dood to ocpioyb FilesgetTypeoctUuicy hiefix ft@ Code swioTh04GKwindeurlahmehieht4 spad...
|
81509
|
NULL
|
NULL
|
NULL
|
|
81509
|
2829
|
10
|
2026-05-28T08:21:31.559676+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956491559_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"15","depth":4,"bounds":{"left":0.37333778,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"64","depth":4,"bounds":{"left":0.3849734,"top":0.10055866,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39694148,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.40425533,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-7338789406039012759
|
-2005030018943372365
|
typing_pause
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81508
|
2829
|
9
|
2026-05-28T08:21:26.326563+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956486326_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"15","depth":4,"bounds":{"left":0.37333778,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"64","depth":4,"bounds":{"left":0.3849734,"top":0.10055866,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39694148,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.40425533,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"10","depth":4,"bounds":{"left":0.72772604,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7390292,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7463431,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","depth":4,"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-4397807297170792528
|
-2007281816540925037
|
typing_pause
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
81507
|
NULL
|
NULL
|
NULL
|
|
81507
|
2829
|
8
|
2026-05-28T08:21:22.333052+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956482333_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"15","depth":4,"bounds":{"left":0.37333778,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"64","depth":4,"bounds":{"left":0.3849734,"top":0.10055866,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39694148,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.40425533,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_selected":false,"is_expanded":false}]...
|
1256027070376305626
|
-8708464657711297600
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
rapstomViewCoocWindowFV faVsco.|s ~$ JY-20915-fix-missProinet v© SyncMailbox.phpWockhrhta© ServiceTest.php© SyncBatchRedisServiceRaseSercetest oho© CachedCrmServiceDecora© CrmActivityServiceTest.ptc CrmConfigurationSettingsCrmObiectsResolverTest.gDefaultProspectSearchStEmailHelperTest.pho© FieldValueConverterTest.LayoutManagertest.prpC MigrateProviderServiceTe© OpportunityActivityMatchiTextRelsyServiceTest.php x php fiminny.php3.env.productionuse wanny servaces näzt lextkeldyoervzeeuse thrunzt rranework aecizuutes coversulassuse Purunze rranework Accrzbures uacarrovzderuse Tests esccaseruse kertectzonctassuse hockery=coverscLassdexkelayserv.ce:.classclass Tex ReLayservacetest excends Testcasac Opportuniysyncstratcoyt© ProspectCacheTest.phoc Prosoccsearchstratcoytc ProviderReoistviestohoc Recordseleclortestono© ResolveCompanyNameByle ttimepenodtertontortocUocareeiman acors werdlntemnav KioskvuromatedceooreCACMMiMneSorooteCackminnucerr.oC AskJiminnyReportServiAutomatedPanorsoah© AutomatedReportsSenAutomatedPadotteSen© AutomatedReportsSenv© AutomatedReportsSenv© AutomatedReportsSen© AutomatedReportsSen© AutomatedReportsSen© AutomatedReportsSenAutomatedReportsSenAntomatndecoosssenC) RecicientServiceTest.o184 €216 ₽wiswa>bActions248 PZusagesoubldc starc tuncison envi ronmentProv deror arrav annrorecteduncion sernor wosd.protected function tearbowng: voidt...#baraprousderenusconmenr?rowsden"nubibie functiion testisForiucrentFnwsconnenttthwatchsnoy6nin.osnalTokeaderdstring SdeployRegion,string SexpectedAlias,string Srecipient•: void 1..unataProusden enusconcontProusdentpuoere tuncczon cesclsrorcurrentanv.ronnen:.Nonksrchsingx6non..o.oml.Tokondenstring SdeployRegiontiino SexocercoRtrowiiano sreczoreneD: void 4..Hpublic function testIsForCurrentEnvironnentLoqsRefusedMessageO: void...,oublic function testisForCurrentEnvironnent/gnoresToHeaderO: voidi...;public functiion testisFor@urrentEnvironnent@ithEnotyHeadersO= voidf...,oublic functiion testisFor@urrentEnvironnent@ithSxceptzion@= voidf...oublic functsion testisFor@urrentEnvironnentRefectsllrongHostWithMatchingPlusTaqO: voidi...>E Otrice> &a Resolvers>traitspublic function testSyncUsesEuALiasForEuRegion(): void{...}• - Validatorsmuaide sunetion testsunciisasis.acsonlcreosoodt wosora© BatchServiceTest.php@ EmailActivitvServiceTest© InboxServiceTest.phpo Teytcalavsemceltes60dpublic function testSyncwithEnhancedLoggingO: voidi...TAAGpublic function testSyncWithRefusedMessageLogs: voidk....IilMeet ne caneratorM Notificationpublic function testGetHistoryLogsError0nException: voidk..araveliosSF (iminny@localhost)HS.Jocal jiminny@blocalhost)& console [PROD# console EuTconsole STAcinG(startHistoryId] => 359929correlatzon10: 0045/14/-t328-4017-8355-967c0cca1z00race-10: 34082136-3912-450t-95cc-0528268C2t0S-17826-85-78 88:88:54 Locau.AWFU: Snessaachzscorycorrelation.1d:0av5y74-7378-4017-8055-96c8ccalxoctrace-10:[CREDIT_CARD]-95c6-052826862T05-317876-85078 88:852 omuetsts Soaranelh story wnes messaneaddedctartHistorydil50:741'correlation_1d:"C5339dcc-46c1-45a4-81f9-ede8285ab266, trace_10: 627196cf-0a89-465a-ab3e-18e546adfcde"}12826-85-28 R8-05:201l TocolTwEn: Snessadels stomArrayi"correlation_id":"c5339dcc-46C1-45a4-81f9-ede8283ab266*, *trace_1d":"627196cf-0a09-465a-ab3e-10e546adfcde*)(2826-85-28 88:10:44) local.INFO: SparansArrayhistoryTypes => messageAddecistartHistoryId) => 359929"correlation_id":"86677130-79c8-46a6-bSa4-b13351d287da*,*trace_id":"52cc740a-b685-4b96-abda-8eSab1057ca6"}12826-85-28 88:10:44] Zocal.INF0: SmessageHistoryArratce10:S2ec//48a-0685-4096-a0da-8e5ab85yeao17826-85328 88-157381 ocaunuFl: Soaransmistorvnvoes => nessagenddecstartHistoryd 8> 359823conneationsd"."cranriny.anne.wox-oo0d-caaadoscehoeuooaceo.thesisestns.hexe.8oc/.uhRehzcserxierhoReeS oesi ShassadelstonyCascadirner hensewiet7o0sLXoo inu co moy tiicie+0.Winat about thit. Saeme the a sion ie in cmall. Witistill work and howaYes, this will work correctly. Let me trace through the logic with this exact ema.o incader valtes carchen444700 Syaloryideoeuowon.coephe11 1. Split on &oirt8carchenttocho0LyaPors.cra8808.0o.wot.tdwrinw.conthos,chict:Xwloihy.cos=ssXr9th.osI1 3. Strip plus tag fron local partstoca Basc= exolodel",catch=a14447700157786...Ol"catch-al// 4. Compare alías: 'catch-all' ma= 'catch-all' 7 - returns truSo isforcurrentEnvi ronsentü returns tre and the messace docaeds to oe disoatchedThen in EnailTextRelay job, parseRecipient() uses the To header directly and the regex \d+\.1d+\. [a-zA-20-91(10)@txt\.Jiminny\.com extracts 447700152786.359877878118. 1005kd302M9txt-Jiminny.com -the + prefixbelore tne phoné numbers is stripped oy parsekeciotentintoentities wnich prepends + ilselt anyway.Everything works end-to-end. Now you just need to re-apply the to header fallback fix so these messagesvice.oho #487-718aytPalhuSarica nhrFix is back in place and the temporary headers oresent disgnostic logging is removed. The tests already retlcctthtwoe tom esrcarouito doodoocron# Group by ©Adnptive MgSWERTGCudOhin ModinehKimi K2.6Ach sowthine ouua with Hitton-@ eodtAdhotv• CKwindeurlahmehieh*4 space...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81506
|
2828
|
9
|
2026-05-28T08:21:22.227670+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956482227_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"15","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"64","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"10","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","depth":4,"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-4397807297170792528
|
-2007281816540925037
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
81505
|
NULL
|
NULL
|
NULL
|
|
81505
|
2828
|
8
|
2026-05-28T08:21:16.248236+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956476248_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-7228688528716742632
|
2609222811515291121
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
iTerm2ShellEditViewSessionScriptsProfilesWindowHelp‹$0ADOCKER- ₴81DEV (docker)₴2dockerdockerscreenpipe"O ₴4-zsh*5ec2-user@ip-10-30-1...100% <78• Thu 28 May 11:21:16T81O ₴6ec2-user@ip-10-30-140-….$7Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory usedDetected deprecations in use (they will stop working in next major release):Rule set"@PHP74Migration"is deprecated.Use"@PHP7x4Migration"instead.- Rule set "@PHP80Migration" is deprecated.Use "@PHP8x0Migration" instead.- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration"instead.Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.Rule set "@PHP83Migration" is deprecated.Use"@PHP8x3Migration" instead.- Rule set "@PHP84Migration" is deprecated.Use"@PHP8x4Migration" instead.What's next:Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1Learn more at [URL_WITH_CREDENTIALS] deprecated. Use "@PHP7x4Migration" instead.Rule set"@PHP80Migration" is deprecated.Use "@PHP8x0Migration" instead.- Rule set "@PHP81Migration" is deprecated. Use "®PHP8x1Migration" instead.- Rule set "@PHP82Migration" is deprecated. Use "®PHP8x2Migration" instead.- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.What's next:Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ ;xddocker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"What's next:Try Docker Debug forseamless, persistent debugging tools in any container or image → docker debug docker_lamp_1Learn moreat https://docs.docker.com/go/debug-cli/docker exec -it docker_lamp_1 supervisorctl restart all...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81504
|
2829
|
7
|
2026-05-28T08:21:15.543203+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956475543_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"15","depth":4,"bounds":{"left":0.37333778,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"64","depth":4,"bounds":{"left":0.3849734,"top":0.10055866,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39694148,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.40425533,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"10","depth":4,"bounds":{"left":0.72772604,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7390292,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7463431,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","depth":4,"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-4397807297170792528
|
-2007281816540925037
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
15
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
81503
|
NULL
|
NULL
|
NULL
|
|
81503
|
2829
|
6
|
2026-05-28T08:21:11.710710+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956471710_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
13
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"13","depth":4,"bounds":{"left":0.37333778,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"64","depth":4,"bounds":{"left":0.3849734,"top":0.10055866,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39694148,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.40425533,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"10","depth":4,"bounds":{"left":0.72772604,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7390292,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7463431,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","depth":4,"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
1294603470630768666
|
-2007281816540925037
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
13
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81502
|
2829
|
5
|
2026-05-28T08:20:59.446538+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956459446_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Rerun 'PHPUnit: TextRelayServiceTest'
Debug 'TextRelayServiceTest'
Stop 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
13
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Rerun 'PHPUnit: TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Stop 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9494681,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"13","depth":4,"bounds":{"left":0.37333778,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"64","depth":4,"bounds":{"left":0.3849734,"top":0.10055866,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39694148,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.40425533,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"10","depth":4,"bounds":{"left":0.72772604,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7390292,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7463431,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","depth":4,"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
781220798701032375
|
-2007282366296738925
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Rerun 'PHPUnit: TextRelayServiceTest'
Debug 'TextRelayServiceTest'
Stop 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
13
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
81500
|
NULL
|
NULL
|
NULL
|
|
81501
|
2828
|
7
|
2026-05-28T08:20:53.437698+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956453437_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
13
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"13","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"64","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Services\\Mail;\n\nuse Google\\Service\\Gmail as GoogleGmail;\nuse Google\\Service\\Gmail\\Message as GmailMessage;\nuse Google\\Service\\Gmail\\MessagePart;\nuse Google\\Service\\Gmail\\MessagePartHeader;\nuse Illuminate\\Support\\Facades\\Config;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Services\\Mail\\TextRelayService;\nuse PHPUnit\\Framework\\Attributes\\CoversClass;\nuse PHPUnit\\Framework\\Attributes\\DataProvider;\nuse Tests\\TestCase;\nuse ReflectionClass;\nuse Mockery;\n\n#[CoversClass(TextRelayService::class)]\nclass TextRelayServiceTest extends TestCase\n{\n public static function environmentProvider(): array\n {\n return [\n 'eu_environment' => ['eu', 'catch-all-eu', 'catch-all-eu@txt.jiminny.com'],\n 'us_environment' => ['us', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'other_environment_defaults_to_us' => ['other', 'catch-all', 'catch-all@txt.jiminny.com'],\n 'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', 'catch-all-eu+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n 'us_environment_with_plus_tag' => ['us', 'catch-all', 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.jiminny.com'],\n ];\n }\n\n protected function setUp(): void\n {\n parent::setUp();\n }\n\n protected function tearDown(): void\n {\n Mockery::close();\n parent::tearDown();\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = $recipient;\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertTrue($result);\n }\n\n #[DataProvider('environmentProvider')]\n public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(\n string $deployRegion,\n string $expectedAlias,\n string $recipient\n ): void {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'other@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentLogsRefusedMessage(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'wrong@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Refused message', [\n 'message_id' => 'msg123',\n 'original_to_sanitized' => 'wrong@txt.jiminny.com',\n ]);\n\n Log::shouldReceive('error')\n ->never()\n ->with('[TextRelayService] Failed to inspect message', \\Mockery::type('array'));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentIgnoresToHeader(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'To';\n $header->value = 'catch-all@txt.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithEmptyHeaders(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n\n $payload->method('getHeaders')->willReturn([]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('warning')\n ->once()\n ->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [\n 'message_id' => 'msg123',\n ]);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentWithException(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')\n ->willThrowException(new \\Exception('Gmail API error'));\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to inspect message', [\n 'message_id' => 'msg123',\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void\n {\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n\n $message = $this->createMock(GmailMessage::class);\n $payload = $this->createMock(MessagePart::class);\n $header = $this->createMock(MessagePartHeader::class);\n\n $header->name = 'X-Gm-Original-To';\n $header->value = 'catch-all+447700152706.447893937879.3ndZZBqjRo@txt.staging.jiminny.com';\n\n $payload->method('getHeaders')->willReturn([$header]);\n $message->method('getPayload')->willReturn($payload);\n\n $usersMessages = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersMessages::class);\n $usersMessages->method('get')->willReturn($message);\n\n $gmailService = $this->createMock(GoogleGmail::class);\n $gmailService->users_messages = $usersMessages;\n\n $service = $this->createTextRelayService();\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('isForCurrentEnvironment');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');\n\n $this->assertFalse($result);\n }\n\n public function testSyncUsesEuAliasForEuRegion(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncUsesUsAliasForUsRegion(): void\n {\n Config::set('jiminny.deploy_region', 'us');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $historyResponse = $this->createMock(\\Google\\Service\\Gmail\\ListHistoryResponse::class);\n $historyResponse->historyId = 12345;\n $historyResponse->method('getHistory')->willReturn([]);\n $historyResponse->method('getNextPageToken')->willReturn(null);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')->willReturn($historyResponse);\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n \\Cache::shouldReceive('put')->with('test-topic', 12345, \\Mockery::on(fn ($expires) => $expires instanceof \\Carbon\\Carbon));\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n }\n\n public function testSyncWithEnhancedLogging(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testSyncWithRefusedMessageLogs(): void\n {\n Config::set('jiminny.deploy_region', 'eu');\n Config::set('jiminny.google_text_host', 'txt.jiminny.com');\n Config::set('jiminny.google_text_user', 'test@example.com');\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n\n // Create a partial mock of the service to control the getHistory method\n $service = $this->createPartialMock(TextRelayService::class, ['getHistory']);\n\n // Mock getHistory to return empty array (no messages to process)\n $service->method('getHistory')->willReturn([]);\n\n // Mock Log facade - channel() returns a driver mock that accepts any method call\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Starting sync', [\n 'mailbox' => 'test@example.com',\n 'expected_alias' => 'catch-all-eu',\n 'expected_host' => 'txt.jiminny.com',\n ]);\n\n Log::shouldReceive('info')\n ->once()\n ->with('[TextRelayService] Sync completed', [\n 'mailbox' => 'test@example.com',\n 'messages_processed' => 0,\n 'message_ids' => [],\n ]);\n\n // Mock Sentry to prevent actual error reporting\n \\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();\n\n $reflection = new ReflectionClass($service);\n $syncMethod = $reflection->getMethod('sync');\n $syncMethod->setAccessible(true);\n\n $result = $syncMethod->invoke($service);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n public function testGetHistoryLogsErrorOnException(): void\n {\n Config::set('jiminny.google_text_relay_topic', 'test-topic');\n Config::set('jiminny.google_text_user', 'test@example.com');\n\n $service = $this->createTextRelayService();\n $gmailService = $this->createMock(GoogleGmail::class);\n\n $usersHistory = $this->createMock(\\Google\\Service\\Gmail\\Resource\\UsersHistory::class);\n $usersHistory->method('listUsersHistory')\n ->willThrowException(new \\Exception('Gmail API error'));\n $gmailService->users_history = $usersHistory;\n\n \\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);\n\n $logDriver = \\Mockery::mock();\n $logDriver->shouldIgnoreMissing();\n Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);\n Log::shouldReceive('error')\n ->once()\n ->with('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => 'Gmail API error',\n ]);\n\n \\Sentry::shouldReceive('captureException')\n ->once()\n ->with(\\Mockery::type(\\Exception::class));\n\n $reflection = new ReflectionClass($service);\n $method = $reflection->getMethod('getHistory');\n $method->setAccessible(true);\n\n $result = $method->invoke($service, $gmailService);\n\n $this->assertIsArray($result);\n $this->assertEmpty($result);\n }\n\n private function createTextRelayService(): TextRelayService\n {\n $service = new class () extends TextRelayService {\n public function __construct()\n {\n }\n };\n\n return $service;\n }\n\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"10","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","depth":4,"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:15:30] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}\n[2026-05-28 08:15:31] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"d7777b21-4b0e-4793-922d-caaad95cebbe\",\"trace_id\":\"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
1294603470630768666
|
-2007281816540925037
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
13
64
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\Mail;
use Google\Service\Gmail as GoogleGmail;
use Google\Service\Gmail\Message as GmailMessage;
use Google\Service\Gmail\MessagePart;
use Google\Service\Gmail\MessagePartHeader;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Jiminny\Services\Mail\TextRelayService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
use ReflectionClass;
use Mockery;
#[CoversClass(TextRelayService::class)]
class TextRelayServiceTest extends TestCase
{
public static function environmentProvider(): array
{
return [
'eu_environment' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment' => ['us', 'catch-all', '[EMAIL]'],
'other_environment_defaults_to_us' => ['other', 'catch-all', '[EMAIL]'],
'eu_environment_with_plus_tag' => ['eu', 'catch-all-eu', '[EMAIL]'],
'us_environment_with_plus_tag' => ['us', 'catch-all', '[EMAIL]'],
];
}
protected function setUp(): void
{
parent::setUp();
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = $recipient;
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertTrue($result);
}
#[DataProvider('environmentProvider')]
public function testIsForCurrentEnvironmentWithNonMatchingXGmOriginalToHeader(
string $deployRegion,
string $expectedAlias,
string $recipient
): void {
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', $expectedAlias, 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentLogsRefusedMessage(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Refused message', [
'message_id' => 'msg123',
'original_to_sanitized' => '[EMAIL]',
]);
Log::shouldReceive('error')
->never()
->with('[TextRelayService] Failed to inspect message', \Mockery::type('array'));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentIgnoresToHeader(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithEmptyHeaders(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$payload->method('getHeaders')->willReturn([]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('warning')
->once()
->with('[TextRelayService] Refused message: missing X-Gm-Original-To header', [
'message_id' => 'msg123',
]);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentWithException(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')
->willThrowException(new \Exception('Gmail API error'));
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to inspect message', [
'message_id' => 'msg123',
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testIsForCurrentEnvironmentRejectsWrongHostWithMatchingPlusTag(): void
{
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
$message = $this->createMock(GmailMessage::class);
$payload = $this->createMock(MessagePart::class);
$header = $this->createMock(MessagePartHeader::class);
$header->name = 'X-Gm-Original-To';
$header->value = '[EMAIL]';
$payload->method('getHeaders')->willReturn([$header]);
$message->method('getPayload')->willReturn($payload);
$usersMessages = $this->createMock(\Google\Service\Gmail\Resource\UsersMessages::class);
$usersMessages->method('get')->willReturn($message);
$gmailService = $this->createMock(GoogleGmail::class);
$gmailService->users_messages = $usersMessages;
$service = $this->createTextRelayService();
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('isForCurrentEnvironment');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService, 'catch-all', 'msg123', 'catch-all', 'txt.jiminny.com');
$this->assertFalse($result);
}
public function testSyncUsesEuAliasForEuRegion(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncUsesUsAliasForUsRegion(): void
{
Config::set('jiminny.deploy_region', 'us');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$historyResponse = $this->createMock(\Google\Service\Gmail\ListHistoryResponse::class);
$historyResponse->historyId = 12345;
$historyResponse->method('getHistory')->willReturn([]);
$historyResponse->method('getNextPageToken')->willReturn(null);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')->willReturn($historyResponse);
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
\Cache::shouldReceive('put')->with('test-topic', 12345, \Mockery::on(fn ($expires) => $expires instanceof \Carbon\Carbon));
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
}
public function testSyncWithEnhancedLogging(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testSyncWithRefusedMessageLogs(): void
{
Config::set('jiminny.deploy_region', 'eu');
Config::set('jiminny.google_text_host', 'txt.jiminny.com');
Config::set('jiminny.google_text_user', '[EMAIL]');
Config::set('jiminny.google_text_relay_topic', 'test-topic');
// Create a partial mock of the service to control the getHistory method
$service = $this->createPartialMock(TextRelayService::class, ['getHistory']);
// Mock getHistory to return empty array (no messages to process)
$service->method('getHistory')->willReturn([]);
// Mock Log facade - channel() returns a driver mock that accepts any method call
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Starting sync', [
'mailbox' => '[EMAIL]',
'expected_alias' => 'catch-all-eu',
'expected_host' => 'txt.jiminny.com',
]);
Log::shouldReceive('info')
->once()
->with('[TextRelayService] Sync completed', [
'mailbox' => '[EMAIL]',
'messages_processed' => 0,
'message_ids' => [],
]);
// Mock Sentry to prevent actual error reporting
\Sentry::shouldReceive('captureException')->zeroOrMoreTimes();
$reflection = new ReflectionClass($service);
$syncMethod = $reflection->getMethod('sync');
$syncMethod->setAccessible(true);
$result = $syncMethod->invoke($service);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
public function testGetHistoryLogsErrorOnException(): void
{
Config::set('jiminny.google_text_relay_topic', 'test-topic');
Config::set('jiminny.google_text_user', '[EMAIL]');
$service = $this->createTextRelayService();
$gmailService = $this->createMock(GoogleGmail::class);
$usersHistory = $this->createMock(\Google\Service\Gmail\Resource\UsersHistory::class);
$usersHistory->method('listUsersHistory')
->willThrowException(new \Exception('Gmail API error'));
$gmailService->users_history = $usersHistory;
\Cache::shouldReceive('get')->with('test-topic')->andReturn(10000);
$logDriver = \Mockery::mock();
$logDriver->shouldIgnoreMissing();
Log::shouldReceive('channel')->zeroOrMoreTimes()->andReturn($logDriver);
Log::shouldReceive('error')
->once()
->with('[TextRelayService] Failed to fetch Gmail history', [
'exception' => 'Gmail API error',
]);
\Sentry::shouldReceive('captureException')
->once()
->with(\Mockery::type(\Exception::class));
$reflection = new ReflectionClass($service);
$method = $reflection->getMethod('getHistory');
$method->setAccessible(true);
$result = $method->invoke($service, $gmailService);
$this->assertIsArray($result);
$this->assertEmpty($result);
}
private function createTextRelayService(): TextRelayService
{
$service = new class () extends TextRelayService {
public function __construct()
{
}
};
return $service;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
10
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:15:30] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
[2026-05-28 08:15:31] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"d7777b21-4b0e-4793-922d-caaad95cebbe","trace_id":"11b3e5d5-5f65-4e3e-82c2-488eb7c15ed6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
81499
|
NULL
|
NULL
|
NULL
|
|
81500
|
2829
|
4
|
2026-05-28T08:20:50.218496+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956450218_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
rnostolFv faVsco.is$ JY-20915-fix-missing-header-t rnostolFv faVsco.is$ JY-20915-fix-missing-header-text-relayproideta Kemeloho© SyncMailbox.phpWockhrhta© ServiceTest.php© SyncBatchRedisServiceRaseSercetest oho© CachedCrmServiceDecora© CrmActivityServiceTest.ptc CrmConfigurationSettingsCrmObiectsResolverTest.rDefaultProspectSearchStEmailHelperTest.pho© FieldValueConverterTest.g© LayoutManagerTest.phdC MigrateProviderServiceTe© OpportunityActivityMatchiTextRelsyServiceTest.php x php fiminny.php3.env.productionuse wanhy ocrvaces nözt textkelayseryzeeuse thrunzt rranework aecizuutes coversulassuse Purunze rranework Accrzbures uacarrovzderuse Tests esccaseruse kertectzonctassuse Mockeny:=coversclassdexRelayserv.ce:.classclass Tex Relayservzcetest excends Testeasac Opportuniysyncstratcoyt© ProspectCacheTest.phoc Prosoccsearchstratcoyt© ProviderRecistryTest.phoc Recordseleclortestono© ResolveCompanyNameByle ttimepenodtertontortocUocareeiman acors werdlntemnaV KioskvuromatedceooreOACMTMiMneSorsoterCackminnucerr.oC AskJiminnyReportServiAutomatedPanorsoah© AutomatedReportsSenAutomatedPadotteSen© AutomatedReportsSenvAntomatadPanoneCan© AutomatedReportsSen© AutomatedReportsSen© AutomatedReportsSen© AutomatedReportsSenAutomatedReportsSenAutomatedReportsSenC RecicientServiceTest.o184 P216 ₽wiswa>bActions248 ₽Zusagespublic static function environmentProviderO: arrayf…nrorecteduncion sernor wosd.protected function tearbowng: voidt...#baraprousderenusconmenr?rowsden"nubibie functiion testisForfucrentFnvsconnenttthMatchsnoY6n0r.csnalTokeaderdstring SdeployRegion,string SexpectedAlias,string Srecipient•: void 1..unataProusden enusconcontProusdentpooere tuncczon cesclsrorcurrentanv.ronnen:.Nonksrchsingx6non..o.mml.Tokondenstring SdeployRegiontiino SexocercoRtrowiiano sreczoreneD: void 4..Hpublic function testIsForCurrentEnvironnentLoqsRefusedMessageO: void...,oublic function testisForCurrentEnvironnent/gnoresToHeaderO: void...;public function testIsForCurrentEnvironmentWithEmptyHeaders(): void(...}oublic functiion testisFor@urrentEnvironnent@ithSxceptzion@= voidf...oublic functsion testisFor@urrentEnvironnentRefectsllrongHostWithMatchingPlusTaq@: voidf...h>E Otrice> &a Resolvers>traitspublic function testSyncUsesEuALiasForEuRegion(): void{...}• - Validatorsmaite Funetson tastcunclcasisacsonlcceosodde wosd.e.c) Batchservicetestcho@ EmailActivitvServiceTest© InboxServiceTest.phpo Teytcalavsemceltes60dpublic function testSyncwithEnhancedLoggingO: voidi...TAAGpublic function testSyncWithRefusedMessageLogs: voidk....IilMeet ne caneratorM Notificationpublic function testGetHistoryLogsErrorOnException: voidk....araveliosSF (iminny@localhost)HS Jocal (jiminny@alocalhost)& console [PROD# consolefFulconsole STAcinG(startHistoryId] => 359929correlazon1d: 0095/14/-t328-4017-8a55-961cocca1200race10: 34062130-3912-45ct-95cc-0528268C2t0S-17826-85-78 88:88:54 Locau.AWFU: Snessaachzscorycorrelation.1d:0av5y74-7378-4017-8055-96c8ccalxoctrace-10:[CREDIT_CARD]-95c6-052826862T05-317876-85078 88:852 omuetsts Soaranelh story wnesi messado.ddedctartHistorydil50:741"correlation_1d:"C5339dcc-4601-45a4-81f9-ede8285ab266, trace_10: 627196cf-0a89-465a-ab3e-18eS4oadfcde"}12826-85-28 R8-05:201l TocolTwEn: Snessadels stomAnnar"correlation_id":"c5339dcc-46C1-45a4-81f9-ede8283ab266*,*trace_1d":"627196cf-0a89-465a-ab3e-10e546adfcde")2924-95-28 RR-10-WAI Tocol TNEh• SnanansArrayhistoryTypes => messageAddecistartHistoryId) => 359929""correlation_id":"86677130-79c8-46a6-bSa4-b13351d287da*, *trace_id":"52cc740a-b685-4b96-abda-8eSab1057ca6"-12826-85-28 88:10:44] Zocal.INF0: SmessageHistoryArracorrelation.1d: 860/30-1908-4606-0504-065507870atrace10:Syec/48a-0685-4096-a0da-8eSab8Syeao12826-85-28 88:15:301 Zocal,INF0: SoaransArravmistorvnvoes => nessagenddecstartHistoryd 8> 359823fconnelation fa"."47777621-4h8e-4703-022d-600ad05cehhe* etoace 3a*.*11h38545-5665-483e-92c2-/88eh7c15ed6*})ierhoReeS oesi Shassadelstonyconnallatton"*"ctrhhh.-nna-woX-002decaaadoscanhaeconea/etthhasnsesthchxn-82c2./.Rahtcs5erxuTextRelayServiceTesteeendhrner hensewiet100% L7oo Inu co moy 11.20.48+0.Winat about thit. Saeme the a cion is in cmall. Witistll work and howYes, this will work correctly. Let me trace through the logic with this exact ema.o tncader valtos catchen2444700 SyxPorlheeeRoosueonnrcophe11 1. Split on &oirt8carchenttocho0LyaPors.cra8808.0o.wot.tdwrinw.conthos,chict:Xwloihy.cos=ssXr9th.osI1 3. Strip plus tag fron local partstoca Basc= exolodel",catch=a14447700157786...Ol"catch-al// 4. Compare alías: 'catch-all' ma= 'catch-all' 7 - returns truSo isforcurrentEnvi ronsentü returns tre and the messace docaeds to oe disoatchedThen in EnailTextRelay job, parseRecipient() uses the To header directly and the regex \0+\.1d+\. [a-zA-20-91(10)@txt\.Jiminny\.com extracts 447700152786.359877878118. 1005kd3d2M9txt-Jiminny.com -the + prefixbelore tne phoné numbers is stripped oy parsekeciptentintoentities wnich prepends + isell anyway.Everything works end-to-end. Now you just need to re-apply the to header fallback fix so these messagesice.0ho #l187-718aytPalhuSarica nhrFix is back in place and the temporary headers present diagnostic logging is removed. The tests already retlcctthis loo'e trom carier. Youfo dood to ocpioyAsk anything (XoL)-@ eodtAdhotvP4 s...
|
NULL
|
-4256858682243319785
|
NULL
|
click
|
ocr
|
NULL
|
rnostolFv faVsco.is$ JY-20915-fix-missing-header-t rnostolFv faVsco.is$ JY-20915-fix-missing-header-text-relayproideta Kemeloho© SyncMailbox.phpWockhrhta© ServiceTest.php© SyncBatchRedisServiceRaseSercetest oho© CachedCrmServiceDecora© CrmActivityServiceTest.ptc CrmConfigurationSettingsCrmObiectsResolverTest.rDefaultProspectSearchStEmailHelperTest.pho© FieldValueConverterTest.g© LayoutManagerTest.phdC MigrateProviderServiceTe© OpportunityActivityMatchiTextRelsyServiceTest.php x php fiminny.php3.env.productionuse wanhy ocrvaces nözt textkelayseryzeeuse thrunzt rranework aecizuutes coversulassuse Purunze rranework Accrzbures uacarrovzderuse Tests esccaseruse kertectzonctassuse Mockeny:=coversclassdexRelayserv.ce:.classclass Tex Relayservzcetest excends Testeasac Opportuniysyncstratcoyt© ProspectCacheTest.phoc Prosoccsearchstratcoyt© ProviderRecistryTest.phoc Recordseleclortestono© ResolveCompanyNameByle ttimepenodtertontortocUocareeiman acors werdlntemnaV KioskvuromatedceooreOACMTMiMneSorsoterCackminnucerr.oC AskJiminnyReportServiAutomatedPanorsoah© AutomatedReportsSenAutomatedPadotteSen© AutomatedReportsSenvAntomatadPanoneCan© AutomatedReportsSen© AutomatedReportsSen© AutomatedReportsSen© AutomatedReportsSenAutomatedReportsSenAutomatedReportsSenC RecicientServiceTest.o184 P216 ₽wiswa>bActions248 ₽Zusagespublic static function environmentProviderO: arrayf…nrorecteduncion sernor wosd.protected function tearbowng: voidt...#baraprousderenusconmenr?rowsden"nubibie functiion testisForfucrentFnvsconnenttthMatchsnoY6n0r.csnalTokeaderdstring SdeployRegion,string SexpectedAlias,string Srecipient•: void 1..unataProusden enusconcontProusdentpooere tuncczon cesclsrorcurrentanv.ronnen:.Nonksrchsingx6non..o.mml.Tokondenstring SdeployRegiontiino SexocercoRtrowiiano sreczoreneD: void 4..Hpublic function testIsForCurrentEnvironnentLoqsRefusedMessageO: void...,oublic function testisForCurrentEnvironnent/gnoresToHeaderO: void...;public function testIsForCurrentEnvironmentWithEmptyHeaders(): void(...}oublic functiion testisFor@urrentEnvironnent@ithSxceptzion@= voidf...oublic functsion testisFor@urrentEnvironnentRefectsllrongHostWithMatchingPlusTaq@: voidf...h>E Otrice> &a Resolvers>traitspublic function testSyncUsesEuALiasForEuRegion(): void{...}• - Validatorsmaite Funetson tastcunclcasisacsonlcceosodde wosd.e.c) Batchservicetestcho@ EmailActivitvServiceTest© InboxServiceTest.phpo Teytcalavsemceltes60dpublic function testSyncwithEnhancedLoggingO: voidi...TAAGpublic function testSyncWithRefusedMessageLogs: voidk....IilMeet ne caneratorM Notificationpublic function testGetHistoryLogsErrorOnException: voidk....araveliosSF (iminny@localhost)HS Jocal (jiminny@alocalhost)& console [PROD# consolefFulconsole STAcinG(startHistoryId] => 359929correlazon1d: 0095/14/-t328-4017-8a55-961cocca1200race10: 34062130-3912-45ct-95cc-0528268C2t0S-17826-85-78 88:88:54 Locau.AWFU: Snessaachzscorycorrelation.1d:0av5y74-7378-4017-8055-96c8ccalxoctrace-10:[CREDIT_CARD]-95c6-052826862T05-317876-85078 88:852 omuetsts Soaranelh story wnesi messado.ddedctartHistorydil50:741"correlation_1d:"C5339dcc-4601-45a4-81f9-ede8285ab266, trace_10: 627196cf-0a89-465a-ab3e-18eS4oadfcde"}12826-85-28 R8-05:201l TocolTwEn: Snessadels stomAnnar"correlation_id":"c5339dcc-46C1-45a4-81f9-ede8283ab266*,*trace_1d":"627196cf-0a89-465a-ab3e-10e546adfcde")2924-95-28 RR-10-WAI Tocol TNEh• SnanansArrayhistoryTypes => messageAddecistartHistoryId) => 359929""correlation_id":"86677130-79c8-46a6-bSa4-b13351d287da*, *trace_id":"52cc740a-b685-4b96-abda-8eSab1057ca6"-12826-85-28 88:10:44] Zocal.INF0: SmessageHistoryArracorrelation.1d: 860/30-1908-4606-0504-065507870atrace10:Syec/48a-0685-4096-a0da-8eSab8Syeao12826-85-28 88:15:301 Zocal,INF0: SoaransArravmistorvnvoes => nessagenddecstartHistoryd 8> 359823fconnelation fa"."47777621-4h8e-4703-022d-600ad05cehhe* etoace 3a*.*11h38545-5665-483e-92c2-/88eh7c15ed6*})ierhoReeS oesi Shassadelstonyconnallatton"*"ctrhhh.-nna-woX-002decaaadoscanhaeconea/etthhasnsesthchxn-82c2./.Rahtcs5erxuTextRelayServiceTesteeendhrner hensewiet100% L7oo Inu co moy 11.20.48+0.Winat about thit. Saeme the a cion is in cmall. Witistll work and howYes, this will work correctly. Let me trace through the logic with this exact ema.o tncader valtos catchen2444700 SyxPorlheeeRoosueonnrcophe11 1. Split on &oirt8carchenttocho0LyaPors.cra8808.0o.wot.tdwrinw.conthos,chict:Xwloihy.cos=ssXr9th.osI1 3. Strip plus tag fron local partstoca Basc= exolodel",catch=a14447700157786...Ol"catch-al// 4. Compare alías: 'catch-all' ma= 'catch-all' 7 - returns truSo isforcurrentEnvi ronsentü returns tre and the messace docaeds to oe disoatchedThen in EnailTextRelay job, parseRecipient() uses the To header directly and the regex \0+\.1d+\. [a-zA-20-91(10)@txt\.Jiminny\.com extracts 447700152786.359877878118. 1005kd3d2M9txt-Jiminny.com -the + prefixbelore tne phoné numbers is stripped oy parsekeciptentintoentities wnich prepends + isell anyway.Everything works end-to-end. Now you just need to re-apply the to header fallback fix so these messagesice.0ho #l187-718aytPalhuSarica nhrFix is back in place and the temporary headers present diagnostic logging is removed. The tests already retlcctthis loo'e trom carier. Youfo dood to ocpioyAsk anything (XoL)-@ eodtAdhotvP4 s...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81499
|
2828
|
6
|
2026-05-28T08:20:39.668808+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956439668_m1.jpg...
|
iTerm2
|
docker
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
ec2-user@ip-10-30-140-255:~ (-zsh)
Close Tab
⌥⌘1
docker...
|
[{"role":"AXTextArea","text [{"role":"AXTextArea","text":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5698 files in 51.755 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all","depth":4,"on_screen":true,"value":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5698 files in 51.755 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all","is_focused":true},{"role":"AXRadioButton","text":"DOCKER","depth":2,"bounds":{"left":0.0,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.004166667,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"DEV (docker)","depth":2,"bounds":{"left":0.140625,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.14479166,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"docker","depth":2,"bounds":{"left":0.28125,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.28541666,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe\"","depth":2,"bounds":{"left":0.421875,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.42604166,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"-zsh","depth":2,"bounds":{"left":0.5625,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.56666666,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-129-190:~ (-zsh)","depth":2,"bounds":{"left":0.7027778,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.70694447,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-140-255:~ (-zsh)","depth":2,"bounds":{"left":0.84305555,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.8472222,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"⌥⌘1","depth":1,"bounds":{"left":0.9548611,"top":0.032222223,"width":0.03888889,"height":0.018888889},"on_screen":true,"automation_id":"_NS:8","role_description":"text"},{"role":"AXStaticText","text":"docker","depth":1,"bounds":{"left":0.4826389,"top":0.033333335,"width":0.034027778,"height":0.017777778},"on_screen":true,"role_description":"text"}]...
|
-3329078714930866893
|
-690278898522902327
|
typing_pause
|
accessibility
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
ec2-user@ip-10-30-140-255:~ (-zsh)
Close Tab
⌥⌘1
docker...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81498
|
2829
|
3
|
2026-05-28T08:20:35.589355+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956435589_m2.jpg...
|
iTerm2
|
-zsh
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
⌥⌘1
-zsh...
|
[{"role":"AXTextArea","text [{"role":"AXTextArea","text":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5698 files in 51.755 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ ;x","depth":4,"on_screen":true,"value":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5698 files in 51.755 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ ;x","is_focused":true},{"role":"AXRadioButton","text":"DOCKER","depth":2,"bounds":{"left":0.27027926,"top":1.0,"width":0.06732048,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.27227393,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"DEV (docker)","depth":2,"bounds":{"left":0.33759972,"top":1.0,"width":0.06732048,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.33959442,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"-zsh","depth":2,"bounds":{"left":0.40492022,"top":1.0,"width":0.06732048,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.4069149,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe\"","depth":2,"bounds":{"left":0.4722407,"top":1.0,"width":0.06732048,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.4742354,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"-zsh","depth":2,"bounds":{"left":0.53956115,"top":1.0,"width":0.06715426,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.5415558,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-129-190:~ (-zsh)","depth":2,"bounds":{"left":0.60671544,"top":1.0,"width":0.06715426,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.6087101,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-140-255:~ (-zsh)","depth":2,"bounds":{"left":0.67386967,"top":1.0,"width":0.06715426,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.67586434,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"⌥⌘1","depth":1,"bounds":{"left":0.7273936,"top":1.0,"width":0.01861702,"height":-0.023144484},"on_screen":true,"automation_id":"_NS:8","role_description":"text"},{"role":"AXStaticText","text":"-zsh","depth":1,"bounds":{"left":0.50398934,"top":1.0,"width":0.010970744,"height":-0.02394259},"on_screen":true,"role_description":"text"}]...
|
2759483326457972627
|
-690278898522900343
|
visual_change
|
accessibility
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
⌥⌘1
-zsh...
|
81497
|
NULL
|
NULL
|
NULL
|
|
81496
|
2828
|
5
|
2026-05-28T08:20:33.960346+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956433960_m1.jpg...
|
iTerm2
|
-zsh
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at https://docs.docker.com/go/debug-cli/
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $
DOCKER
Close Tab
DEV (docker)
Close Tab
-zsh
Close Tab
screenpipe"
Close Tab
-zsh
Close Tab
ec2-user@ip-10-30-129-190:~ (-zsh)...
|
[{"role":"AXTextArea","text [{"role":"AXTextArea","text":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5698 files in 51.755 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $","depth":4,"on_screen":true,"value":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5698 files in 51.755 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $","is_focused":true},{"role":"AXRadioButton","text":"DOCKER","depth":2,"bounds":{"left":0.0,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.004166667,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"DEV (docker)","depth":2,"bounds":{"left":0.140625,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.14479166,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"-zsh","depth":2,"bounds":{"left":0.28125,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.28541666,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe\"","depth":2,"bounds":{"left":0.421875,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.42604166,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"-zsh","depth":2,"bounds":{"left":0.5625,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.56666666,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-129-190:~ (-zsh)","depth":2,"bounds":{"left":0.7027778,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
2745193995254725972
|
-690278898522900339
|
click
|
accessibility
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at https://docs.docker.com/go/debug-cli/
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $
DOCKER
Close Tab
DEV (docker)
Close Tab
-zsh
Close Tab
screenpipe"
Close Tab
-zsh
Close Tab
ec2-user@ip-10-30-129-190:~ (-zsh)...
|
81495
|
NULL
|
NULL
|
NULL
|
|
81497
|
2829
|
2
|
2026-05-28T08:20:32.718834+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956432718_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
rapstomViewNeweNNCCoocWindowFV faVsco.|s ~$2 JY-20 rapstomViewNeweNNCCoocWindowFV faVsco.|s ~$2 JY-20915-fix-missing-header-text-relproidet© SyncMailbox.phpmockhrhts© InternetMessagelnterface.ph© MailChannelService.phgC TextRelayServiceTest.php >fyminny.ohe3.env.productionuse wanny servaces näzt lextkeldyoervzeeo Textrelkysewice.on> ( MeetinaGeneratoruse thrunzt rranework hecizuutes coversulassuse Purunze rranework Accrzbures Uacarrovzderanoucadorên OAuth2Dn Playbooksuse Tests esccaseruse kertectzonctass—KeCaLA—oeon=coversclassdexRelayserv.ce:.classJotaeo21%class Tex ReLayservacetest excends Testcasa-Streaminaa Teama TelechonyaUserPilotWebhook2467)C Abstrac Semvice cho©ActivityProviderFactory.php© ActivityService.php© ApiResponseService.ohog conferenceService.phpg InsightSeatService.phpC InstantMeetingService.phgC IntercomService.phgC IpapiClient.php© IpapiService.phpC ParticipantShareService.phg©PlanhatService.php© PlaybackService.phpPlaybackVideoOnlyService.pho© PlaybookCategoryService.php© PlaylistGeneratorinterface.phpel PocAlvo TosmerEmnodtin ny© SimoleThrottleService.ohd© SlackService.oho© SoclalAccountService.oho)© SoftPhoneService.oho©) TeamDeactivatedService.oho©) TeamOwnerService.ohoC) TeamService.ohoC) TranscodeParameterResolver.oh113 %154 %184 P216 ₽48 PZusagespublic static function environmentProviderO: arrayf…nrorecteduncion serint wosd.protected function tearbowng: voidt...#baraprousdenenusconmenr?rowsden"nubibie functiion testisForfucrentFnvsconnenttthMatchsnoY6n0r.csnalTokeaderdstring SdeployRegion,string SexpectedAlias,string Srecipient): void {...}nataProusden enusconcontProusdentpooere tuncczon cesclsrorcurrentanv.ronnen:.Nonksrchsingx6non..o.mml.Tokondenstring SdeployRegiontiino SexoeechoR broriiino oreczorenD: void 4..Hpublic function testIsForCurrentEnvironnentLoqsRefusedMessageO: void...oublic function testisForCurrentEnvironnent/gnoresToHeaderO: void...public functiion testisFor@urrentEnvironnent@ithEnotvHeadersO= voidf...;oublic functiion testisFor@urrentEnvironnent@ithSxceptzionO= voidf...C UserSemce.on© Uuid.php> M Traitc› @ UseCasesoublic functsion testisFor@urrentEnvironnentRefectsllrongHostWithMatchingPlusTaq@: voidf...public function testSyncUsesEuALiasForEuRegion(): void{...}mutismaite Funetson tastcunclcasisacsonlcceosodde wosde>E Va cationpublic function testSyncwithEnhancedLoggingO: voidt...Mo halnore nhr@ tnitislGrantondGtnto nhoTAApublic function testSyncWithRefusedMessageLogs: voidk....eillliminnv nhnpublic function testGetHistoryLogsErrorOnException: voidk...;araveliosSF (iminny@localhost)HS.Jocal jiminny@blocalhost)& console [PROD# console leul# CodMTGN(startHistoryId] => 359929correlazon1d: 0095/14/-t328-4017-8a55-961cocca1200race10: 34062130-3912-45ct-95cc-0528268C2t0S-17826-85-78 88:88:54 Locau.AWFU: Snessaachzscorycorrelation.1d:0av5y74-7378-4017-8055-96c8ccalxoctrace-10:[CREDIT_CARD]-95c6-052826862T05-317876-85078 88:852 omuetsts Soaranelh story wnesi messado.ddedctartHistorydil50:741"correlation_1d:"C5339dcc-4601-45a4-81f9-ede8285ab266, trace_10: 627196cf-0a89-465a-ab3e-18eS4oadfcde"}12826-85-28 R8-05:201l TocolTwEn: Snessadels stomAnnar"correlation_id":"c5339dcc-46C1-45a4-81f9-ede8283ab266*,*trace_1d":"627196cf-0a89-465a-ab3e-10e546adfcde")(2826-85-28 88:10:44) local.INFO: SparansArrayhistoryTypes => messageAddecistartHistoryId) => 359929"correlation_id":"86677130-79c8-46a6-bSa4-b13351d287da*,*trace_id":"52cc740a-b685-4b96-abda-8eSab1057ca6"}12826-85-28 88:10:44] Zocal.INF0: SmessageHistoryArratcorrelation.1d: 860/30-1908-4606-0504-065507870atrace10:Syec/48a-0685-4096-a0da-8eSab8Syeao12826-85-28 88:15:301 Zocal,INF0: SoaransArravnistorvivoes => messageaddedstartHistoryd 8> 359823fconnelation fa"."47777621-4h8e-4703-022d-600ad05cehhe* etoace 3a*.=11h38545-5665-483e-92c2-/88eb7c15ed6*})ierhoReeS oesi Shassadelstonyconnallatton"*"ctrhhh.-nna-woX-002decaaadoscanhaeconea/etthhasnsesthchxn-82c2./.Rahtcs5erxuTextRelayServiceTesteeendhler henwserwietTO0У L7• Thu 28 May 11:20:32+0.Winat about thit. Saeme the a cion is in cmall. Witistll work and howYes, this will work correctly. Let me trace through the logic with this exact ema.o tncader valtos catchen2444700 SyxPorlheeeRoosueonnrcophe11 1. Split on &oirt8carchenttocho0LyaPors.cra8808.0o.wot.tdwrinw.conthos,chict:Xwloihy.cos=ssXr9th.osI1 3. Strip plus tag fron local partstoca Basc= exolodel",catch=a14447700157786...Ol"catch-al// 4. Compare alías: 'catch-all' ma= 'catch-all' 7 - returns truSo isforcurrentEnvi ronsentü returns tre and the messace docaeds to oe disoatchedThen in EnailTextRelay job, parseRecipient() uses the To header directly and the regex \0+\.1d+\. [a-zA-20-91(10)@txt\.Jiminny\.com extracts 447700152786.359877878118. 1005kd3d2M9txt-Jiminny.com -the + prefixbelore tne phoné numbers is stripped oy parsekeciptentintoentities wnich prepends + isell anyway.Everything works end-to-end. Now you just need to re-apply the to header fallback fix so these messagesice.0ho #l187-718aytPalhuSarica nhrFix is back in place and the temporary headers present diagnostic logging is removed. The tests already retlcctthis loo'e trom carier. Youfo dood to ocpioyAsk anything (XoL)-@ eodtAdhotv• CKwindeurlahmehieh*4 space...
|
NULL
|
-2193955457860972182
|
NULL
|
click
|
ocr
|
NULL
|
rapstomViewNeweNNCCoocWindowFV faVsco.|s ~$2 JY-20 rapstomViewNeweNNCCoocWindowFV faVsco.|s ~$2 JY-20915-fix-missing-header-text-relproidet© SyncMailbox.phpmockhrhts© InternetMessagelnterface.ph© MailChannelService.phgC TextRelayServiceTest.php >fyminny.ohe3.env.productionuse wanny servaces näzt lextkeldyoervzeeo Textrelkysewice.on> ( MeetinaGeneratoruse thrunzt rranework hecizuutes coversulassuse Purunze rranework Accrzbures Uacarrovzderanoucadorên OAuth2Dn Playbooksuse Tests esccaseruse kertectzonctass—KeCaLA—oeon=coversclassdexRelayserv.ce:.classJotaeo21%class Tex ReLayservacetest excends Testcasa-Streaminaa Teama TelechonyaUserPilotWebhook2467)C Abstrac Semvice cho©ActivityProviderFactory.php© ActivityService.php© ApiResponseService.ohog conferenceService.phpg InsightSeatService.phpC InstantMeetingService.phgC IntercomService.phgC IpapiClient.php© IpapiService.phpC ParticipantShareService.phg©PlanhatService.php© PlaybackService.phpPlaybackVideoOnlyService.pho© PlaybookCategoryService.php© PlaylistGeneratorinterface.phpel PocAlvo TosmerEmnodtin ny© SimoleThrottleService.ohd© SlackService.oho© SoclalAccountService.oho)© SoftPhoneService.oho©) TeamDeactivatedService.oho©) TeamOwnerService.ohoC) TeamService.ohoC) TranscodeParameterResolver.oh113 %154 %184 P216 ₽48 PZusagespublic static function environmentProviderO: arrayf…nrorecteduncion serint wosd.protected function tearbowng: voidt...#baraprousdenenusconmenr?rowsden"nubibie functiion testisForfucrentFnvsconnenttthMatchsnoY6n0r.csnalTokeaderdstring SdeployRegion,string SexpectedAlias,string Srecipient): void {...}nataProusden enusconcontProusdentpooere tuncczon cesclsrorcurrentanv.ronnen:.Nonksrchsingx6non..o.mml.Tokondenstring SdeployRegiontiino SexoeechoR broriiino oreczorenD: void 4..Hpublic function testIsForCurrentEnvironnentLoqsRefusedMessageO: void...oublic function testisForCurrentEnvironnent/gnoresToHeaderO: void...public functiion testisFor@urrentEnvironnent@ithEnotvHeadersO= voidf...;oublic functiion testisFor@urrentEnvironnent@ithSxceptzionO= voidf...C UserSemce.on© Uuid.php> M Traitc› @ UseCasesoublic functsion testisFor@urrentEnvironnentRefectsllrongHostWithMatchingPlusTaq@: voidf...public function testSyncUsesEuALiasForEuRegion(): void{...}mutismaite Funetson tastcunclcasisacsonlcceosodde wosde>E Va cationpublic function testSyncwithEnhancedLoggingO: voidt...Mo halnore nhr@ tnitislGrantondGtnto nhoTAApublic function testSyncWithRefusedMessageLogs: voidk....eillliminnv nhnpublic function testGetHistoryLogsErrorOnException: voidk...;araveliosSF (iminny@localhost)HS.Jocal jiminny@blocalhost)& console [PROD# console leul# CodMTGN(startHistoryId] => 359929correlazon1d: 0095/14/-t328-4017-8a55-961cocca1200race10: 34062130-3912-45ct-95cc-0528268C2t0S-17826-85-78 88:88:54 Locau.AWFU: Snessaachzscorycorrelation.1d:0av5y74-7378-4017-8055-96c8ccalxoctrace-10:[CREDIT_CARD]-95c6-052826862T05-317876-85078 88:852 omuetsts Soaranelh story wnesi messado.ddedctartHistorydil50:741"correlation_1d:"C5339dcc-4601-45a4-81f9-ede8285ab266, trace_10: 627196cf-0a89-465a-ab3e-18eS4oadfcde"}12826-85-28 R8-05:201l TocolTwEn: Snessadels stomAnnar"correlation_id":"c5339dcc-46C1-45a4-81f9-ede8283ab266*,*trace_1d":"627196cf-0a89-465a-ab3e-10e546adfcde")(2826-85-28 88:10:44) local.INFO: SparansArrayhistoryTypes => messageAddecistartHistoryId) => 359929"correlation_id":"86677130-79c8-46a6-bSa4-b13351d287da*,*trace_id":"52cc740a-b685-4b96-abda-8eSab1057ca6"}12826-85-28 88:10:44] Zocal.INF0: SmessageHistoryArratcorrelation.1d: 860/30-1908-4606-0504-065507870atrace10:Syec/48a-0685-4096-a0da-8eSab8Syeao12826-85-28 88:15:301 Zocal,INF0: SoaransArravnistorvivoes => messageaddedstartHistoryd 8> 359823fconnelation fa"."47777621-4h8e-4703-022d-600ad05cehhe* etoace 3a*.=11h38545-5665-483e-92c2-/88eb7c15ed6*})ierhoReeS oesi Shassadelstonyconnallatton"*"ctrhhh.-nna-woX-002decaaadoscanhaeconea/etthhasnsesthchxn-82c2./.Rahtcs5erxuTextRelayServiceTesteeendhler henwserwietTO0У L7• Thu 28 May 11:20:32+0.Winat about thit. Saeme the a cion is in cmall. Witistll work and howYes, this will work correctly. Let me trace through the logic with this exact ema.o tncader valtos catchen2444700 SyxPorlheeeRoosueonnrcophe11 1. Split on &oirt8carchenttocho0LyaPors.cra8808.0o.wot.tdwrinw.conthos,chict:Xwloihy.cos=ssXr9th.osI1 3. Strip plus tag fron local partstoca Basc= exolodel",catch=a14447700157786...Ol"catch-al// 4. Compare alías: 'catch-all' ma= 'catch-all' 7 - returns truSo isforcurrentEnvi ronsentü returns tre and the messace docaeds to oe disoatchedThen in EnailTextRelay job, parseRecipient() uses the To header directly and the regex \0+\.1d+\. [a-zA-20-91(10)@txt\.Jiminny\.com extracts 447700152786.359877878118. 1005kd3d2M9txt-Jiminny.com -the + prefixbelore tne phoné numbers is stripped oy parsekeciptentintoentities wnich prepends + isell anyway.Everything works end-to-end. Now you just need to re-apply the to header fallback fix so these messagesice.0ho #l187-718aytPalhuSarica nhrFix is back in place and the temporary headers present diagnostic logging is removed. The tests already retlcctthis loo'e trom carier. Youfo dood to ocpioyAsk anything (XoL)-@ eodtAdhotv• CKwindeurlahmehieh*4 space...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81495
|
2828
|
4
|
2026-05-28T08:20:32.181340+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956432181_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-7635200922161528077
|
-4598385934329243181
|
visual_change
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
iTerm2Shell•EditViewSessionScriptsProfilesWindowHelp‹$0DOCKER-zshscreenpipe™O ₴1dispatch(Sjob);DEV (docker)₴2-zshdispatch(Sjob);Log: :info('[TextRelayService] Successfully dispatched message', ["message_id'=> SmessageId,end diff84-zsh*5Aec2-user@ip-10-30-1...100% <78• Thu 28 May 11:20:31T81O ₴6ec2-user@ip-10-30-140-...$7Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory usedDetected deprecations in useRule set"@PHP74Migration"(they will stop working in next major release):is deprecated.Use- Rule set"@PHP80Migration""@PHP7x4Migration"instead.is deprecated.Use "@PHP8x®Migration" instead.- Rule set"@PHP81Migration" is deprecated.Use "@PHP8x1Migration" instead.Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.- Rule set "@PHP83Migration" is deprecated.Use"@PHP8x3Migration" instead.- Rule set"@PHP84Migration" is deprecated.Use"@PHP8x4Migration" instead.What's next:Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1Learn more at [URL_WITH_CREDENTIALS] is deprecated. Use"@PHP7x4Migration" instead.- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x®Migration" instead.- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration"instead.- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.What's next:Try Docker Debug for seamless, persistent debugging tools in any container or image » docker debug docker_1amp_1Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $D...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81494
|
2828
|
3
|
2026-05-28T08:20:29.655101+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956429655_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayServiceTest.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
iTerm2ShellEditViewSessionScriptsProfilesWindowHel iTerm2ShellEditViewSessionScriptsProfilesWindowHelpA100% C-zshDOCKERк 881dispatch(Sjob);DEV (docker)₴2-zsh883dispatch(Sjob);Log: :info('[TextRelayService] Successfully dispatched message', ["message_id'=> SmessageId,end diffscreenpipe"О 84-zsh*5ec2-user@ip-10-30-1...O 86Thu 28 May 11:20:29T81ec2-user@ip-10-30-140-...$7Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory usedDetected deprecations in useRule set"@PHP74Migration"(they will stop working in next major release):is deprecated. Use- Rule set"@PHP80Migration""@PHP7x4Migration"instead.is deprecated.Use "@PHP8x®Migration" instead.- Rule set"@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.- Rule set "@PHP83Migration" is deprecated.Use "@PHP8x3Migration" instead.- Rule set "@PHP84Migration" is deprecated.Use"@PHP8x4Migration" instead.What's next:Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1Learn more at [URL_WITH_CREDENTIALS] is deprecated. Use"@PHP7x4Migration" instead.- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x®Migration" instead.- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration"instead.- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.What's next:Try Docker Debug for seamless, persistent debugging tools in any container or image » docker debug docker_1amp_1Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $...
|
NULL
|
3071947094976582750
|
NULL
|
click
|
ocr
|
NULL
|
iTerm2ShellEditViewSessionScriptsProfilesWindowHel iTerm2ShellEditViewSessionScriptsProfilesWindowHelpA100% C-zshDOCKERк 881dispatch(Sjob);DEV (docker)₴2-zsh883dispatch(Sjob);Log: :info('[TextRelayService] Successfully dispatched message', ["message_id'=> SmessageId,end diffscreenpipe"О 84-zsh*5ec2-user@ip-10-30-1...O 86Thu 28 May 11:20:29T81ec2-user@ip-10-30-140-...$7Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory usedDetected deprecations in useRule set"@PHP74Migration"(they will stop working in next major release):is deprecated. Use- Rule set"@PHP80Migration""@PHP7x4Migration"instead.is deprecated.Use "@PHP8x®Migration" instead.- Rule set"@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.- Rule set "@PHP83Migration" is deprecated.Use "@PHP8x3Migration" instead.- Rule set "@PHP84Migration" is deprecated.Use"@PHP8x4Migration" instead.What's next:Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1Learn more at [URL_WITH_CREDENTIALS] is deprecated. Use"@PHP7x4Migration" instead.- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x®Migration" instead.- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration"instead.- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.What's next:Try Docker Debug for seamless, persistent debugging tools in any container or image » docker debug docker_1amp_1Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $...
|
81493
|
NULL
|
NULL
|
NULL
|
|
81493
|
2828
|
2
|
2026-05-28T08:20:23.991351+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956423991_m1.jpg...
|
iTerm2
|
-zsh
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
⌥⌘1
-zsh...
|
[{"role":"AXTextArea","text [{"role":"AXTextArea","text":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5698 files in 51.755 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $","depth":4,"on_screen":true,"value":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5698 files in 51.755 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $","is_focused":true},{"role":"AXRadioButton","text":"DOCKER","depth":2,"bounds":{"left":0.0,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.004166667,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"DEV (docker)","depth":2,"bounds":{"left":0.140625,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.14479166,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"-zsh","depth":2,"bounds":{"left":0.28125,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.28541666,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe\"","depth":2,"bounds":{"left":0.421875,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.42604166,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"-zsh","depth":2,"bounds":{"left":0.5625,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.56666666,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-129-190:~ (-zsh)","depth":2,"bounds":{"left":0.7027778,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.70694447,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-140-255:~ (-zsh)","depth":2,"bounds":{"left":0.84305555,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.8472222,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"⌥⌘1","depth":1,"bounds":{"left":0.9548611,"top":0.032222223,"width":0.03888889,"height":0.018888889},"on_screen":true,"automation_id":"_NS:8","role_description":"text"},{"role":"AXStaticText","text":"-zsh","depth":1,"bounds":{"left":0.48819444,"top":0.033333335,"width":0.022916667,"height":0.017777778},"on_screen":true,"role_description":"text"}]...
|
6911656891139555327
|
-690278898522900323
|
idle
|
accessibility
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
⌥⌘1
-zsh...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81492
|
2829
|
1
|
2026-05-28T08:20:21.157147+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956421157_m2.jpg...
|
iTerm2
|
-zsh
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
⌥⌘1
-zsh...
|
[{"role":"AXTextArea","text [{"role":"AXTextArea","text":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5698 files in 51.755 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $","depth":4,"on_screen":true,"value":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5698 files in 51.755 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $","is_focused":true},{"role":"AXRadioButton","text":"DOCKER","depth":2,"bounds":{"left":0.27027926,"top":1.0,"width":0.06732048,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.27227393,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"DEV (docker)","depth":2,"bounds":{"left":0.33759972,"top":1.0,"width":0.06732048,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.33959442,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"-zsh","depth":2,"bounds":{"left":0.40492022,"top":1.0,"width":0.06732048,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.4069149,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe\"","depth":2,"bounds":{"left":0.4722407,"top":1.0,"width":0.06732048,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.4742354,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"-zsh","depth":2,"bounds":{"left":0.53956115,"top":1.0,"width":0.06715426,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.5415558,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-129-190:~ (-zsh)","depth":2,"bounds":{"left":0.60671544,"top":1.0,"width":0.06715426,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.6087101,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-140-255:~ (-zsh)","depth":2,"bounds":{"left":0.67386967,"top":1.0,"width":0.06715426,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.67586434,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"⌥⌘1","depth":1,"bounds":{"left":0.7273936,"top":1.0,"width":0.01861702,"height":-0.023144484},"on_screen":true,"automation_id":"_NS:8","role_description":"text"},{"role":"AXStaticText","text":"-zsh","depth":1,"bounds":{"left":0.50398934,"top":1.0,"width":0.010970744,"height":-0.02394259},"on_screen":true,"role_description":"text"}]...
|
6911656891139555327
|
-690278898522900323
|
idle
|
accessibility
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
⌥⌘1
-zsh...
|
81490
|
NULL
|
NULL
|
NULL
|
|
81491
|
2828
|
1
|
2026-05-28T08:19:49.795167+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956389795_m1.jpg...
|
iTerm2
|
docker
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
ec2-user@ip-10-30-140-255:~ (-zsh)
Close Tab
⌥⌘1
docker...
|
[{"role":"AXTextArea","text [{"role":"AXTextArea","text":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 3621/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░] 63%","depth":4,"on_screen":true,"value":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 3621/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░] 63%","is_focused":true},{"role":"AXRadioButton","text":"DOCKER","depth":2,"bounds":{"left":0.0,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.004166667,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"DEV (docker)","depth":2,"bounds":{"left":0.140625,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.14479166,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"docker","depth":2,"bounds":{"left":0.28125,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.28541666,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe\"","depth":2,"bounds":{"left":0.421875,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.42604166,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"-zsh","depth":2,"bounds":{"left":0.5625,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.56666666,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-129-190:~ (-zsh)","depth":2,"bounds":{"left":0.7027778,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.70694447,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-140-255:~ (-zsh)","depth":2,"bounds":{"left":0.84305555,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.8472222,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"⌥⌘1","depth":1,"bounds":{"left":0.9548611,"top":0.032222223,"width":0.03888889,"height":0.018888889},"on_screen":true,"automation_id":"_NS:8","role_description":"text"},{"role":"AXStaticText","text":"docker","depth":1,"bounds":{"left":0.4826389,"top":0.033333335,"width":0.034027778,"height":0.017777778},"on_screen":true,"role_description":"text"}]...
|
-8225350262170580515
|
-690279173400807287
|
idle
|
accessibility
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
ec2-user@ip-10-30-140-255:~ (-zsh)
Close Tab
⌥⌘1
docker...
|
81488
|
NULL
|
NULL
|
NULL
|
|
81490
|
2829
|
0
|
2026-05-28T08:19:20.714955+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956360714_m2.jpg...
|
iTerm2
|
docker
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
ec2-user@ip-10-30-140-255:~ (-zsh)
Close Tab
⌥⌘1
docker...
|
[{"role":"AXTextArea","text [{"role":"AXTextArea","text":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 0/5698 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0%","depth":4,"on_screen":true,"value":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 0/5698 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0%","is_focused":true},{"role":"AXRadioButton","text":"DOCKER","depth":2,"bounds":{"left":0.27027926,"top":1.0,"width":0.06732048,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.27227393,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"DEV (docker)","depth":2,"bounds":{"left":0.33759972,"top":1.0,"width":0.06732048,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.33959442,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"docker","depth":2,"bounds":{"left":0.40492022,"top":1.0,"width":0.06732048,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.4069149,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe\"","depth":2,"bounds":{"left":0.4722407,"top":1.0,"width":0.06732048,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.4742354,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"-zsh","depth":2,"bounds":{"left":0.53956115,"top":1.0,"width":0.06715426,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.5415558,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-129-190:~ (-zsh)","depth":2,"bounds":{"left":0.60671544,"top":1.0,"width":0.06715426,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.6087101,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-140-255:~ (-zsh)","depth":2,"bounds":{"left":0.67386967,"top":1.0,"width":0.06715426,"height":-0.042298436},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.67586434,"top":1.0,"width":0.005319149,"height":-0.04549086},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"⌥⌘1","depth":1,"bounds":{"left":0.7273936,"top":1.0,"width":0.01861702,"height":-0.023144484},"on_screen":true,"automation_id":"_NS:8","role_description":"text"},{"role":"AXStaticText","text":"docker","depth":1,"bounds":{"left":0.5013298,"top":1.0,"width":0.016289894,"height":-0.02394259},"on_screen":true,"role_description":"text"}]...
|
837512287160996845
|
-690278898388682615
|
idle
|
accessibility
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
ec2-user@ip-10-30-140-255:~ (-zsh)
Close Tab
⌥⌘1
docker...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81489
|
2828
|
0
|
2026-05-28T08:19:19.591814+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956359591_m1.jpg...
|
iTerm2
|
docker
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
ec2-user@ip-10-30-140-255:~ (-zsh)
Close Tab
⌥⌘1
docker...
|
[{"role":"AXTextArea","text [{"role":"AXTextArea","text":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.","depth":4,"on_screen":true,"value":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.","is_focused":true},{"role":"AXRadioButton","text":"DOCKER","depth":2,"bounds":{"left":0.0,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.004166667,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"DEV (docker)","depth":2,"bounds":{"left":0.140625,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.14479166,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"docker","depth":2,"bounds":{"left":0.28125,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.28541666,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe\"","depth":2,"bounds":{"left":0.421875,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.42604166,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"-zsh","depth":2,"bounds":{"left":0.5625,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.56666666,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-129-190:~ (-zsh)","depth":2,"bounds":{"left":0.7027778,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.70694447,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-140-255:~ (-zsh)","depth":2,"bounds":{"left":0.84305555,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.8472222,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"⌥⌘1","depth":1,"bounds":{"left":0.9548611,"top":0.032222223,"width":0.03888889,"height":0.018888889},"on_screen":true,"automation_id":"_NS:8","role_description":"text"},{"role":"AXStaticText","text":"docker","depth":1,"bounds":{"left":0.4826389,"top":0.033333335,"width":0.034027778,"height":0.017777778},"on_screen":true,"role_description":"text"}]...
|
1529312617094683139
|
-690278898388682615
|
idle
|
accessibility
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
ec2-user@ip-10-30-140-255:~ (-zsh)
Close Tab
⌥⌘1
docker...
|
81488
|
NULL
|
NULL
|
NULL
|
|
81488
|
NULL
|
0
|
2026-05-28T08:18:49.471568+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956329471_m1.jpg...
|
iTerm2
|
docker
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
ec2-user@ip-10-30-140-255:~ (-zsh)
Close Tab
⌥⌘1
docker...
|
[{"role":"AXTextArea","text [{"role":"AXTextArea","text":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.","depth":4,"on_screen":true,"value":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.","is_focused":true},{"role":"AXRadioButton","text":"DOCKER","depth":2,"bounds":{"left":0.0,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.004166667,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"DEV (docker)","depth":2,"bounds":{"left":0.140625,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.14479166,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"docker","depth":2,"bounds":{"left":0.28125,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.28541666,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe\"","depth":2,"bounds":{"left":0.421875,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.42604166,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"-zsh","depth":2,"bounds":{"left":0.5625,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.56666666,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-129-190:~ (-zsh)","depth":2,"bounds":{"left":0.7027778,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.70694447,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-140-255:~ (-zsh)","depth":2,"bounds":{"left":0.84305555,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.8472222,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"⌥⌘1","depth":1,"bounds":{"left":0.9548611,"top":0.032222223,"width":0.03888889,"height":0.018888889},"on_screen":true,"automation_id":"_NS:8","role_description":"text"},{"role":"AXStaticText","text":"docker","depth":1,"bounds":{"left":0.4826389,"top":0.033333335,"width":0.034027778,"height":0.017777778},"on_screen":true,"role_description":"text"}]...
|
1529312617094683139
|
-690278898388682615
|
idle
|
accessibility
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
ec2-user@ip-10-30-140-255:~ (-zsh)
Close Tab
⌥⌘1
docker...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81486
|
2826
|
35
|
2026-05-28T08:18:18.107258+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956298107_m1.jpg...
|
iTerm2
|
-zsh
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
⌥⌘1
-zsh...
|
[{"role":"AXTextArea","text [{"role":"AXTextArea","text":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $","depth":4,"on_screen":true,"value":"Last login: Wed May 27 12:49:32 on ttys012\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\n\nPoetry could not find a pyproject.toml file in /Users/lukas or its parents\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nAlready up to date.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service\nSwitched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd\ndocker exec -it docker_lamp_1 bash -c \"mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini\"\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 supervisorctl restart all\njiminny-worker-processing-3:jiminny-worker-processing-3_00: stopped\njiminny-worker-processing-1:jiminny-worker-processing-1_00: stopped\njiminny-worker-processing-2:jiminny-worker-processing-2_00: stopped\njiminny-worker-processing-4:jiminny-worker-processing-4_00: stopped\njiminny-worker-processing-5:jiminny-worker-processing-5_00: stopped\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: stopped\nworker:worker_00: stopped\nworker-analytics:worker-analytics_00: stopped\nworker-audio:worker-audio_00: stopped\nworker-calendar:worker-calendar_00: stopped\nworker-conferences:worker-conferences_00: stopped\nworker-crm-sync:worker-crm-sync_00: stopped\nworker-crm-update:worker-crm-update_00: stopped\nworker-download:worker-download_00: stopped\nworker-emails:worker-emails_00: stopped\nworker-es-update:worker-es-update_00: stopped\nworker-nudges:worker-nudges_00: stopped\nartisan-schedule:artisan-schedule_00: stopped\nartisan-schedule:artisan-schedule_00: started\njiminny-worker-processing-1:jiminny-worker-processing-1_00: started\njiminny-worker-processing-2:jiminny-worker-processing-2_00: started\njiminny-worker-processing-3:jiminny-worker-processing-3_00: started\njiminny-worker-processing-4:jiminny-worker-processing-4_00: started\njiminny-worker-processing-5:jiminny-worker-processing-5_00: started\njiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00: started\nworker:worker_00: started\nworker-analytics:worker-analytics_00: started\nworker-audio:worker-audio_00: started\nworker-calendar:worker-calendar_00: started\nworker-conferences:worker-conferences_00: started\nworker-crm-sync:worker-crm-sync_00: started\nworker-crm-update:worker-crm-update_00: started\nworker-download:worker-download_00: started\nworker-emails:worker-emails_00: started\nworker-es-update:worker-es-update_00: started\nworker-nudges:worker-nudges_00: started\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\ndocker exec -it docker_lamp_1 php -v\nPHP 8.5.5 (cli) (built: Apr 22 2026 01:25:22) (NTS)\nCopyright (c) The PHP Group\nBuilt by https://github.com/docker-library/php\nZend Engine v4.5.5, Copyright (c) Zend Technologies\n with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n\nFixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nerror: Your local changes to the following files would be overwritten by checkout:\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Services/Mail/TextRelayService.php\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ttests/Unit/Services/Mail/TextRelayServiceTest.php\nPlease commit your changes or stash them before you switch branches.\nAborting\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master\nM\u0000\u0000\u0000\u0000\u0000\u0000\t.env.local\nM\u0000\u0000\u0000\u0000\u0000\u0000\tapp/Console/Commands/JiminnyDebugCommand.php\nM\u0000\u0000\u0000\u0000\u0000\u0000\tconfig/logging.php\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull\nremote: Enumerating objects: 97, done.\nremote: Counting objects: 100% (97/97), done.\nremote: Compressing objects: 100% (27/27), done.\nremote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)\nUnpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.\nFrom github.com:jiminny/app\n f1ccf9be50..890e429206 master -> origin/master\n ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members\n ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing\nUpdating f1ccf9be50..890e429206\nFast-forward\n app/Services/Mail/TextRelayService.php | 6 +++---\n tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--\n 2 files changed, 14 insertions(+), 5 deletions(-)\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay\nSwitched to a new branch 'JY-20915-fix-missing-header-text-relay'\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update\naws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin https://438740370364.dkr.ecr.us-east-2.amazonaws.com\nLogin Succeeded\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\nlatest: Pulling from jiminny/app/qa\nDigest: sha256:92b2c3b1ce5badf9f7add1f42efe3636e3d8ef50ee1b1fd66f7c7dfc539cbf3c\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:latest\ndocker pull 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\narm64v8-latest: Pulling from jiminny/app/qa\nDigest: sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6\nStatus: Image is up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\n\nWhat's next:\n View a summary of image vulnerabilities and recommendations → docker scout quickview 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latest\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix\ndocker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff \nPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.5\nLoaded config default from \".php-cs-fixer.dist.php\".\nRunning analysis on 7 cores with 10 files per process.\n 5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n 1) app/Services/Mail/TextRelayService.php (statement_indentation)\n ---------- begin diff ----------\n--- /home/jiminny/app/Services/Mail/TextRelayService.php\n+++ /home/jiminny/app/Services/Mail/TextRelayService.php\n@@ -67,7 +67,7 @@\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n \n-// dispatch($job);\n+ // dispatch($job);\n \n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n\n ----------- end diff -----------\n\n\nFixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used\n\nDetected deprecations in use (they will stop working in next major release):\n- Rule set \"@PHP74Migration\" is deprecated. Use \"@PHP7x4Migration\" instead.\n- Rule set \"@PHP80Migration\" is deprecated. Use \"@PHP8x0Migration\" instead.\n- Rule set \"@PHP81Migration\" is deprecated. Use \"@PHP8x1Migration\" instead.\n- Rule set \"@PHP82Migration\" is deprecated. Use \"@PHP8x2Migration\" instead.\n- Rule set \"@PHP83Migration\" is deprecated. Use \"@PHP8x3Migration\" instead.\n- Rule set \"@PHP84Migration\" is deprecated. Use \"@PHP8x4Migration\" instead.\n\nWhat's next:\n Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1\n Learn more at https://docs.docker.com/go/debug-cli/\nlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $","is_focused":true},{"role":"AXRadioButton","text":"DOCKER","depth":2,"bounds":{"left":0.0,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.004166667,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"DEV (docker)","depth":2,"bounds":{"left":0.140625,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.14479166,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"-zsh","depth":2,"bounds":{"left":0.28125,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.28541666,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe\"","depth":2,"bounds":{"left":0.421875,"top":0.05888889,"width":0.140625,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.42604166,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"-zsh","depth":2,"bounds":{"left":0.5625,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.56666666,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-129-190:~ (-zsh)","depth":2,"bounds":{"left":0.7027778,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.70694447,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"ec2-user@ip-10-30-140-255:~ (-zsh)","depth":2,"bounds":{"left":0.84305555,"top":0.05888889,"width":0.14027777,"height":0.026666667},"on_screen":true,"role_description":"radio button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close Tab","depth":3,"bounds":{"left":0.8472222,"top":0.06333333,"width":0.011111111,"height":0.017777778},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"⌥⌘1","depth":1,"bounds":{"left":0.9548611,"top":0.032222223,"width":0.03888889,"height":0.018888889},"on_screen":true,"automation_id":"_NS:8","role_description":"text"},{"role":"AXStaticText","text":"-zsh","depth":1,"bounds":{"left":0.48819444,"top":0.033333335,"width":0.022916667,"height":0.017777778},"on_screen":true,"role_description":"text"}]...
|
1935207407041476744
|
-654245978201116535
|
click
|
accessibility
|
NULL
|
Last login: Wed May 27 12:49:32 on ttys012
Poetry Last login: Wed May 27 12:49:32 on ttys012
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
Poetry could not find a pyproject.toml file in /Users/lukas or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ app
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-strict-casting-text-relay-service
Switched to a new branch 'JY-20915-fix-strict-casting-text-relay-service'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5697/5697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5697 files in 55.554 seconds, 799.06 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-strict-casting-text-relay-service) $ co master
M .env.local
M app/Console/Commands/JiminnyDebugCommand.php
M config/logging.php
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 97 (delta 69), reused 95 (delta 69), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 14.08 KiB | 150.00 KiB/s, done.
From github.com:jiminny/app
f1ccf9be50..890e429206 master -> origin/master
ce9abde868..3800efb7ea JY-20905-tool-search-members -> origin/JY-20905-tool-search-members
ad6ace97b9..b3659b1290 JY-20910-schedule-parallel-update-target-processing -> origin/JY-20910-schedule-parallel-update-target-processing
Updating f1ccf9be50..890e429206
Fast-forward
app/Services/Mail/TextRelayService.php | 6 +++---
tests/Unit/Services/Mail/TextRelayServiceTest.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20915-fix-missing-header-text-relay
Switched to a new branch 'JY-20915-fix-missing-header-text-relay'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ make docker-update
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20915-fix-missing-header-text-relay) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.5
Loaded config default from ".php-cs-fixer.dist.php".
Running analysis on 7 cores with 10 files per process.
5698/5698 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Services/Mail/TextRelayService.php (statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Services/Mail/TextRelayService.php
+++ /home/jiminny/app/Services/Mail/TextRelayService.php
@@ -67,7 +67,7 @@
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
-// dispatch($job);
+ // dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
----------- end diff -----------
Fixed 1 of 5698 files in 84.046 seconds, 701.18 MB memory used
Detected deprecations in use (they will stop working in next major release):
- Rule set "@PHP74Migration" is deprecated. Use "@PHP7x4Migration" instead.
- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x0Migration" instead.
- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.
- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.
- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration" instead.
- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] (-zsh)
Close Tab
⌥⌘1
-zsh...
|
81485
|
NULL
|
NULL
|
NULL
|
|
81487
|
NULL
|
0
|
2026-05-28T08:18:16.931051+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956296931_m2.jpg...
|
iTerm2
|
-zsh
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
18PhpStormEV faVsco,ls ~View$2 JY-20915-fix-mis:Co 18PhpStormEV faVsco,ls ~View$2 JY-20915-fix-mis:CoocRunToolsWindow©InternetMessagelnterface.ph/©MailChannelService.phpo Textrelkysewice.onMeetingGeneratorNotification#OAuth2Playbooks—KecallA© SyneMailbox.php& Dockerfile© TextRelayServiceTest.phpE env.productionclass TextReLayServiceSi tan featin reomatteamSnessage = $service-susers_nessages->get(Smailbox, Snessageld);Sheaders = Smessage->getPayload(->getHeaders():StrategyStreaminga TeamTelephonyaUserPilot©lpapiClient.php©IpapiService.phpPlanhatService.php© PlaybackService.php© PlaybackVideoOnlyService.php© PlaybookCategoryService.php©PlaylistGeneratorinterface.phpSoriginalTo = null;Sto = null;if (Sheader->name u= "X-Gn-Original-To') €} elseif (Sheader->nane aan "To") (Srecipient = SoriginalTo ?? Sto;1f (Srecipient las null) (Snatches = $this-›natchesExpectedRecipient(Srecipient, SexpectedAlias, SexpectedHost);(/ Sanitize PII by renoving plus-tag content for loggingSsanitizedRecipient = explode( separator:***, Srecipient) (0]:•[TextRelayService) Refused message', E"message_id' = Snessageld,=InitialFrontendState.php© Jiminny.phpA SF giminny@localhost]A console [PROD]s consoe leu.[2826-05-28 87:47:50) Local. INFO: Sparans(startHistoryId) => 35902198C0/05-0215-444217826-85-28 87:47:58 Local.wFu: Snessagchzscoryid*:*87439623-3deb-4827-aBcf-b862aec93289*}trace10: [CREDIT_CARD]-a8cт-0862aec93789-%7876-85o28 87rS8.5omuftsoarang[historyTypes] => nessageAddedstartHistorytoll50%2ph67/306-7359-172h-6789-40a7456066550 "trace Sa".-62a0Ro6p-1669-hcR4-h1de-R/Bcecchaat*[2826-85-28 07:50:58] Local.INF0: SnessageHistory{"correlation_id":"ebf74306-735e-472b-D780-f9a7f56e465S*, "trace_1d":*b2a98e4e-d669-4c04-b1de-843cecc6a601*}2924-05-28 07-55-17 1 1oc01 THSn• Snanane[nistoryTypes) => nessageAddedAwAtU&AtAAuTAl = 26002-4d4a-b84b-a8531ca414a7*}(2826-05-28 87:SS:12] Local.INF0: SmessageHistory{"correlation_id":"25971837-31f1-431b-ad59-e898eb48b0Sf*, "trace_id*:"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7*}[2826-85-28 08:00:53] Local. INF0: Sparansmistorvnvoes => nessagendded[startHistoryid) => 359025toace aexeiaioowesor.oSce.nsyiwhichtheierhooR neohieSa oetet shacsadel stomX6c82479-7042-1566.05cc-h529269c24h7m[2826-05-28 88:05:23] Local.INFO: SparansTO0У L7oo nu co moy ti-lo.leU TextRelayServiceTest~Cascaderner hensemwiet+0.What about this. Scems the + sign is in email. Wil ti still work and howYes, this will work correctly. Let me trace through the logic with this exact emaillo incader valtes carchen444700 Syaloryideoeuowon.copheM soler onoirsscarchent teehoeLye lhorssotrhit8elrdoskottheernw.com"thos,chict:Xwloihy.cos=ssXr9th.os1/ 3. Strip plus tag fron local partstoca Basc= exolodel",catch=a14447700157786...Ol"catch-al// 4. Compare alías: 'catch-all' ma= 'catch-all' 7 - returns truThen in EnsilTextRelay Job, parseRecipient() uses the To header directly and the regex \d+).1d+). fa-2A-20-- the & prefixbelore tne phoné numbers is stripped oy parsekeciptentintoentities wnich prepends + iiselt anyway.Everything works end-to-end. Now you just need to re-apply the to header fallback fix so these messagesvice,0ho #l187-716Fix is back in place and the temporary headers oresent disgnostic logging is removed. The tests already retlectthis logic from earlier. You're good to deploy.Ask anything (XOL)-@ eodtAdhotv• Cwwoderemorenuitire%2 4 space:...
|
NULL
|
-7263199782662481242
|
NULL
|
click
|
ocr
|
NULL
|
18PhpStormEV faVsco,ls ~View$2 JY-20915-fix-mis:Co 18PhpStormEV faVsco,ls ~View$2 JY-20915-fix-mis:CoocRunToolsWindow©InternetMessagelnterface.ph/©MailChannelService.phpo Textrelkysewice.onMeetingGeneratorNotification#OAuth2Playbooks—KecallA© SyneMailbox.php& Dockerfile© TextRelayServiceTest.phpE env.productionclass TextReLayServiceSi tan featin reomatteamSnessage = $service-susers_nessages->get(Smailbox, Snessageld);Sheaders = Smessage->getPayload(->getHeaders():StrategyStreaminga TeamTelephonyaUserPilot©lpapiClient.php©IpapiService.phpPlanhatService.php© PlaybackService.php© PlaybackVideoOnlyService.php© PlaybookCategoryService.php©PlaylistGeneratorinterface.phpSoriginalTo = null;Sto = null;if (Sheader->name u= "X-Gn-Original-To') €} elseif (Sheader->nane aan "To") (Srecipient = SoriginalTo ?? Sto;1f (Srecipient las null) (Snatches = $this-›natchesExpectedRecipient(Srecipient, SexpectedAlias, SexpectedHost);(/ Sanitize PII by renoving plus-tag content for loggingSsanitizedRecipient = explode( separator:***, Srecipient) (0]:•[TextRelayService) Refused message', E"message_id' = Snessageld,=InitialFrontendState.php© Jiminny.phpA SF giminny@localhost]A console [PROD]s consoe leu.[2826-05-28 87:47:50) Local. INFO: Sparans(startHistoryId) => 35902198C0/05-0215-444217826-85-28 87:47:58 Local.wFu: Snessagchzscoryid*:*87439623-3deb-4827-aBcf-b862aec93289*}trace10: [CREDIT_CARD]-a8cт-0862aec93789-%7876-85o28 87rS8.5omuftsoarang[historyTypes] => nessageAddedstartHistorytoll50%2ph67/306-7359-172h-6789-40a7456066550 "trace Sa".-62a0Ro6p-1669-hcR4-h1de-R/Bcecchaat*[2826-85-28 07:50:58] Local.INF0: SnessageHistory{"correlation_id":"ebf74306-735e-472b-D780-f9a7f56e465S*, "trace_1d":*b2a98e4e-d669-4c04-b1de-843cecc6a601*}2924-05-28 07-55-17 1 1oc01 THSn• Snanane[nistoryTypes) => nessageAddedAwAtU&AtAAuTAl = 26002-4d4a-b84b-a8531ca414a7*}(2826-05-28 87:SS:12] Local.INF0: SmessageHistory{"correlation_id":"25971837-31f1-431b-ad59-e898eb48b0Sf*, "trace_id*:"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7*}[2826-85-28 08:00:53] Local. INF0: Sparansmistorvnvoes => nessagendded[startHistoryid) => 359025toace aexeiaioowesor.oSce.nsyiwhichtheierhooR neohieSa oetet shacsadel stomX6c82479-7042-1566.05cc-h529269c24h7m[2826-05-28 88:05:23] Local.INFO: SparansTO0У L7oo nu co moy ti-lo.leU TextRelayServiceTest~Cascaderner hensemwiet+0.What about this. Scems the + sign is in email. Wil ti still work and howYes, this will work correctly. Let me trace through the logic with this exact emaillo incader valtes carchen444700 Syaloryideoeuowon.copheM soler onoirsscarchent teehoeLye lhorssotrhit8elrdoskottheernw.com"thos,chict:Xwloihy.cos=ssXr9th.os1/ 3. Strip plus tag fron local partstoca Basc= exolodel",catch=a14447700157786...Ol"catch-al// 4. Compare alías: 'catch-all' ma= 'catch-all' 7 - returns truThen in EnsilTextRelay Job, parseRecipient() uses the To header directly and the regex \d+).1d+). fa-2A-20-- the & prefixbelore tne phoné numbers is stripped oy parsekeciptentintoentities wnich prepends + iiselt anyway.Everything works end-to-end. Now you just need to re-apply the to header fallback fix so these messagesvice,0ho #l187-716Fix is back in place and the temporary headers oresent disgnostic logging is removed. The tests already retlectthis logic from earlier. You're good to deploy.Ask anything (XOL)-@ eodtAdhotv• Cwwoderemorenuitire%2 4 space:...
|
81484
|
NULL
|
NULL
|
NULL
|
|
81485
|
2826
|
34
|
2026-05-28T08:18:16.818706+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956296818_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"15","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","depth":4,"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
1764831529811932805
|
-8307856800295171704
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81484
|
2827
|
45
|
2026-05-28T08:18:13.655213+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956293655_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.37632978,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"15","depth":4,"bounds":{"left":0.3856383,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39694148,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.40425533,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"bounds":{"left":0.7293883,"top":0.10055866,"width":0.007978723,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7390292,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7463431,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","depth":4,"bounds":{"left":0.43051863,"top":0.09736632,"width":0.32280585,"height":0.90263367},"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
1764831529811932805
|
-8307856800295171704
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81483
|
2826
|
33
|
2026-05-28T08:18:13.551111+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956293551_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"15","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-987438372797753690
|
-6438878488507806805
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification...
|
81481
|
NULL
|
NULL
|
NULL
|
|
81482
|
2827
|
44
|
2026-05-28T08:18:10.964729+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956290964_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
8043719072324535154
|
-8628527368849355612
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
PhpStormEV faVsco,ls ~Vie Project: faVsco.js, menu
PhpStormEV faVsco,ls ~View$2 JY-20915-fix-missCootRunWindow©InternetMessagelnterface.phy©MailChannelService.phpo Textrelkysewice. oneMeetingGeneratorNotification#OAuth2PlaybooksRecallAl© TextRelayServiceTest.phpStrategyStreaminga TeamTelephonyaUserPilot#Webhook© AbstractService.php©ActivityProviderFactory.php©ActivityService.php© ApiResponseService.phpeeonaraneacarhes oool©InsightSeatService.php© InstantMeetingService.php@ IntercomService.phpE env.productiona, funten rercrenter/remeteSnessage = $service-susers_nessages->get(Smailbox, Snessageld);Sheaders = Snessage->getPayLoad()->getHeaders():SoriginalTo = nutl;Sto = null;1f (Sheader->name• a= "X-6m-Original-To') (} elseif (Sheader->nane uue "To') €Sreciptent = SoriginalTo 2? Sto;1f (Srecipient [== null) 4Smatches = $this->matchesExpectedRecipient(Srecipient, $expectedAlias, $expectedHost)=© Jiminny.phpA SF giminny@localhost][2826-05-28 87:47:50) Local. INFO: Sparans(startHistoryId) => 359021-correlatzon10:%aC0/1105-C2415-4442-17826-85-28 87:47:58 Local.wFu: SnessagchzscoryA console [PROD]# consoe leu.1d":*87f39623-3deb-4827-a8cf-b862acc93289**trace10: [CREDIT_CARD]-a8cт-0862aec93789-17876-85528 87-S8857omuotfteSoamane[historyTypes] => nessageAddedstartHistorytoll50%2"ph67/306-7350-172h-6789-4017456066550 "tлaса 36".-62a0Rp6p-1669-hcR4-h1de-R/3ceccba6at*[2826-85-28 07:50:58] Local.INF0: SnessageHistory{"correlation_id":"ebf74306-735e-472b-D780-f9a7f56e465S*, "trace_1d*:*b2a98e4e-d669-4c04-b1de-843ceçc6a601*}2924-05-28 07-55-17 1 1oc01 THSn• Snanane[nistoryTypes) => nessageAdded(startHistoryId] => 359921-4d4a-b84b-a8531ca414a7*}(2826-05-28 87:SS:12] Local.INF0: SmessageHistory{"correlation_id":"25971837-31f1-431b-ad59-e898eb48b0Sf*, "trace_id*:"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7*}[2826-85-28 08:00:53] Local.INF0: Sparansmistorvnvoes > messageadded[startHistoryid) => 359025connel atson o""naosynoo%ctheyerark -chn chcoaiieuooace aeuei aioowe ser.oSec-hsyiuhichthuierhooR neohieSa oetet shacsadel stomX6c82479-7042-1566.05cc-h529269c24h7m[2826-85-28 88:05:23] Local.INFO: Sparans7o0sLXoo Inu co moy ti-lo.lU TextRelayServiceTest~Cascaderner hensemwiet+0.What about this. Seems the + sign is in email. Wil ti still work and howYes, this will work correctly. Let me trace through the logic with this exact emailo tncader valtos catchen2444700 SyxPorlheeeRoosueonnrcopheM soler onoirt8carchenttocho0LyaPors.cra8808.0o.wot.tdwrinw.conthos,chict:Xwloihy.cos=ssXr9th.os1/ 3. Strip plus tag fron local partstoca Basc= exolodel",catch=a14447700157786...Ol"carch-alt// 4. Compare alías: 'catch-all' ma= 'catch-all' 7 - returns truThen in EnsilTextRelay job, parseRecipient() uses the To header directly and the regex \d+).1d+). [a-zA-20-- the * prefixbelore tne phoné numbers is stripped oy parsekeciotentintoentities wnich prepends + ilselt anyway.Everything works end-to-end. Now you just need to re-apply the to header falliback fix so these messagesice.0ho #l187-718Fix is back in place and the temporary headers oresent disgnostic logging is removed. The tests already retlcctthis logic from earlier. You're good to deploy.Ask anything (XOL)-@ eodtAdhotvKtwodeurlete186:32 UTF-8• C2 4 space:...
|
81479
|
NULL
|
NULL
|
NULL
|
|
81481
|
2826
|
32
|
2026-05-28T08:18:10.862620+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956290862_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpDOCKER₴81DEV ( SlackFileEditViewGoHistoryWindowHelpDOCKER₴81DEV (docker)₴2-zshscreenpipe"Digest:sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6Status: Imageis up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/‹438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latestWhat's next:View a summary ofimage vulnerabilities and recommendations docker scoutquickviewlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix--config=.php-cs-fixer.dist.plPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminskiand contributors.PHP runtime: 8.5.5Loadedconfigdefault from ".php-cs-fixer.dist.php"Running analysis on 7cores with 10files perprocess.5698/5698100%1) app/Services/Mail/TextRelayService.php (statement_indentation)begin diff/home/jiminny/app/Services/Mail/TextRelayService.php+++/home/jiminny/app/Services/Mail/TextRelayService.php-67,7 +67,7 @eSjob = new EmailTextRelay(SmessageId, SrelayedText);Sjob-›onQueue(Constants: :QUEUE_EMAILS);dispatch($job);dispatch($job);Log: :info(' [TextRelayService]Successfully dispatched message', ["message_id'= SmessageId,end diffFixed 1 of 5698 files in 84.046 seconds, 701.18 MBmemory usedDetected deprecations in use (they will stop working in next major release)- Rule set"@PHP74Migration" is deprecated. Use"@PHP7x4Migration"instead.- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x®Migration" instead.- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration"instead.- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.What's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image »Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-• •HomeDMsActivityFilesLater..•More+ED→Jiminny... vw Starrea& platform-backend-...platform-inner-teamChannels# ai-chapter# alerts# backend# bugs# confusion-clinic# donut_time# engineering# general# happy_birthday# jbu-team-info# jiminny-bg# platform-tickets# product_launches# random# releases# support# thank-yous# the_people_of_jimi...• Direct messages& Petko Kashinski% Galya Dimitrova&. Stefka Stoyanova: Todor StamatovStalivan Ganraiou100% <78• Thu 28 May 11:18:10Describe what you are looking for* & platform-inner-team& 106 0• MessagesP Channel OverviewMore v+Yesterday ~Resolve rrir v.oiotPreview in SlackStatusBacklogPriority= MediumAssigneeUnassignedAs of yesterday at 6:20 PM RefreshOpen in Jira*+ SummarizeToday ~NewNikolay Nikolov 10:52 AMФикс за пускане на remote commands за staging:https://github.com/jiminny/app/pull/12132#12132 Fix stage profile for remote commandsrunJIRA: JY-XXXXDeployment notes:• NoneComments1V1jiminny/app| May 26th Added by GitHubMessage & platform-inner-team...
|
NULL
|
8939761280494406748
|
NULL
|
click
|
ocr
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpDOCKER₴81DEV ( SlackFileEditViewGoHistoryWindowHelpDOCKER₴81DEV (docker)₴2-zshscreenpipe"Digest:sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6Status: Imageis up to date for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/‹438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latestWhat's next:View a summary ofimage vulnerabilities and recommendations docker scoutquickviewlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix--config=.php-cs-fixer.dist.plPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminskiand contributors.PHP runtime: 8.5.5Loadedconfigdefault from ".php-cs-fixer.dist.php"Running analysis on 7cores with 10files perprocess.5698/5698100%1) app/Services/Mail/TextRelayService.php (statement_indentation)begin diff/home/jiminny/app/Services/Mail/TextRelayService.php+++/home/jiminny/app/Services/Mail/TextRelayService.php-67,7 +67,7 @eSjob = new EmailTextRelay(SmessageId, SrelayedText);Sjob-›onQueue(Constants: :QUEUE_EMAILS);dispatch($job);dispatch($job);Log: :info(' [TextRelayService]Successfully dispatched message', ["message_id'= SmessageId,end diffFixed 1 of 5698 files in 84.046 seconds, 701.18 MBmemory usedDetected deprecations in use (they will stop working in next major release)- Rule set"@PHP74Migration" is deprecated. Use"@PHP7x4Migration"instead.- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x®Migration" instead.- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration"instead.- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.What's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image »Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-• •HomeDMsActivityFilesLater..•More+ED→Jiminny... vw Starrea& platform-backend-...platform-inner-teamChannels# ai-chapter# alerts# backend# bugs# confusion-clinic# donut_time# engineering# general# happy_birthday# jbu-team-info# jiminny-bg# platform-tickets# product_launches# random# releases# support# thank-yous# the_people_of_jimi...• Direct messages& Petko Kashinski% Galya Dimitrova&. Stefka Stoyanova: Todor StamatovStalivan Ganraiou100% <78• Thu 28 May 11:18:10Describe what you are looking for* & platform-inner-team& 106 0• MessagesP Channel OverviewMore v+Yesterday ~Resolve rrir v.oiotPreview in SlackStatusBacklogPriority= MediumAssigneeUnassignedAs of yesterday at 6:20 PM RefreshOpen in Jira*+ SummarizeToday ~NewNikolay Nikolov 10:52 AMФикс за пускане на remote commands за staging:https://github.com/jiminny/app/pull/12132#12132 Fix stage profile for remote commandsrunJIRA: JY-XXXXDeployment notes:• NoneComments1V1jiminny/app| May 26th Added by GitHubMessage & platform-inner-team...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81480
|
2826
|
31
|
2026-05-28T08:18:00.251289+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956280251_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"15","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","depth":4,"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
1764831529811932805
|
-8307856800295171704
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
81477
|
NULL
|
NULL
|
NULL
|
|
81479
|
2827
|
43
|
2026-05-28T08:18:00.149862+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956280149_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.37632978,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"15","depth":4,"bounds":{"left":0.3856383,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39694148,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.40425533,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"bounds":{"left":0.7293883,"top":0.10055866,"width":0.007978723,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7390292,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7463431,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","depth":4,"bounds":{"left":0.43051863,"top":0.09736632,"width":0.32280585,"height":0.90263367},"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
1764831529811932805
|
-8307856800295171704
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81477
|
2826
|
30
|
2026-05-28T08:17:50.920103+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956270920_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"15","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","depth":4,"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-8341700080930998891
|
-8235816798443288184
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81478
|
2827
|
42
|
2026-05-28T08:17:50.815333+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956270815_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
8043719072324535154
|
-8628527368849355612
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
PhpStorm$2 JY-20915-fix-m Project: faVsco.js, menu
PhpStorm$2 JY-20915-fix-miss©MailChannelService.phpMeetingGeneratorNotification#OAuth2PlaybooksRecallAlStrategyStreaminga TeamTelephonyaUserPilot#Webhook© AbstractService.php©ActivityProviderFactory.php©ActivityService.php©ApiResponseService.phpeeonaraneacarhes oool©InsightSeatService.php© InstantMeetingService.phpCootRunWindow© SyneMailbox.php© TextRelayServiceTest.phpE .env.production3: vane (unetton arereurentenv/romenteSnessage = $service-susers_nessages->get(Smailbox, Snessageld);Sheaders = Snessage->getPayLoad()->getHeaders():SoriginalTo = nutz:lSto = null;1f (Sheader->nameaas Xeol-urzethal-lo1 elseif (Sheader-»nane uns "To") €Sreciptent = SoriginalTo 2? Sto;Lf (Srecipient (== null) 4Smatches = $this->matchesExpectedRecipient(Srecipient, $expectedAlias, $expectedHost)'=© Jiminny.phpA SF giminny@localhost)[2826-05-28 87:47:50) Local. INFO: Sparans(startHistoryId) => 359021-correlatzon10:%aC0/1105-C2415-4442-17826-85-28 87:47:58 Local.wFu: SnessagchzscoryA console [PROD]# consoe leu.1d":*87f39623-3deb-4827-a8cf-b862acc93289**trace10: [CREDIT_CARD]-a8cт-0862aec93789-%17876-85528 87-S8857omuotfteSoamane[historyTypes] => nessageAddedstartHistorytoll50%2"ph67/306-7350-172h-6789-4017456066550 "tлaса 36".-62a0Rp6p-1669-hcR4-h1de-R/3ceccba6at*[2826-85-28 07:50:58] Local.INF0: SnessageHistory{"correlation_id":"ebf74306-735e-472b-b780-f9a7fS6e465S*,"trace_1d":*b2a98e4e-d669-4c04-b1de-843cecc6a601*}2924-05.28 87-55-17 1 1oc01 TNSh: Soanans[nistoryTypes) => nessageAdded(startHistoryId] => 359921-4d4a-b84b-a8531ca414a7*}(2826-05-28 87:SS:12] Local.INF0: SmessageHistory{"correlation_id":"25971837-31f1-431b-ad59-e898eb48b0Sf*, "trace_id*:"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7*}[2826-85-28 08:00:53] Local.INF0: Sparansmistorvivoes => messageadded[startHistoryid) => 359025connel atson o""naosynoo%ctheyerark -chn chcoaiieuooace aeuei aioowe ser.oSec-hsyiuhichthuOierhoR RRohieSaioetst SrassadelsromX6c82470-7042-4566.05cc-h52026Ac24h7"[2826-05-28 88:05:23] Local.INFO: SparansCascaderner hensemwietTO0У L78• Thu 28 May 11:17:50U TextRelayServiceTest~+0.What about this. Seems the + sign is in email. Wll ti still work and howYes, this will work correctly. Let me trace through the logic with this exact emaillo tncader valtos catchen2444700 SyxPorlheeeRoosueonnrcopheM soler onoirt8carchenttocho0LyaPors.cra8808.0o.wot.tdwrinw.conhos,chict:Xwoihnv.cosesX1419thh.os1/ 3. Strip plus tag fron local partstoca Base= exolodel"*,catch=a14447700.57706...e"carch-alt// 4. Compare alías: 'catch-all' ma= 'catch-all' 7 - returns truSo isforcurrentEnvi ronsentü returns tre and the messace docaeds to oe disoatchedThen in EnsilTextRelay job, parseRecipient() uses the To header directly and the regex \8+).1d+).(a-zA-20-- the & prefixbelore tne phoné numbers is stripped oy parsekeciotentintoentities wnich prepends + ilselt anyway.Everything works end-to-end. Now you just need to re-apply the to header falliback fix so these messagesice.0ho #1187-716Fix is back in place and the temporary headers oresent disgnostic logging is removed. The tests already retlcctthis logic from earlier. You're good to deploy.Ask anything (XOL)-@ eodtAdhotvKwoeunate186:32 UTF-8• C2 4 space:...
|
81474
|
NULL
|
NULL
|
NULL
|
|
81476
|
2827
|
41
|
2026-05-28T08:17:31.308113+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956251308_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.37632978,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"15","depth":4,"bounds":{"left":0.3856383,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39694148,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.40425533,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"bounds":{"left":0.7293883,"top":0.10055866,"width":0.007978723,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7390292,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7463431,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","depth":4,"bounds":{"left":0.43051863,"top":0.09736632,"width":0.32280585,"height":0.90263367},"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
1764831529811932805
|
-8307856800295171704
|
idle
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
81474
|
NULL
|
NULL
|
NULL
|
|
81475
|
2826
|
29
|
2026-05-28T08:17:29.184326+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956249184_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"15","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","depth":4,"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
1764831529811932805
|
-8307856800295171704
|
idle
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
81473
|
NULL
|
NULL
|
NULL
|
|
81474
|
2827
|
40
|
2026-05-28T08:17:01.003763+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956221003_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.37632978,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"15","depth":4,"bounds":{"left":0.3856383,"top":0.10055866,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39694148,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.40425533,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"bounds":{"left":0.7293883,"top":0.10055866,"width":0.007978723,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7390292,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7463431,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","depth":4,"bounds":{"left":0.43051863,"top":0.09736632,"width":0.32280585,"height":0.90263367},"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
1764831529811932805
|
-8307856800295171704
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
15
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81473
|
2826
|
28
|
2026-05-28T08:16:58.099313+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956218099_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
17
Previous Highlighted Error...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.015277778,"height":0.02111111},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"17","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.019444445,"height":0.02111111},"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.015277778,"height":0.025555555},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
2797364124384554827
|
-7623060321892881446
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
17
Previous Highlighted Error
SlackFileEditViewGoHistoryWindowHelpDOCKER• ₴1DEV (docker)₴2-zshscreenpipe"Digest:sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6Status: Imageis up todate for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/q438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latestWhat's next:View a summary of image vulnerabilities and recommendations → docker scoutquickviewlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix--config=.php-cs-fixer.dist.plPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminskiand contributors.PHP runtime: 8.5.5Loadedconfigdefault from ".php-cs-fixer.dist.php"Running analysis on 7cores with 10files per process.5698/5698100%1) app/Services/Mail/TextRelayService.php (statement_indentation)begin diff/home/jiminny/app/Services/Mail/TextRelayService.php+++/home/jiminny/app/Services/Mail/TextRelayService.php-67,7 +67,7 @eSjob = new EmailTextRelay(SmessageId, SrelayedText);Sjob-›onQueue(Constants: :QUEUE_EMAILS);dispatch($job);dispatch($job);Log: :info(' [TextRelayService]Successfully dispatched message', ["message_id'= SmessageId,end diffFixed 1 of 5698 files in 84.046 seconds, 701.18 MBmemory usedDetected deprecations in use (they will stop working in next major release)- Rule set"@PHP74Migration" is deprecated. Use"@PHP7x4Migration"instead.- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x®Migration" instead.- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration"instead.- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.What's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image »Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-• •HomeDMsActivityFilesLater..•More+ED→Jiminny... vw Starrea& platform-backend-...platform-inner-teamChannels# ai-chapter# alerts# backend# bugs# confusion-clinic# donut_time# engineering# general# happy_birthday# jbu-team-info# jiminny-bg# platform-tickets# product_launches# random# releases# support# thank-yous# the_people_of_jimi...• Direct messages& Petko Kashinski% Galya Dimitrova&. Stefka Stoyanova: Todor StamatovStalivan Ganraiou100% <78 • Thu 28 May 11:16:57Describe what you are looking for* & platform-inner-team& 106 0• MessagesP Channel OverviewMore v+Yesterday ~Resolve rrir v.oiotPreview in SlackStatusBacklogPriority= MediumAssigneeUnassignedAs of yesterday at 6:20 PM RefreshOpen in Jira*+ SummarizeToday ~NewNikolay Nikolov 10:52 AMФикс за пускане на remote commands за staging:https://github.com/jiminny/app/pull/12132#12132 Fix stage profile for remote commandsrunJIRA: JY-XXXXDeployment notes:• NoneComments1V1jiminny/app| May 26th Added by GitHubMessage & platform-inner-team...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81472
|
2827
|
39
|
2026-05-28T08:16:57.995978+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956217995_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
17
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.00731383,"height":0.0},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"17","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.00930851,"height":0.0},"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.00731383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.006981383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"bounds":{"left":0.7293883,"top":0.10055866,"width":0.007978723,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7390292,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7463431,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","depth":4,"bounds":{"left":0.43051863,"top":0.09736632,"width":0.32280585,"height":0.90263367},"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
4195952255238992687
|
-8812277550477751928
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
17
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}...
|
81470
|
NULL
|
NULL
|
NULL
|
|
81471
|
2826
|
27
|
2026-05-28T08:16:51.964608+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956211964_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
17
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.015277778,"height":0.02111111},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"17","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.019444445,"height":0.02111111},"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.015277778,"height":0.025555555},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.014583333,"height":0.025555555},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","depth":4,"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-4729423357167171668
|
-8235799205988284024
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
17
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
81468
|
NULL
|
NULL
|
NULL
|
|
81470
|
2827
|
38
|
2026-05-28T08:16:51.859578+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956211859_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
17
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8374335,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"bounds":{"left":0.85272604,"top":0.019952115,"width":0.062832445,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.00731383,"height":0.0},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"17","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.00930851,"height":0.0},"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.00731383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.006981383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Mail;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\Log;\nuse Jiminny\\Component\\Queue\\Constants;\nuse Jiminny\\Jobs\\Mailbox\\EmailTextRelay;\nuse Jiminny\\Models\\TextRelay;\nuse Google\\Service\\Gmail as GoogleGmail;\n\nclass TextRelayService\n{\n public function __construct()\n {\n $credentials = storage_path('text-relay.json');\n\n abort_unless(file_exists($credentials), 422);\n\n putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);\n }\n\n /**\n * Fetch the latest messages since the last sync.\n */\n public function sync(): array\n {\n $mailbox = config('jiminny.google_text_user');\n\n $expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';\n $expectedHost = config('jiminny.google_text_host');\n\n Log::info('[TextRelayService] Starting sync', [\n 'mailbox' => $mailbox,\n 'expected_alias' => $expectedAlias,\n 'expected_host' => $expectedHost,\n ]);\n\n $service = $this->getService($mailbox);\n\n $messageHistory = $this->getHistory($service);\n $messageIds = [];\n\n foreach ($messageHistory as $histories) {\n $messages = $histories->messagesAdded ?? [];\n\n foreach ($messages as $message) {\n $messageId = $message->message->id;\n\n if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {\n continue;\n }\n\n $relayedText = TextRelay::where('email_provider_id', $messageId)->first();\n\n if ($relayedText === null) {\n $relayedText = TextRelay::create([\n 'email_provider' => TextRelay::PROVIDER_GSUITE,\n 'email_provider_id' => $messageId,\n 'status' => TextRelay::STATUS_PROCESSING,\n ]);\n }\n\n $job = new EmailTextRelay($messageId, $relayedText);\n $job->onQueue(Constants::QUEUE_EMAILS);\n\n dispatch($job);\n\n Log::info('[TextRelayService] Successfully dispatched message', [\n 'message_id' => $messageId,\n 'text_relay_id' => $relayedText->id,\n 'queue' => Constants::QUEUE_EMAILS,\n ]);\n\n $messageIds[] = $messageId;\n }\n }\n\n Log::info('[TextRelayService] Sync completed', [\n 'mailbox' => $mailbox,\n 'messages_processed' => count($messageIds),\n 'message_ids' => array_slice($messageIds, 0, 10),\n ]);\n\n return $messageIds;\n }\n\n public function getHistory(GoogleGmail $service): array\n {\n $pageToken = null;\n $topic = config('jiminny.google_text_relay_topic');\n $messages = [];\n $historyId = \\Cache::get($topic);\n\n // If we have no history stored, WatchMailboxEvents must not have run yet :/\n if ($historyId == false) {\n $historyId = $this->refreshHistoryPoint($topic);\n }\n\n $params = [\n 'historyTypes' => 'messageAdded',\n 'startHistoryId' => $historyId,\n ];\n\n do {\n try {\n if ($pageToken) {\n $params['pageToken'] = $pageToken;\n }\n\n $historyResponse = $service->users_history->listUsersHistory(\n config('jiminny.google_text_user'),\n $params\n );\n\n $this->setHistoryPoint($topic, (int) $historyResponse->historyId);\n\n if ($historyResponse->getHistory()) {\n $messages = array_merge($messages, $historyResponse->getHistory());\n $pageToken = $historyResponse->getNextPageToken();\n }\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to fetch Gmail history', [\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n } while ($pageToken);\n\n return $messages;\n }\n\n protected function setHistoryPoint(string $topic, int $historyPoint): Carbon\n {\n $expiresAt = now()->addDay();\n\n \\Cache::put($topic, $historyPoint, $expiresAt);\n\n return $expiresAt;\n }\n\n public function getService(string $mailbox): GoogleGmail\n {\n $client = new \\Google_Client();\n $client->useApplicationDefaultCredentials();\n $client->addScope(GoogleGmail::GMAIL_MODIFY);\n $client->setAccessType('offline');\n $client->setSubject($mailbox);\n\n return new GoogleGmail($client);\n }\n\n public function refreshHistoryPoint(string $topic): int\n {\n $mailbox = config('jiminny.google_text_user');\n $service = $this->getService($mailbox);\n\n $watchRequest = new GoogleGmail\\WatchRequest();\n $watchRequest->setLabelIds(['INBOX']);\n $watchRequest->setLabelFilterAction('include');\n $watchRequest->setTopicName($topic);\n\n $watchResponse = $service->users->watch($mailbox, $watchRequest);\n\n //$expiryTimestamp = $watchResponse->expiration / 1000;\n $historyPoint = (int) $watchResponse->historyId;\n\n $this->setHistoryPoint($topic, $historyPoint);\n\n return $historyPoint;\n }\n\n private function isForCurrentEnvironment(\n GoogleGmail $service,\n string $mailbox,\n string $messageId,\n string $expectedAlias,\n string $expectedHost\n ): bool {\n try {\n $message = $service->users_messages->get($mailbox, $messageId);\n $headers = $message->getPayload()->getHeaders();\n\n $originalTo = null;\n $to = null;\n\n foreach ($headers as $header) {\n if ($header->name === 'X-Gm-Original-To') {\n $originalTo = $header->value;\n } elseif ($header->name === 'To') {\n $to = $header->value;\n }\n }\n\n $recipient = $originalTo ?? $to;\n\n if ($recipient !== null) {\n $matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);\n\n if (! $matches) {\n // Sanitize PII by removing plus-tag content for logging\n $sanitizedRecipient = explode('+', $recipient)[0];\n Log::info('[TextRelayService] Refused message', [\n 'message_id' => $messageId,\n 'original_to_sanitized' => $sanitizedRecipient,\n ]);\n }\n\n return $matches;\n }\n\n Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [\n 'message_id' => $messageId,\n ]);\n } catch (\\Exception $e) {\n Log::error('[TextRelayService] Failed to inspect message', [\n 'message_id' => $messageId,\n 'exception' => $e->getMessage(),\n ]);\n \\Sentry::captureException($e);\n }\n\n return false;\n }\n\n private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool\n {\n $parts = explode('@', $recipient, 2);\n\n if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {\n return false;\n }\n\n $localBase = explode('+', $parts[0], 2)[0];\n\n return strcasecmp($localBase, $expectedAlias) === 0;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"bounds":{"left":0.7293883,"top":0.10055866,"width":0.007978723,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7390292,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7463431,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","depth":4,"bounds":{"left":0.43051863,"top":0.09736632,"width":0.32280585,"height":0.90263367},"on_screen":true,"value":"[2026-05-28 07:47:50] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:47:50] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"9acc7103-e275-4442-a80e-72ca0233ad9d\",\"trace_id\":\"87f39623-3deb-4827-a0cf-b862aec93209\"}\n[2026-05-28 07:50:57] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:50:58] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"ebf74306-735e-472b-b780-f9a7f56e4655\",\"trace_id\":\"b2a98e4e-d669-4c04-b1de-043cecc6a601\"}\n[2026-05-28 07:55:17] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359021\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 07:55:17] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"25971837-31f1-431b-ad59-e890eb40b05f\",\"trace_id\":\"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7\"}\n[2026-05-28 08:00:53] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:00:54] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"da957797-f328-4bf7-8a33-961c0cca120c\",\"trace_id\":\"34c82f30-39f2-45cf-95cc-b520260c2fb3\"}\n[2026-05-28 08:05:23] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:05:24] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"c5339dcc-46c1-45a4-81f9-ede0203ab266\",\"trace_id\":\"627196cf-0a09-465a-ab3e-10e546adfcde\"}\n[2026-05-28 08:10:44] local.INFO: $params \nArray\n(\n [historyTypes] => messageAdded\n [startHistoryId] => 359025\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}\n[2026-05-28 08:10:44] local.INFO: $messageHistory \nArray\n(\n)\n {\"correlation_id\":\"8667713e-79c8-46a6-b5a4-b13351d287da\",\"trace_id\":\"52ec740a-b685-4b96-abda-8e5ab1057ea6\"}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-4729423357167171668
|
-8235799205988284024
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
17
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Mail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\Mailbox\EmailTextRelay;
use Jiminny\Models\TextRelay;
use Google\Service\Gmail as GoogleGmail;
class TextRelayService
{
public function __construct()
{
$credentials = storage_path('text-relay.json');
abort_unless(file_exists($credentials), 422);
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $credentials);
}
/**
* Fetch the latest messages since the last sync.
*/
public function sync(): array
{
$mailbox = config('jiminny.google_text_user');
$expectedAlias = config('jiminny.deploy_region') === 'eu' ? 'catch-all-eu' : 'catch-all';
$expectedHost = config('jiminny.google_text_host');
Log::info('[TextRelayService] Starting sync', [
'mailbox' => $mailbox,
'expected_alias' => $expectedAlias,
'expected_host' => $expectedHost,
]);
$service = $this->getService($mailbox);
$messageHistory = $this->getHistory($service);
$messageIds = [];
foreach ($messageHistory as $histories) {
$messages = $histories->messagesAdded ?? [];
foreach ($messages as $message) {
$messageId = $message->message->id;
if (! $this->isForCurrentEnvironment($service, $mailbox, $messageId, $expectedAlias, $expectedHost)) {
continue;
}
$relayedText = TextRelay::where('email_provider_id', $messageId)->first();
if ($relayedText === null) {
$relayedText = TextRelay::create([
'email_provider' => TextRelay::PROVIDER_GSUITE,
'email_provider_id' => $messageId,
'status' => TextRelay::STATUS_PROCESSING,
]);
}
$job = new EmailTextRelay($messageId, $relayedText);
$job->onQueue(Constants::QUEUE_EMAILS);
dispatch($job);
Log::info('[TextRelayService] Successfully dispatched message', [
'message_id' => $messageId,
'text_relay_id' => $relayedText->id,
'queue' => Constants::QUEUE_EMAILS,
]);
$messageIds[] = $messageId;
}
}
Log::info('[TextRelayService] Sync completed', [
'mailbox' => $mailbox,
'messages_processed' => count($messageIds),
'message_ids' => array_slice($messageIds, 0, 10),
]);
return $messageIds;
}
public function getHistory(GoogleGmail $service): array
{
$pageToken = null;
$topic = config('jiminny.google_text_relay_topic');
$messages = [];
$historyId = \Cache::get($topic);
// If we have no history stored, WatchMailboxEvents must not have run yet :/
if ($historyId == false) {
$historyId = $this->refreshHistoryPoint($topic);
}
$params = [
'historyTypes' => 'messageAdded',
'startHistoryId' => $historyId,
];
do {
try {
if ($pageToken) {
$params['pageToken'] = $pageToken;
}
$historyResponse = $service->users_history->listUsersHistory(
config('jiminny.google_text_user'),
$params
);
$this->setHistoryPoint($topic, (int) $historyResponse->historyId);
if ($historyResponse->getHistory()) {
$messages = array_merge($messages, $historyResponse->getHistory());
$pageToken = $historyResponse->getNextPageToken();
}
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to fetch Gmail history', [
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
} while ($pageToken);
return $messages;
}
protected function setHistoryPoint(string $topic, int $historyPoint): Carbon
{
$expiresAt = now()->addDay();
\Cache::put($topic, $historyPoint, $expiresAt);
return $expiresAt;
}
public function getService(string $mailbox): GoogleGmail
{
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(GoogleGmail::GMAIL_MODIFY);
$client->setAccessType('offline');
$client->setSubject($mailbox);
return new GoogleGmail($client);
}
public function refreshHistoryPoint(string $topic): int
{
$mailbox = config('jiminny.google_text_user');
$service = $this->getService($mailbox);
$watchRequest = new GoogleGmail\WatchRequest();
$watchRequest->setLabelIds(['INBOX']);
$watchRequest->setLabelFilterAction('include');
$watchRequest->setTopicName($topic);
$watchResponse = $service->users->watch($mailbox, $watchRequest);
//$expiryTimestamp = $watchResponse->expiration / 1000;
$historyPoint = (int) $watchResponse->historyId;
$this->setHistoryPoint($topic, $historyPoint);
return $historyPoint;
}
private function isForCurrentEnvironment(
GoogleGmail $service,
string $mailbox,
string $messageId,
string $expectedAlias,
string $expectedHost
): bool {
try {
$message = $service->users_messages->get($mailbox, $messageId);
$headers = $message->getPayload()->getHeaders();
$originalTo = null;
$to = null;
foreach ($headers as $header) {
if ($header->name === 'X-Gm-Original-To') {
$originalTo = $header->value;
} elseif ($header->name === 'To') {
$to = $header->value;
}
}
$recipient = $originalTo ?? $to;
if ($recipient !== null) {
$matches = $this->matchesExpectedRecipient($recipient, $expectedAlias, $expectedHost);
if (! $matches) {
// Sanitize PII by removing plus-tag content for logging
$sanitizedRecipient = explode('+', $recipient)[0];
Log::info('[TextRelayService] Refused message', [
'message_id' => $messageId,
'original_to_sanitized' => $sanitizedRecipient,
]);
}
return $matches;
}
Log::warning('[TextRelayService] Refused message: missing X-Gm-Original-To and To headers', [
'message_id' => $messageId,
]);
} catch (\Exception $e) {
Log::error('[TextRelayService] Failed to inspect message', [
'message_id' => $messageId,
'exception' => $e->getMessage(),
]);
\Sentry::captureException($e);
}
return false;
}
private function matchesExpectedRecipient(string $recipient, string $expectedAlias, string $expectedHost): bool
{
$parts = explode('@', $recipient, 2);
if (count($parts) !== 2 || strcasecmp($parts[1], $expectedHost) !== 0) {
return false;
}
$localBase = explode('+', $parts[0], 2)[0];
return strcasecmp($localBase, $expectedAlias) === 0;
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
6
Previous Highlighted Error
Next Highlighted Error
[2026-05-28 07:47:50] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:47:50] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"9acc7103-e275-4442-a80e-72ca0233ad9d","trace_id":"87f39623-3deb-4827-a0cf-b862aec93209"}
[2026-05-28 07:50:57] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:50:58] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"ebf74306-735e-472b-b780-f9a7f56e4655","trace_id":"b2a98e4e-d669-4c04-b1de-043cecc6a601"}
[2026-05-28 07:55:17] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359021
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 07:55:17] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"25971837-31f1-431b-ad59-e890eb40b05f","trace_id":"c3f63c2c-d21b-4d4a-b84b-a8531ca414a7"}
[2026-05-28 08:00:53] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:00:54] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"da957797-f328-4bf7-8a33-961c0cca120c","trace_id":"34c82f30-39f2-45cf-95cc-b520260c2fb3"}
[2026-05-28 08:05:23] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:05:24] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"c5339dcc-46c1-45a4-81f9-ede0203ab266","trace_id":"627196cf-0a09-465a-ab3e-10e546adfcde"}
[2026-05-28 08:10:44] local.INFO: $params
Array
(
[historyTypes] => messageAdded
[startHistoryId] => 359025
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
[2026-05-28 08:10:44] local.INFO: $messageHistory
Array
(
)
{"correlation_id":"8667713e-79c8-46a6-b5a4-b13351d287da","trace_id":"52ec740a-b685-4b96-abda-8e5ab1057ea6"}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
81469
|
2827
|
37
|
2026-05-28T08:16:49.898635+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956209898_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.09740692,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-3150964534923304660
|
-4304507549388960332
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
PhpStormViewCootRurTOOI-WindowFV faVsco.|s ~$ JY-20915-fix-misproidet) Kernelphp© SyncMailbox.phpockhrhtt© InternetMessagelnterface.ph© MailChannelService.phgTextRelayServiceTest.php3.env.productionclass TextRelayServiceo Textrelkysewice.ond MeetingGeneratorda Notificationên OAuth2in Playbooks—KeCaLA—oeownyJ StrategyStreaminga Teama [EMAIL]@ ApiResponseService.ohdCeonarsneasaries oodclineehCaatswies donC InstantMeetingService.phgc IntercomService.phgC IpapiClient.phpc lpapiService.phpC ParticipantShareService.phg© PlanhatService.php© PlaybackService.phpPlaybackVideoOnlyService.pho© PlaybookCategoryService.php© PlaylistGeneratorinterface.php© ResolveTeamCrmConnection.ph© SimoleThrottleService.ohd© SlackService.oho© SoclalAccountService.oho)© SoftPhoneService.oho©) TeamDeactivatedService.oho©) TeamOwnerService.ohoC) TeamService.ohoC) TranscodeParameterResolver.ohCUserService.ohdC Uuidloho> M Traitc@ UseCases181182183uuise ValaationMo halnore nhr@ tnitislGrantondGtnto nho88555852553eillliminnv nhnA Olen nhipobtaeatuuetzondaueysnscogyroangeyeegne seoezeee. 12sservace & schis-serservace suazlooxSwatchRequest = new Google6naiz\WatchRequestoSwatchRequest->setLabelIds(['INB0X'])smechkeoues csstthewecnterwrconcluotSexonrunhisdino= SwatchResponse->expiration / 1000;ShistoryPosint =ointl SwarcheesoonseoshictomydSthis->setHistoryPoint(Stopic, ShistoryPoint);return ShistoryPoint;private function isForCurrentEnvironmentGoogleGnail Sserviceetasnn Chasihaystring SexpectedAliasstring SexpectedHos:): boor ttoy lSnessage = Sservice->users nessages->get(Smailbox, Smessageld)sheaders = saessage->oexrayload ->oecheadersorSoniginalTo = null;Rencetforeach (Sheaders as Sheader)Sif (Sheaden->nane aa= «X-6n-0cfoinal-To") 2Smatches = Sthis->natchesExpectedRecipient(Sheader->value, SexpectedALias.} elseif (Sheader->name aa= 'To') 4nethandon.susimeeSrecipient = Soriginalto ?? Sto:if (Srecipient !as nulb)Snatches = Sthis->matchesExpectedRecipient(Srecipient, SexpectedALias, SexpectedHostv Accept Fle x- X Reject File ox ci4 CnatchesiSF (iminny@localhost)HS.Jocal jiminny@blocalhost)& console [PROD)# consoe leu.2826-85-28 87:47:501 Local.INF0: Sparansnzscorylypes = messageaddecstartHistoryId) => 3599219aC0 //105-02715-4442-3886-12638233809701d":*87f39623-3deb-4827-aBcf-b862acc93289**17826-85-28 87:47:58 Local.wFu: Snessagchzscorytrace10: [CREDIT_CARD]-a8cт-0862aec93789-%17876-85528 87-S8857omuotfteSoamaneIhistorylypes => messageAddecstartHistorytoll50%2*ebf74306-735e-472b-b788-f9a7f56e4655*, "trace_1d":"b2a98e4e-d669-4c84-b1de-843cecc6а681*)2826-85-28 87-58-5811 JocnlTWEn: Snessadels stom{"correlation_id":"ebf74306-735e-472b-b788-f9a7f56e4655*,"trace_1d":"b2a98e4e-d669-4C04-b1de-843cecc6a681"}2924-05.28 87-55-17 1 1oc01 TNSh: SoananshistoryTypes => messageAddecAwAtU&AtAAuTAl = 26002-4d4a-b84b-a8531ca414a7"12826-85-28 87:55:171 Zocal.INF0: SmessageHistory#"correlation_id":"25971837-3141-431b-adS9-e898eb49beSf*, *trace_1d*:*c3463c2c-d21b-4d4a-b84b-a8531ca414a7"}(2826-85-28 88:88:531 Zocal, INF0: SparansArrav[historyTypesl => nessageAddedistartHistoruidl s 350029connel atson o""naosynoo%ctheyerark -chn chcoaiieuooace aeuei aioowe ser.oSec-hsyiuhichthuOierhoR RRohieSaioetst SrassadelsromX6c82479-7042-1566.05cc-h529269c24h7m2924-85.28 9R-95-271 1ocol TМSЛ• Soananeinu cowoy ti-lo.Cascadirner hensewiet+0.Winst about the. Shams the + cion is in emslWitistill work and hownYes, this will work correctly. Let me trace through the logic with this exact ema:oneioerwawue carchswewwoL720onsshwobl.n0o.ktw1oinnv.cos0 pho11 1. Split on €oirdecch- tuewbewtonsehototordoskolotorxrwetnnv.con"I1 2. Host check: 'txt.fiminny.com'11 3. Strip plus tag fron local partcatch-all[PHONE]...e- "catch-all/1 4. Compare alías: 'catch-all' mm 'catch-all' - returns truSo isForcurrentEnvi ronsentü returns true and the messade orocreds to be disoatchedThen in EnaflTextRelay job, parseRecipient() uses the To header directly and the regex \d+\.1d+\. [a-zA-20-- the + prefixoetore tne phone numoers is stipped or parschecipientintoentities, wiuch prepenos + iselt anyway.Everythina worke end-tosand. Now vou luet nesd to ranodly the To Thoader thinrck ir so these mosenaosaren't refused.pho #L182-218haytRelusarich.oorFix is back in place and the temporary headerspresent disgnostic logging is removed. The tests already reflectthis loae trom aartar. Youtre cnodito deoio1tile +23-12>Ask anything (XOL)- @ CodnAdhotvAcceot allKwindeurlahmest4 space...
|
81467
|
NULL
|
NULL
|
NULL
|
|
81468
|
2826
|
26
|
2026-05-28T08:16:49.793362+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-28/1779 /Users/lukas/.screenpipe/data/data/2026-05-28/1779956209793_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelayService.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
17
Previous Highlighted Error...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20915-fix-missing-header-text-relay, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20915-fix-missing-header-text-relay","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"TextRelayServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'TextRelayServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.015277778,"height":0.02111111},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"17","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.019444445,"height":0.02111111},"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.015277778,"height":0.025555555},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
2797364124384554827
|
-7623060321892881446
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20915-fix-missing-head Project: faVsco.js, menu
JY-20915-fix-missing-header-text-relay, menu
Start Listening for PHP Debug Connections
TextRelayServiceTest
Run 'TextRelayServiceTest'
Debug 'TextRelayServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
17
Previous Highlighted Error
SlackFileEditViewGoHistoryWindowHelpDOCKERO ₴1DEV (docker)₴2-zshscreenpipe"Digest:sha256:d6b7ebd9b71c0480b909d77fceada3df720c6594e4c853228765509b36f52db6Status: Imageis up todate for 438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/q438740370364.dkr.ecr.us-east-2.amazonaws.com/jiminny/app/qa:arm64v8-latestWhat's next:View a summary of image vulnerabilities and recommendations → docker scoutquickviewlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix--config=.php-cs-fixer.dist.plPHP CS Fixer 3.95.1 Adalbertus by Fabien Potencier, Dariusz Ruminskiand contributors.PHP runtime: 8.5.5Loadedconfigdefault from ".php-cs-fixer.dist.php"Running analysis on 7cores with 10files per process.5698/5698100%1) app/Services/Mail/TextRelayService.php (statement_indentation)begin diff/home/jiminny/app/Services/Mail/TextRelayService.php+++/home/jiminny/app/Services/Mail/TextRelayService.php-67,7 +67,7 @eSjob = new EmailTextRelay(SmessageId, SrelayedText);Sjob-›onQueue(Constants: :QUEUE_EMAILS);dispatch($job);dispatch($job);Log: :info(' [TextRelayService]Successfully dispatched message', ["message_id'= SmessageId,end diffFixed 1 of 5698 files in 84.046 seconds, 701.18 MBmemory usedDetected deprecations in use (they will stop working in next major release)- Rule set"@PHP74Migration" is deprecated. Use"@PHP7x4Migration"instead.- Rule set "@PHP80Migration" is deprecated. Use "@PHP8x®Migration" instead.- Rule set "@PHP81Migration" is deprecated. Use "@PHP8x1Migration" instead.- Rule set "@PHP82Migration" is deprecated. Use "@PHP8x2Migration" instead.- Rule set "@PHP83Migration" is deprecated. Use "@PHP8x3Migration"instead.- Rule set "@PHP84Migration" is deprecated. Use "@PHP8x4Migration" instead.What's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image »Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20915-fix-missing-header-text-• •HomeDMsActivityFilesLater..•More+ED→Jiminny... vw Starrea& platform-backend-...platform-inner-teamChannels# ai-chapter# alerts# backend# bugs# confusion-clinic# donut_time# engineering# general# happy_birthday# jbu-team-info# jiminny-bg# platform-tickets# product_launches# random# releases# support# thank-yous# the_people_of_jimi...• Direct messages& Petko Kashinski% Galya Dimitrova&. Stefka Stoyanova: Todor StamatovStalivan Ganraiou100% <78• Thu 28 May 11:16:49Describe what you are looking for®* & platform-inner-team& 106 0• MessagesP Channel OverviewMore v+Yesterday ~Resolve rrir v.oiotPreview in SlackStatusBacklogPriority= MediumAssigneeUnassignedAs of yesterday at 6:20 PM RefreshOpen in Jira*+ SummarizeToday ~NewNikolay Nikolov 10:52 AMФикс за пускане на remote commands за staging:https://github.com/jiminny/app/pull/12132#12132 Fix stage profile for remote commandsrunJIRA: JY-XXXXDeployment notes:• NoneComments1V1jiminny/app| May 26th Added by GitHubMessage & platform-inner-team...
|
NULL
|
NULL
|
NULL
|
NULL
|