BTCPay-infrastructure-recovery

This commit is contained in:
sysadmin
2025-09-04 21:28:47 +01:00
parent b4cee007c4
commit be4d797c6c
22 changed files with 1552 additions and 101 deletions

View File

@@ -40,6 +40,14 @@ public class PushNotificationService : IPushNotificationService
{
try
{
// Check if the user actually exists in the database
var userExists = await _context.Users.AnyAsync(u => u.Id == userId);
if (!userExists)
{
Log.Warning("Attempted to subscribe non-existent user {UserId} to push notifications", userId);
return false;
}
// Check if subscription already exists
var existingSubscription = await _context.PushSubscriptions
.FirstOrDefaultAsync(ps => ps.Endpoint == subscriptionDto.Endpoint && ps.UserId == userId);
@@ -53,6 +61,7 @@ public class PushNotificationService : IPushNotificationService
existingSubscription.IsActive = true;
existingSubscription.UserAgent = userAgent;
existingSubscription.IpAddress = ipAddress;
Log.Information("Updated existing push subscription for user {UserId}", userId);
}
else
{
@@ -71,10 +80,11 @@ public class PushNotificationService : IPushNotificationService
};
_context.PushSubscriptions.Add(subscription);
Log.Information("Created new push subscription for user {UserId}", userId);
}
await _context.SaveChangesAsync();
Log.Information("Push subscription created/updated for user {UserId}", userId);
Log.Information("Push subscription saved successfully for user {UserId}", userId);
return true;
}
catch (Exception ex)