aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/api/Others.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2015-10-31 01:36:15 +0300
committerGravatar Vitaly Takmazov2015-10-31 01:36:15 +0300
commita4897522174fb48864a4ef7d6276167f9da61f3b (patch)
tree882e8ac66cfd73b4ea1361976fe8be479d78f765 /src/main/java/com/juick/api/Others.java
parent0742847f430b02d2d9031f1a11799ac7076e9e26 (diff)
moved to Gradle
Diffstat (limited to 'src/main/java/com/juick/api/Others.java')
-rw-r--r--src/main/java/com/juick/api/Others.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main/java/com/juick/api/Others.java b/src/main/java/com/juick/api/Others.java
new file mode 100644
index 00000000..25df5bf4
--- /dev/null
+++ b/src/main/java/com/juick/api/Others.java
@@ -0,0 +1,45 @@
+package com.juick.api;
+
+import com.juick.server.PMQueries;
+import java.io.IOException;
+import java.sql.Connection;
+import java.util.ArrayList;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * @author ugnich
+ */
+public class Others {
+
+ Connection sql;
+
+ public Others(Connection sql) {
+ this.sql = sql;
+ }
+
+ public void doGetGroupsPMs(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException {
+ int cnt = 5;
+ try {
+ String cntStr = request.getParameter("cnt");
+ cnt = Integer.parseInt(cntStr);
+ if (cnt < 3) {
+ cnt = 3;
+ }
+ if (cnt > 10) {
+ cnt = 10;
+ }
+ } catch (Exception e) {
+ }
+
+ ArrayList<com.juick.User> lastconv = PMQueries.getPMLastConversationsUsers(sql, vuid, cnt);
+ if (lastconv != null && !lastconv.isEmpty()) {
+ String json = "{\"pms\":" + com.juick.json.Users.arrayToString(lastconv) + "}";
+ Main.replyJSON(request, response, json);
+ } else {
+ response.sendError(404);
+ }
+ }
+}