aboutsummaryrefslogtreecommitdiff
path: root/src/com/juick
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/juick')
-rw-r--r--src/com/juick/server/MessagesQueries.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/com/juick/server/MessagesQueries.java b/src/com/juick/server/MessagesQueries.java
index 64ee3b96..bf26b70b 100644
--- a/src/com/juick/server/MessagesQueries.java
+++ b/src/com/juick/server/MessagesQueries.java
@@ -352,6 +352,35 @@ public class MessagesQueries {
return mids;
}
+ public static ArrayList<Integer> getTags(Connection sql, String tids, int visitor_uid, int before, int cnt) {
+ ArrayList<Integer> mids = new ArrayList<Integer>(20);
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ if (before > 0) {
+ stmt = sql.prepareStatement("SELECT messages.message_id FROM messages_tags INNER JOIN messages USING(message_id) WHERE messages_tags.tag_id IN (" + tids + ") AND messages.message_id<? AND (messages.privacy>0 OR messages.user_id=?) ORDER BY messages.message_id DESC LIMIT ?");
+ stmt.setInt(1, before);
+ stmt.setInt(2, visitor_uid);
+ stmt.setInt(3, cnt);
+ } else {
+ stmt = sql.prepareStatement("SELECT messages.message_id FROM messages_tags INNER JOIN messages USING(message_id) WHERE messages_tags.tag_id IN (" + tids + ") AND (messages.privacy>0 OR messages.user_id=?) ORDER BY messages.message_id DESC LIMIT ?");
+ stmt.setInt(1, visitor_uid);
+ stmt.setInt(2, cnt);
+ }
+ rs = stmt.executeQuery();
+ rs.beforeFirst();
+ while (rs.next()) {
+ mids.add(rs.getInt(1));
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+ return mids;
+ }
+
public static ArrayList<Integer> getPlace(Connection sql, int place_id, int visitor_uid, int before) {
ArrayList<Integer> mids = new ArrayList<Integer>(20);