aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/juick/server/PMQueries.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/com/juick/server/PMQueries.java b/src/com/juick/server/PMQueries.java
index 651524ee..56b91abf 100644
--- a/src/com/juick/server/PMQueries.java
+++ b/src/com/juick/server/PMQueries.java
@@ -243,7 +243,7 @@ public class PMQueries {
return msgs;
}
- public static ArrayList<com.juick.Message> getLastPMMessages(Connection sql, int uid) {
+ public static ArrayList<com.juick.Message> getLastPMInbox(Connection sql, int uid) {
ArrayList<com.juick.Message> msgs = new ArrayList<com.juick.Message>(20);
PreparedStatement stmt = null;
@@ -271,4 +271,33 @@ public class PMQueries {
return msgs;
}
+
+ public static ArrayList<com.juick.Message> getLastPMSent(Connection sql, int uid) {
+ ArrayList<com.juick.Message> msgs = new ArrayList<com.juick.Message>(20);
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT pm.user_id_to,users.nick,pm.txt,TIMESTAMPDIFF(MINUTE,pm.ts,NOW()),DATE_FORMAT(pm.ts,'%Y-%m-%d %H:%i:%s') FROM pm INNER JOIN users ON pm.user_id_to=users.id WHERE pm.user_id=? ORDER BY pm.ts DESC LIMIT 20");
+ stmt.setInt(1, uid);
+ rs = stmt.executeQuery();
+ rs.beforeFirst();
+ while (rs.next()) {
+ com.juick.Message msg = new com.juick.Message();
+ msg.User = new com.juick.User();
+ msg.User.UID = rs.getInt(1);
+ msg.User.UName = rs.getString(2);
+ msg.Text = rs.getString(3);
+ msg.TimeAgo = rs.getInt(4);
+ msg.TimestampString = rs.getString(5);
+ msgs.add(0, msg);
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ return msgs;
+ }
}