🐛 Fixes in notification

This commit is contained in:
2025-07-31 16:42:35 +08:00
parent 0306b54a0f
commit e3499ff283
3 changed files with 22 additions and 5 deletions

View File

@@ -142,8 +142,15 @@ public class PushService
if (!isSilent) _ = DeliveryNotification(notification); if (!isSilent) _ = DeliveryNotification(notification);
} }
public async Task DeliveryNotification(Notification notification) private async Task DeliveryNotification(Notification notification)
{ {
_logger.LogInformation(
"Delivering notification: {NotificationTopic} #{NotificationId} with meta {NotificationMeta}",
notification.Topic,
notification.Id,
notification.Meta
);
// Pushing the notification // Pushing the notification
var subscribers = await _db.PushSubscriptions var subscribers = await _db.PushSubscriptions
.Where(s => s.AccountId == notification.AccountId) .Where(s => s.AccountId == notification.AccountId)
@@ -184,6 +191,13 @@ public class PushService
}).ToList(); }).ToList();
await _db.BulkInsertAsync(notifications); await _db.BulkInsertAsync(notifications);
} }
_logger.LogInformation(
"Delivering notification in batch: {NotificationTopic} #{NotificationId} with meta {NotificationMeta}",
notification.Topic,
notification.Id,
notification.Meta
);
var subscribers = await _db.PushSubscriptions var subscribers = await _db.PushSubscriptions
.Where(s => accounts.Contains(s.AccountId)) .Where(s => accounts.Contains(s.AccountId))

View File

@@ -91,7 +91,9 @@ public class PusherServiceGrpc(
request.Notification.Title, request.Notification.Title,
request.Notification.Subtitle, request.Notification.Subtitle,
request.Notification.Body, request.Notification.Body,
GrpcTypeHelper.ConvertByteStringToObject<Dictionary<string, object?>>(request.Notification.Meta) ?? [], request.Notification.HasMeta
? GrpcTypeHelper.ConvertByteStringToObject<Dictionary<string, object?>>(request.Notification.Meta) ?? []
: [],
request.Notification.ActionUri, request.Notification.ActionUri,
request.Notification.IsSilent, request.Notification.IsSilent,
request.Notification.IsSavable request.Notification.IsSavable
@@ -108,8 +110,9 @@ public class PusherServiceGrpc(
Title = request.Notification.Title, Title = request.Notification.Title,
Subtitle = request.Notification.Subtitle, Subtitle = request.Notification.Subtitle,
Content = request.Notification.Body, Content = request.Notification.Body,
Meta = GrpcTypeHelper.ConvertByteStringToObject<Dictionary<string, object?>>(request.Notification.Meta) ?? Meta = request.Notification.HasMeta
[] ? GrpcTypeHelper.ConvertByteStringToObject<Dictionary<string, object?>>(request.Notification.Meta) ?? []
: [],
}; };
if (request.Notification.ActionUri is not null) if (request.Notification.ActionUri is not null)
notification.Meta["action_uri"] = request.Notification.ActionUri; notification.Meta["action_uri"] = request.Notification.ActionUri;

View File

@@ -85,7 +85,7 @@ message PushNotification {
string title = 2; string title = 2;
string subtitle = 3; string subtitle = 3;
string body = 4; string body = 4;
bytes meta = 5; optional bytes meta = 5;
optional string action_uri = 6; optional string action_uri = 6;
bool is_silent = 7; bool is_silent = 7;
bool is_savable = 8; bool is_savable = 8;