update contact list

This commit is contained in:
2025-08-04 16:41:23 +03:30
parent 83a29d5ea1
commit 96fa7264cf
10 changed files with 309 additions and 30 deletions
@@ -251,7 +251,28 @@ public class PrivateChatDatabase {
}
public static UUID findChatBetween(UUID user1, UUID user2) {
String sql = """
SELECT chat_id FROM private_chat
WHERE (user1_id = ? AND user2_id = ?) OR (user1_id = ? AND user2_id = ?)
""";
try (Connection conn = ConnectionDb.connect();
PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setObject(1, user1);
ps.setObject(2, user2);
ps.setObject(3, user2);
ps.setObject(4, user1);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return (UUID) rs.getObject("chat_id");
}
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
}