diff --git a/DysonNetwork.Sphere/Chat/ChatService.cs b/DysonNetwork.Sphere/Chat/ChatService.cs index 87214ef..04939bd 100644 --- a/DysonNetwork.Sphere/Chat/ChatService.cs +++ b/DysonNetwork.Sphere/Chat/ChatService.cs @@ -249,15 +249,6 @@ public partial class ChatService( List accountsToNotify = []; foreach (var member in members) { - await scopedNty.PushWebSocketPacketToUsersAsync(new PushWebSocketPacketToUsersRequest - { - Packet = new WebSocketPacket - { - Type = type, - Data = GrpcTypeHelper.ConvertObjectToByteString(message), - }, - }); - if (member.AccountId == sender.AccountId) continue; if (member.Notify == ChatMemberNotify.None) continue; // if (scopedWs.IsUserSubscribedToChatRoom(member.AccountId, room.Id.ToString())) continue; @@ -272,6 +263,17 @@ public partial class ChatService( accountsToNotify.Add(member.Account.ToProtoValue()); } + var request = new PushWebSocketPacketToUsersRequest + { + Packet = new WebSocketPacket + { + Type = type, + Data = GrpcTypeHelper.ConvertObjectToByteString(message), + }, + }; + request.UserIds.AddRange(accountsToNotify.Select(a => a.Id.ToString())); + await scopedNty.PushWebSocketPacketToUsersAsync(request); + logger.LogInformation($"Trying to deliver message to {accountsToNotify.Count} accounts..."); // Only send notifications if there are accounts to notify var ntyRequest = new SendPushNotificationToUsersRequest { Notification = notification };