From 4844ef8ea55d8b88619af8400df1bbf690842f7f Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Wed, 20 Nov 2013 04:14:35 +0700 Subject: UserQueries.isInBLAny; PMQueries lastmessage time fix --- src/com/juick/server/PMQueries.java | 2 +- src/com/juick/server/UserQueries.java | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/com/juick/server/PMQueries.java b/src/com/juick/server/PMQueries.java index 6399802f..b0c2911a 100644 --- a/src/com/juick/server/PMQueries.java +++ b/src/com/juick/server/PMQueries.java @@ -159,7 +159,7 @@ public class PMQueries { if (users.size() < cnt) { try { - stmt = sql.prepareStatement("SELECT user_id,user_id_to FROM pm_streams WHERE user_id=? OR user_id_to=? ORDER BY lastmessage DESC LIMIT ?"); + stmt = sql.prepareStatement("SELECT user_id,user_id_to FROM pm_streams WHERE (user_id=? OR user_id_to=?) AND lastmessage>TIMESTAMPADD(MONTH,-1,NOW()) ORDER BY lastmessage DESC LIMIT ?"); stmt.setInt(1, uid); stmt.setInt(2, uid); stmt.setInt(3, cnt * 2); diff --git a/src/com/juick/server/UserQueries.java b/src/com/juick/server/UserQueries.java index f127cbca..b1198e4d 100644 --- a/src/com/juick/server/UserQueries.java +++ b/src/com/juick/server/UserQueries.java @@ -425,6 +425,29 @@ public class UserQueries { return ret; } + public static boolean isInBLAny(Connection sql, int uid, int uid2) { + boolean ret = false; + + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = sql.prepareStatement("SELECT 1 FROM bl_users WHERE (user_id=? AND bl_user_id=?) OR (user_id=? AND bl_user_id=?)"); + stmt.setInt(1, uid); + stmt.setInt(2, uid2); + stmt.setInt(3, uid2); + stmt.setInt(4, uid); + 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 ArrayList checkBL(Connection sql, int visitor, ArrayList uids) { ArrayList ret = new ArrayList(); -- cgit v1.2.3