From dc6bf14e43aff0723af165a0fffc0d130666a21a Mon Sep 17 00:00:00 2001 From: Artemy <109195690+stalcker2288969@users.noreply.github.com> Date: Sun, 1 Mar 2026 18:10:21 +0700 Subject: [PATCH] fix bugs --- .../Hubs/Infrastructure/ChatNotificationService.cs | 4 ++-- .../Providers/FirebasePushProvider.cs | 13 +++++++++---- Govor.Data/Repositories/PushTokenRepository.cs | 1 + 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Govor.API/Hubs/Infrastructure/ChatNotificationService.cs b/Govor.API/Hubs/Infrastructure/ChatNotificationService.cs index ab9bba0..5d0486b 100644 --- a/Govor.API/Hubs/Infrastructure/ChatNotificationService.cs +++ b/Govor.API/Hubs/Infrastructure/ChatNotificationService.cs @@ -50,9 +50,9 @@ public class ChatNotificationService : IChatNotificationService var privateChat = await _privateChatsRepository.GetByIdAsync(message.RecipientId); var text = message.EncryptedContent.Substring(0, Math.Min(40, message.EncryptedContent.Length)); - var userId = message.SenderId == privateChat.UserAId ? privateChat.UserAId : privateChat.UserBId; + var userId = message.SenderId == privateChat.UserAId ? privateChat.UserBId : privateChat.UserAId; - var profile = await _profileService.GetUserProfileAsync(userId); + var profile = await _profileService.GetUserProfileAsync(message.SenderId); var title = profile.Username; await _notificationService.SendToUserAsync(userId, title,text, "chat_messages"); diff --git a/Govor.Application/Services/PushNotifications/Providers/FirebasePushProvider.cs b/Govor.Application/Services/PushNotifications/Providers/FirebasePushProvider.cs index d6d8f86..4107a6d 100644 --- a/Govor.Application/Services/PushNotifications/Providers/FirebasePushProvider.cs +++ b/Govor.Application/Services/PushNotifications/Providers/FirebasePushProvider.cs @@ -39,15 +39,15 @@ public class FirebasePushProvider : IPushNotificationProvider Notification = new Notification { Title = message.Title, - Body = message.Body + Body = message.Body, }, Data = message.Data, Android = message.ChannelId != null ? new AndroidConfig { + Priority = Priority.High, Notification = new AndroidNotification { - ChannelId = message.ChannelId, - Priority = NotificationPriority.HIGH + ChannelId = message.ChannelId ?? "chat_messages" } } : null }; @@ -82,7 +82,11 @@ public class FirebasePushProvider : IPushNotificationProvider { var msg = new Message { - Notification = new Notification { Title = pm.Title, Body = pm.Body }, + Notification = new Notification + { + Title = pm.Title, + Body = pm.Body + }, Data = pm.Data, Token = token }; @@ -91,6 +95,7 @@ public class FirebasePushProvider : IPushNotificationProvider { msg.Android = new AndroidConfig { + Priority = Priority.High, Notification = new AndroidNotification { ChannelId = pm.ChannelId } }; } diff --git a/Govor.Data/Repositories/PushTokenRepository.cs b/Govor.Data/Repositories/PushTokenRepository.cs index db60747..142adfc 100644 --- a/Govor.Data/Repositories/PushTokenRepository.cs +++ b/Govor.Data/Repositories/PushTokenRepository.cs @@ -73,6 +73,7 @@ public class PushTokenRepository : IPushTokenRepository existing.Provider = provider; existing.UpdatedAt = DateTime.UtcNow; existing.LastUsedAt = DateTime.UtcNow; + existing.Token = token; existing.IsActive = true; _context.UserPushTokens.Update(existing);