Merge pull request 'Refactor push notification logic in afterSave method to streamline subscription checks and improve logging' (#160) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #160
This commit was merged in pull request #160.
This commit is contained in:
@@ -129,45 +129,36 @@ class EditRfqTransporterBid extends EditRecord
|
|||||||
// ]);
|
// ]);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
foreach ($users as $user) {
|
|
||||||
|
|
||||||
$subscriptions = $user->pushSubscriptions()->get();
|
|
||||||
|
|
||||||
Log::info('Checking push subscription for user', [
|
foreach ($users as $user) {
|
||||||
'user_id' => $user->id,
|
|
||||||
'name' => $user->name,
|
|
||||||
'subscription_count' => $subscriptions->count(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
if ($subscriptions->isEmpty()) {
|
$count = $user->pushSubscriptions()->count();
|
||||||
Log::warning('User has NO push subscription', [
|
|
||||||
'user_id' => $user->id,
|
|
||||||
]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::info('Sending push notification', [
|
Log::info('Checking push subscription for user', [
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
]);
|
'name' => $user->name,
|
||||||
|
'subscription_count' => $count,
|
||||||
|
]);
|
||||||
|
|
||||||
foreach ($subscriptions as $subscription) {
|
if ($count == 0) {
|
||||||
try {
|
Log::warning('User has NO push subscription', [
|
||||||
\Notification::route('webpush', $subscription)
|
'user_id' => $user->id,
|
||||||
->notify(new PushAlertNotification(
|
]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::info('Sending push notification', [
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// ✅ THIS IS ALL YOU NEED
|
||||||
|
$user->notify(new PushAlertNotification(
|
||||||
'Rank Updated',
|
'Rank Updated',
|
||||||
$body
|
$body
|
||||||
));
|
));
|
||||||
} catch (\Throwable $e) {
|
}
|
||||||
Log::warning('Removing invalid push subscription', [
|
|
||||||
'user_id' => $user->id,
|
|
||||||
'endpoint' => $subscription->endpoint,
|
|
||||||
'error' => $e->getMessage(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
$subscription->delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user