From 18ccd7a3c0baf7e79490d323657da04e6dff8fbc Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Sun, 5 Jul 2026 13:33:18 +0700 Subject: [PATCH] fix: update SendPushNotificationJob to correctly handle expired subscriptions; modify PushSubscriptionService to ensure user_id is set during subscription creation --- app/Jobs/SendPushNotificationJob.php | 4 ++-- app/Services/System/PushSubscriptionService.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Jobs/SendPushNotificationJob.php b/app/Jobs/SendPushNotificationJob.php index 9603125..9025c48 100644 --- a/app/Jobs/SendPushNotificationJob.php +++ b/app/Jobs/SendPushNotificationJob.php @@ -84,8 +84,8 @@ private function sendWebPush(): void $expiredEndpoints = []; foreach ($webPush->flush() as $report) { - if (! $report->isSuccess()) { - $expiredEndpoints[] = (string) $report->getRequest()->getUri(); + if ($report->isSubscriptionExpired()) { + $expiredEndpoints[] = $report->getEndpoint(); } } diff --git a/app/Services/System/PushSubscriptionService.php b/app/Services/System/PushSubscriptionService.php index 46bf2c7..59eed5e 100644 --- a/app/Services/System/PushSubscriptionService.php +++ b/app/Services/System/PushSubscriptionService.php @@ -10,10 +10,10 @@ public function updateOrCreateSubscription(array $validated, int $userId): void { PushSubscription::updateOrCreate( [ - 'user_id' => $userId, 'endpoint' => $validated['endpoint'], ], [ + 'user_id' => $userId, 'public_key' => $validated['publicKey'], 'auth_token' => $validated['authToken'], ]