diff options
author | Ugnich Anton | 2012-11-02 14:44:28 +0700 |
---|---|---|
committer | Ugnich Anton | 2012-11-02 14:44:28 +0700 |
commit | 860b00003367e5a66ffc8ffe373542e424516249 (patch) | |
tree | deae317eb5a1e2368613e28a7243ab11386752b0 /src/com/juick | |
parent | 691738fa2c9f4b8ac3789b21767e52f35ae72b5a (diff) |
MessagesQueries.isSubscribed
Diffstat (limited to 'src/com/juick')
-rw-r--r-- | src/com/juick/server/MessagesQueries.java | 21 |
1 files changed, 21 insertions, 0 deletions
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; |