Work on block/ unblock

This commit is contained in:
2025-08-08 22:28:23 +03:30
parent a900c66eac
commit ec01dfe269
3 changed files with 71 additions and 4 deletions
@@ -81,7 +81,6 @@ public class ContactDatabase {
}
return !currentlyBlocked;
} else {
// اگر رابطه وجود نداره، اول باید کاربر رو به contact ها اضافه کنیم
String insertSql = "INSERT INTO contacts (user_id, contact_id, is_blocked) VALUES (?, ?, ?)";
try (PreparedStatement insertStmt = conn.prepareStatement(insertSql)) {
insertStmt.setObject(1, userId);
@@ -151,8 +150,13 @@ public class ContactDatabase {
}
}
public boolean eitherBlocks(UUID userA, UUID userB) {
return isBlocked(userA, userB) || isBlocked(userB, userA);
}
public boolean isBlocked(UUID user_id, UUID contact_id) {
public static boolean isBlocked(UUID user_id, UUID contact_id) {
String sql = "SELECT is_blocked FROM contacts WHERE user_id = ? AND contact_id = ?";
try (Connection connection = getConnection()) {
PreparedStatement stmt = connection.prepareStatement(sql);