fixed real time bugs

This commit is contained in:
2025-07-21 18:59:24 +03:30
parent 541f800877
commit 84890539da
4 changed files with 45 additions and 66 deletions
@@ -1143,10 +1143,16 @@ public class ClientHandler implements Runnable {
//RealTime
if (success) {
List<UUID> members = GroupDatabase.getMemberUUIDs(groupId);
// 1. ارسال ownership_transferred فقط به owner جدید
RealTimeEventDispatcher.sendOwnershipTransferred("group", groupId, groupId.toString(), List.of(newOwner.getInternal_uuid()));
// 2. ارسال update_group_or_channel برای همه اعضا
RealTimeEventDispatcher.sendGroupOrChannelUpdate("group", groupId, groupId.toString(), "", "", members);
}
response = success
? new ResponseModel("success", "Ownership transferred.")
: new ResponseModel("error", "Failed to transfer ownership.");
@@ -1558,9 +1564,15 @@ public class ClientHandler implements Runnable {
//RealTime
if (success) {
List<UUID> subscribers = ChannelDatabase.getChannelSubscriberUUIDs(channelId);
// 1. ارسال ownership_transferred فقط به owner جدید
RealTimeEventDispatcher.sendOwnershipTransferred("channel", channelId, channelId.toString(), List.of(newOwner.getInternal_uuid()));
// 2. ارسال update_group_or_channel برای بروزرسانی UI تمام افراد
RealTimeEventDispatcher.sendGroupOrChannelUpdate("channel", channelId, channelId.toString(), "", "", subscribers);
}
response = success
? new ResponseModel("success", "Ownership transferred successfully.")
@@ -1586,7 +1598,7 @@ public class ClientHandler implements Runnable {
if (requestJson.has("request_id")) {
String requestId = requestJson.getString("request_id");
response.setRequestId(requestId);
responseJson.put("request_id", requestId); // ✅ بدون این، کلاینت قفل میشه
responseJson.put("request_id", requestId);
}
out.println(responseJson.toString());