From 860b00003367e5a66ffc8ffe373542e424516249 Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Fri, 2 Nov 2012 14:44:28 +0700 Subject: MessagesQueries.isSubscribed --- src/com/juick/server/MessagesQueries.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src') diff --git a/src/com/juick/server/MessagesQueries.java b/src/com/juick/server/MessagesQueries.java index 87784f63..1df45803 100644 --- a/src/com/juick/server/MessagesQueries.java +++ b/src/com/juick/server/MessagesQueries.java @@ -53,6 +53,27 @@ public class MessagesQueries { return privacy >= 0 || (privacy == -1 && uid > 0 && UserQueries.isInWL(sql, owner_uid, uid)) || (privacy == -2 && uid == owner_uid); } + public static boolean isSubscribed(Connection sql, int uid, int mid) { + boolean ret = false; + + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = sql.prepareStatement("SELECT 1 FROM subscr_messages WHERE suser_id=? AND message_id=?"); + stmt.setInt(1, uid); + stmt.setInt(2, mid); + rs = stmt.executeQuery(); + if (rs.first()) { + ret = rs.getInt(1) == 1; + } + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(rs, stmt); + } + return ret; + } + public static com.juick.Message getMessage(Connection sql, int mid) { com.juick.Message msg = null; -- cgit v1.2.3