Manage block list

This commit is contained in:
2025-09-05 01:17:52 +03:30
parent dde64fd8aa
commit 297696fba1
4 changed files with 117 additions and 2 deletions
@@ -2972,6 +2972,33 @@ public class ClientHandler implements Runnable {
break;
}
case "check_block_status_by_chat": {
try {
UUID viewerId = UUID.fromString(requestJson.getString("viewer_id"));
UUID chatId = UUID.fromString(requestJson.getString("chat_id"));
UUID otherId = ContactDatabase.findOtherUserInPrivateChat(chatId, viewerId);
if (otherId == null) {
response = new ResponseModel("error", "Chat not found or not private.");
break;
}
boolean blockedByMe = ContactDatabase.isBlocked(viewerId, otherId);
boolean blockedMe = ContactDatabase.isBlocked(otherId, viewerId);
org.json.JSONObject data = new org.json.JSONObject()
.put("other_id", otherId.toString())
.put("blocked_by_me", blockedByMe)
.put("blocked_me", blockedMe);
response = new ResponseModel("success", "ok", data);
} catch (Exception e) {
response = new ResponseModel("error", "Invalid parameters.");
}
break;
}
default:
response = new ResponseModel("error", "Unknown action: " + action);