🐛 Chat related two bug fixes

This commit is contained in:
2025-07-21 17:07:08 +08:00
parent 9ecd43ada8
commit f0e16837d6
2 changed files with 9 additions and 8 deletions

View File

@@ -19,6 +19,7 @@ public class RealtimeCallController(
IConfiguration configuration,
AppDatabase db,
ChatService cs,
ChatRoomService crs,
IRealtimeService realtime
) : ControllerBase
{
@@ -64,6 +65,7 @@ public class RealtimeCallController(
.Include(c => c.Sender)
.FirstOrDefaultAsync();
if (ongoingCall is null) return NotFound();
ongoingCall.Sender = await crs.LoadMemberAccount(ongoingCall.Sender);
return Ok(ongoingCall);
}

View File

@@ -6,7 +6,7 @@ using Grpc.Core;
namespace DysonNetwork.Sphere.Connection;
public class WebSocketHandlerGrpc(PusherService.PusherServiceClient pusher, ChatRoomService crs)
public class WebSocketHandlerGrpc(PusherService.PusherServiceClient pusher, ChatRoomService crs, ChatService cs)
: PusherHandlerService.PusherHandlerServiceBase
{
public override async Task<Empty> ReceiveWebSocketPacket(
@@ -34,8 +34,10 @@ public class WebSocketHandlerGrpc(PusherService.PusherServiceClient pusher, Chat
if (packet.Data == null)
{
await SendErrorResponse(request,
"Mark message as read requires you to provide the ChatRoomId and MessageId");
await SendErrorResponse(
request,
"Mark message as read requires you to provide the ChatRoomId"
);
return;
}
@@ -57,10 +59,7 @@ public class WebSocketHandlerGrpc(PusherService.PusherServiceClient pusher, Chat
return;
}
var readReceipt = new MessageReadReceipt { SenderId = sender.Id };
var bufferService = context.GetHttpContext().RequestServices.GetRequiredService<FlushBufferService>();
bufferService.Enqueue(readReceipt);
await cs.ReadChatRoomAsync(Guid.Parse(currentUser.Id), requestData.ChatRoomId);
}
private async Task HandleMessageTyping(ReceiveWebSocketPacketRequest request, ServerCallContext context)