Work on download files(channels)

This commit is contained in:
2025-08-15 00:24:55 +03:30
parent 27fc134ffe
commit 3412648c7f
8 changed files with 159 additions and 27 deletions
@@ -73,4 +73,29 @@ public class ChannelPermissionUtil {
}
return false;
}
public static boolean isUserInChannel(UUID userId, UUID channelId) {
final String SQL = "SELECT 1 FROM channel_subscribers WHERE channel_id = ? AND user_id = ? LIMIT 1";
try (Connection conn = ConnectionDb.connect();
PreparedStatement ps = conn.prepareStatement(SQL)) {
ps.setObject(1, channelId, java.sql.Types.OTHER); // 👈 مهم برای Postgres UUID
ps.setObject(2, userId, java.sql.Types.OTHER);
System.out.println("[SQL] isUserInChannel ch=" + channelId + " user=" + userId
+ " db=" + conn.getMetaData().getURL());
try (ResultSet rs = ps.executeQuery()) {
boolean ok = rs.next();
System.out.println("[SQL] isUserInChannel -> " + ok);
return ok;
}
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
}