Add: Enhanced push notification logging for debugging
This commit is contained in:
parent
b265c89a72
commit
b8390162d9
@ -274,7 +274,10 @@ public class PushNotificationService : IPushNotificationService
|
|||||||
private async Task<bool> SendNotificationToSubscriptions(List<Models.PushSubscription> subscriptions, PushNotificationDto notification)
|
private async Task<bool> SendNotificationToSubscriptions(List<Models.PushSubscription> subscriptions, PushNotificationDto notification)
|
||||||
{
|
{
|
||||||
if (!subscriptions.Any())
|
if (!subscriptions.Any())
|
||||||
|
{
|
||||||
|
Log.Information("No active push subscriptions found for notification: {Title}", notification.Title);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int successCount = 0;
|
int successCount = 0;
|
||||||
var failedSubscriptions = new List<Models.PushSubscription>();
|
var failedSubscriptions = new List<Models.PushSubscription>();
|
||||||
@ -289,6 +292,9 @@ public class PushNotificationService : IPushNotificationService
|
|||||||
data = notification.Data
|
data = notification.Data
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Log.Information("Attempting to send push notification to {Count} subscriptions: {Title}",
|
||||||
|
subscriptions.Count, notification.Title);
|
||||||
|
|
||||||
foreach (var subscription in subscriptions)
|
foreach (var subscription in subscriptions)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -324,8 +330,8 @@ public class PushNotificationService : IPushNotificationService
|
|||||||
// Save changes to update last used times and inactive subscriptions
|
// Save changes to update last used times and inactive subscriptions
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
Log.Information("Push notifications sent: {SuccessCount} successful, {FailedCount} failed",
|
Log.Information("Push notifications sent: {SuccessCount} successful, {FailedCount} failed (Total subscriptions: {Total})",
|
||||||
successCount, failedSubscriptions.Count);
|
successCount, failedSubscriptions.Count, subscriptions.Count);
|
||||||
|
|
||||||
return successCount > 0;
|
return successCount > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user