From 78d2783db897a9f70e86a75ba6c9fb0f880c33b3 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 4 Oct 2024 01:07:05 -0600 Subject: [PATCH] Fix push token for php8.2 --- .../Controllers/Api/ApiV1Dot1Controller.php | 6 ++-- app/Rules/ExpoPushTokenRule.php | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 app/Rules/ExpoPushTokenRule.php diff --git a/app/Http/Controllers/Api/ApiV1Dot1Controller.php b/app/Http/Controllers/Api/ApiV1Dot1Controller.php index 3741390e..31c2e866 100644 --- a/app/Http/Controllers/Api/ApiV1Dot1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Dot1Controller.php @@ -19,6 +19,7 @@ use App\Media; use App\Place; use App\Profile; use App\Report; +use App\Rules\ExpoPushTokenRule; use App\Services\AccountService; use App\Services\BouncerService; use App\Services\EmailService; @@ -48,7 +49,6 @@ use Jenssegers\Agent\Agent; use League\Fractal; use League\Fractal\Serializer\ArraySerializer; use Mail; -use NotificationChannels\Expo\ExpoPushToken; class ApiV1Dot1Controller extends Controller { @@ -1087,7 +1087,7 @@ class ApiV1Dot1Controller extends Controller abort_if($request->user()->status, 422, 'Cannot access this resource at this time'); $this->validate($request, [ - 'expo_token' => ['required', ExpoPushToken::rule()], + 'expo_token' => ['required', 'string', new ExpoPushTokenRule], ]); $user = $request->user(); @@ -1127,7 +1127,7 @@ class ApiV1Dot1Controller extends Controller $this->validate($request, [ 'notify_enabled' => 'required', - 'token' => ['required', ExpoPushToken::rule()], + 'token' => ['required', 'string', new ExpoPushTokenRule], 'notify_like' => 'sometimes', 'notify_follow' => 'sometimes', 'notify_mention' => 'sometimes', diff --git a/app/Rules/ExpoPushTokenRule.php b/app/Rules/ExpoPushTokenRule.php new file mode 100644 index 00000000..27fb9670 --- /dev/null +++ b/app/Rules/ExpoPushTokenRule.php @@ -0,0 +1,33 @@ +