Harden push notification delivery

Keep encrypted message content out of push payloads and improve cross-platform notification data. Add token registration validation and per-session unregister support, batch and deduplicate sends, remove only confirmed unregistered tokens, and protect queued retries with leases. Add delivery tests and document the push API and Firebase setup.
This commit is contained in:
Artemy
2026-10-17 19:53:34 +07:00
parent 9aa7e017e2
commit e060b2bcbb
21 changed files with 16353 additions and 132 deletions
@@ -67,12 +67,14 @@ public class ChatNotificationService : IChatNotificationService
return true;
var profile = await _profiles.GetUserProfileAsync(message.SenderId);
var title = profile.IsSuccess ? profile.Value.Username : "Govor";
var content = message.EncryptedContent ?? string.Empty;
var body = content.Length == 0 ? "Attachment" : content[..Math.Min(40, content.Length)];
// Message content is encrypted; never send ciphertext or a guessed preview to FCM.
var body = "New message";
var data = new Dictionary<string, string>
{
["chatId"] = message.RecipientId.ToString(),
["messageId"] = message.MessageId.ToString(),
["senderId"] = message.SenderId.ToString(),
["type"] = "chat_message",
["isGroup"] = message.RecipientType == RecipientType.Group ? "true" : "false"
};
var push = await _notificationService.SendToUsersAsync(recipients, title, body,