From d76e0dd83b7ada85ff50c1d1c07c05cf1f047b27 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 26 May 2025 01:55:59 +0800 Subject: [PATCH] :bug: Fix wrong end call sender --- DysonNetwork.Sphere/Chat/ChatService.cs | 6 ++++-- DysonNetwork.Sphere/Chat/RealtimeCallController.cs | 2 +- DysonNetwork.sln.DotSettings.user | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/DysonNetwork.Sphere/Chat/ChatService.cs b/DysonNetwork.Sphere/Chat/ChatService.cs index ed62090..b5eaca0 100644 --- a/DysonNetwork.Sphere/Chat/ChatService.cs +++ b/DysonNetwork.Sphere/Chat/ChatService.cs @@ -197,10 +197,12 @@ public class ChatService( return call; } - public async Task EndCallAsync(Guid roomId) + public async Task EndCallAsync(Guid roomId, ChatMember sender) { var call = await GetCallOngoingAsync(roomId); if (call is null) throw new InvalidOperationException("No ongoing call was not found."); + if (sender.Role < ChatMemberRole.Moderator && call.SenderId != sender.Id) + throw new InvalidOperationException("You are not the call initiator either the chat room moderator."); // End the realtime session if it exists if (!string.IsNullOrEmpty(call.SessionId) && !string.IsNullOrEmpty(call.ProviderName)) @@ -230,7 +232,7 @@ public class ChatService( { Type = "call.ended", ChatRoomId = call.RoomId, - SenderId = call.SenderId, + SenderId = sender.Id, Meta = new Dictionary { { "call_id", call.Id }, diff --git a/DysonNetwork.Sphere/Chat/RealtimeCallController.cs b/DysonNetwork.Sphere/Chat/RealtimeCallController.cs index e23c8b9..f460537 100644 --- a/DysonNetwork.Sphere/Chat/RealtimeCallController.cs +++ b/DysonNetwork.Sphere/Chat/RealtimeCallController.cs @@ -173,7 +173,7 @@ public class RealtimeCallController( try { - await cs.EndCallAsync(roomId); + await cs.EndCallAsync(roomId, member); return NoContent(); } catch (Exception exception) diff --git a/DysonNetwork.sln.DotSettings.user b/DysonNetwork.sln.DotSettings.user index ed26cfe..0143c1d 100644 --- a/DysonNetwork.sln.DotSettings.user +++ b/DysonNetwork.sln.DotSettings.user @@ -22,6 +22,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded