From bd1b4bba2005453273a43ff76aa2768af241a5b6 Mon Sep 17 00:00:00 2001 From: Leon Morival Date: Tue, 11 Aug 2026 16:20:27 +0200 Subject: [PATCH] refactor: hardcode Bowli mobile scheme --- .env.example | 1 - .env.prod.example | 1 - app/Services/MobileDeepLink.php | 11 +++------- config/app.php | 2 -- .../EngagementReminderNotificationsTest.php | 21 ++++++------------- tests/Feature/PostReviewsControllerTest.php | 4 +--- tests/Feature/StravaConnectionTest.php | 4 +--- 7 files changed, 11 insertions(+), 33 deletions(-) diff --git a/.env.example b/.env.example index 0087ad1..99426fc 100644 --- a/.env.example +++ b/.env.example @@ -3,7 +3,6 @@ APP_ENV=local APP_KEY= APP_DEBUG=true APP_URL=http://localhost -APP_MOBILE_SCHEME=bowly APP_PORT=8003 APP_LOCALE=fr APP_FALLBACK_LOCALE=en diff --git a/.env.prod.example b/.env.prod.example index a690fc1..0a4b971 100644 --- a/.env.prod.example +++ b/.env.prod.example @@ -3,7 +3,6 @@ APP_ENV=production APP_KEY= APP_DEBUG=false APP_URL=https://dailyapi.leonmorival.xyz -APP_MOBILE_SCHEME=bowly APP_LOCALE=fr APP_FALLBACK_LOCALE=en APP_FAKER_LOCALE=fr_FR diff --git a/app/Services/MobileDeepLink.php b/app/Services/MobileDeepLink.php index 0dec334..0e46582 100644 --- a/app/Services/MobileDeepLink.php +++ b/app/Services/MobileDeepLink.php @@ -4,23 +4,18 @@ namespace App\Services; class MobileDeepLink { + private const string SCHEME = 'bowli'; + /** * @param array $query */ public static function to(string $path, array $query = []): string { - $url = sprintf('%s://%s', self::scheme(), ltrim($path, '/')); + $url = sprintf('%s://%s', self::SCHEME, ltrim($path, '/')); $queryString = http_build_query($query, '', '&', PHP_QUERY_RFC3986); return $queryString === '' ? $url : "{$url}?{$queryString}"; } - - private static function scheme(): string - { - $scheme = rtrim((string) config('app.mobile_scheme', 'bowly'), ':/'); - - return $scheme !== '' ? $scheme : 'bowly'; - } } diff --git a/config/app.php b/config/app.php index c44c1a1..753cb70 100644 --- a/config/app.php +++ b/config/app.php @@ -54,8 +54,6 @@ return [ 'url' => env('APP_URL', 'http://localhost'), - 'mobile_scheme' => env('APP_MOBILE_SCHEME', 'bowly'), - /* |-------------------------------------------------------------------------- | Application Timezone diff --git a/tests/Feature/EngagementReminderNotificationsTest.php b/tests/Feature/EngagementReminderNotificationsTest.php index 0d08d47..ab0042f 100644 --- a/tests/Feature/EngagementReminderNotificationsTest.php +++ b/tests/Feature/EngagementReminderNotificationsTest.php @@ -12,7 +12,6 @@ uses(RefreshDatabase::class); it('sends engagement reminders only to eligible mobile users', function () { app()->setLocale('fr'); - config()->set('app.mobile_scheme', 'dailymeal'); Http::fake([ 'https://exp.host/*' => Http::response([ @@ -63,15 +62,13 @@ it('sends engagement reminders only to eligible mobile users', function () { return $payload['to'] === 'ExponentPushToken[eligible]' && $payload['data']['type'] === 'engagement_reminder' && in_array($payload['data']['url'], [ - 'dailymeal://create', - 'dailymeal://profile/workouts?create=1', + 'bowli://create', + 'bowli://profile/workouts?create=1', ], true); }); }); it('uses the hard-coded localized reminder copy', function () { - config()->set('app.mobile_scheme', 'dailymeal'); - foreach (['fr', 'en'] as $locale) { app()->setLocale($locale); @@ -86,18 +83,12 @@ it('uses the hard-coded localized reminder copy', function () { expect($payload['title'])->toBeString()->not->toBeEmpty() ->and($payload['body'])->toBeString()->not->toBeEmpty() ->and($payload['data']['message_key'])->toBe($messageKey) - ->and($payload['data']['url'])->toBe("dailymeal://{$expectedPath}"); + ->and($payload['data']['url'])->toBe("bowli://{$expectedPath}"); } } }); -it('builds mobile deep links from the configured scheme', function () { - config()->set('app.mobile_scheme', 'dailymeal://'); - - expect(MobileDeepLink::to('/create'))->toBe('dailymeal://create') - ->and(MobileDeepLink::to('strava/callback', ['code' => 'abc 123']))->toBe('dailymeal://strava/callback?code=abc%20123'); - - config()->set('app.mobile_scheme', ''); - - expect(MobileDeepLink::to('create'))->toBe('bowly://create'); +it('builds mobile deep links with the Bowli scheme', function () { + expect(MobileDeepLink::to('/create'))->toBe('bowli://create') + ->and(MobileDeepLink::to('strava/callback', ['code' => 'abc 123']))->toBe('bowli://strava/callback?code=abc%20123'); }); diff --git a/tests/Feature/PostReviewsControllerTest.php b/tests/Feature/PostReviewsControllerTest.php index 45b202e..6a138db 100644 --- a/tests/Feature/PostReviewsControllerTest.php +++ b/tests/Feature/PostReviewsControllerTest.php @@ -43,8 +43,6 @@ it('creates one review per user for a meal post', function () { }); it('sends a push notification to the meal owner when another user comments on their meal', function () { - config()->set('app.mobile_scheme', 'dailymeal'); - Http::fake([ 'https://exp.host/*' => Http::response([ 'data' => [ @@ -79,7 +77,7 @@ it('sends a push notification to the meal owner when another user comments on th 'sound' => 'default', 'channelId' => 'default', 'data' => [ - 'url' => "dailymeal://meals/{$mealPost->id}", + 'url' => "bowli://meals/{$mealPost->id}", ], ], ]); diff --git a/tests/Feature/StravaConnectionTest.php b/tests/Feature/StravaConnectionTest.php index 4841b8f..bc589c4 100644 --- a/tests/Feature/StravaConnectionTest.php +++ b/tests/Feature/StravaConnectionTest.php @@ -38,8 +38,6 @@ it('returns a strava authorization url for the api callback', function () { }); it('redirects the strava web callback to the mobile app', function () { - config()->set('app.mobile_scheme', 'dailymeal'); - $query = http_build_query([ 'code' => 'authorization-code', 'scope' => 'read activity:read', @@ -48,7 +46,7 @@ it('redirects the strava web callback to the mobile app', function () { $this ->get("/strava/callback?{$query}") - ->assertRedirect("dailymeal://strava/callback?{$query}"); + ->assertRedirect("bowli://strava/callback?{$query}"); }); it('stores strava tokens from an authorization code', function () {