From bfd4fbdd2f8224592876485813f07f2943a5a8d5 Mon Sep 17 00:00:00 2001 From: bernardhanna Date: Tue, 19 May 2026 15:02:10 +0100 Subject: [PATCH 1/2] chore(support): default Gmail subject prefix to codeweek-support Align code default with production env (SUPPORT_GMAIL_SUBJECT_PREFIX=codeweek-support). Tickets must include that text in the subject; no Gmail label required. Co-authored-by: Cursor --- app/Console/Commands/Support/GmailTestCommand.php | 2 +- config/support_gmail.php | 3 ++- tests/Unit/Support/SupportGmailPollQueryTest.php | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/Console/Commands/Support/GmailTestCommand.php b/app/Console/Commands/Support/GmailTestCommand.php index de74bddd8..032aeec54 100644 --- a/app/Console/Commands/Support/GmailTestCommand.php +++ b/app/Console/Commands/Support/GmailTestCommand.php @@ -39,7 +39,7 @@ public function handle( 'processing_mode' => 'manual_test', 'gmail_message_id' => 'test-'.SupportJson::correlationId(), 'gmail_thread_id' => 'test-thread-'.time(), - 'subject' => trim((string) config('support_gmail.subject_prefix', '[CodeWeek Support]')).' [TEST] Support copilot dry run', + 'subject' => trim((string) config('support_gmail.subject_prefix', 'codeweek-support')).' [TEST] Support copilot dry run', 'raw_message' => $message, 'forwarded_by_email' => $from, 'original_sender_email' => $from, diff --git a/config/support_gmail.php b/config/support_gmail.php index 50420fe7d..b6e0e7b5e 100644 --- a/config/support_gmail.php +++ b/config/support_gmail.php @@ -20,7 +20,8 @@ 'query' => env('SUPPORT_GMAIL_QUERY', 'newer_than:90d'), // Only ingest messages whose subject contains this text (recommended over labels). - 'subject_prefix' => env('SUPPORT_GMAIL_SUBJECT_PREFIX', '[CodeWeek Support]'), + // Production uses: SUPPORT_GMAIL_SUBJECT_PREFIX=codeweek-support + 'subject_prefix' => env('SUPPORT_GMAIL_SUBJECT_PREFIX', 'codeweek-support'), // Google OAuth client JSON: paste full JSON from Google Cloud (preferred on Forge; survives deploys). 'credentials' => env('SUPPORT_GMAIL_CREDENTIALS'), diff --git a/tests/Unit/Support/SupportGmailPollQueryTest.php b/tests/Unit/Support/SupportGmailPollQueryTest.php index 65ed7a116..95787e021 100644 --- a/tests/Unit/Support/SupportGmailPollQueryTest.php +++ b/tests/Unit/Support/SupportGmailPollQueryTest.php @@ -9,22 +9,22 @@ final class SupportGmailPollQueryTest extends TestCase { public function test_builds_query_with_subject_prefix(): void { - config()->set('support_gmail.subject_prefix', '[CodeWeek Support]'); + config()->set('support_gmail.subject_prefix', 'codeweek-support'); config()->set('support_gmail.query', 'newer_than:90d'); $this->assertSame( - 'subject:"[CodeWeek Support]" newer_than:90d', + 'subject:codeweek-support newer_than:90d', SupportGmailPollQuery::resolve(), ); } public function test_skips_duplicate_subject_filter_when_query_already_has_one(): void { - config()->set('support_gmail.subject_prefix', '[CodeWeek Support]'); - config()->set('support_gmail.query', 'subject:"[CodeWeek Support]" newer_than:7d'); + config()->set('support_gmail.subject_prefix', 'codeweek-support'); + config()->set('support_gmail.query', 'subject:codeweek-support newer_than:7d'); $this->assertSame( - 'subject:"[CodeWeek Support]" newer_than:7d', + 'subject:codeweek-support newer_than:7d', SupportGmailPollQuery::resolve(), ); } From a2c23809d2095d4eb06cbe1e67af1e8fc340a0bc Mon Sep 17 00:00:00 2001 From: bernardhanna Date: Tue, 19 May 2026 15:10:13 +0100 Subject: [PATCH 2/2] feat(support): schedule Gmail poll every five minutes when enabled Automates ticket ingestion and dry-run workflow without manual artisan poll. Co-authored-by: Cursor --- routes/console.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/routes/console.php b/routes/console.php index ff8de36fd..4a40e3f6b 100644 --- a/routes/console.php +++ b/routes/console.php @@ -38,3 +38,8 @@ Schedule::command('app:export-search-data-to-json')->dailyAt('2:00'); Schedule::command('events:generate-recurring')->dailyAt('01:00'); + +// Support Gmail copilot: ingest tickets by subject (codeweek-support), run dry-run, email for APPROVE. +Schedule::command('support:gmail:poll --max=10') + ->everyFiveMinutes() + ->when(fn () => (bool) config('support_gmail.enabled'));