aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/api/Messages.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-01-15 12:51:21 +0300
committerGravatar Vitaly Takmazov2016-01-15 12:51:21 +0300
commit690b3ea447a7a2434ecf1d210e5f5ef89ce27f04 (patch)
tree2e96768580044b2144b38e423f0fe20f73f522d8 /src/main/java/com/juick/api/Messages.java
parent5c207f65b0cafbaa0cbdae72a5a485cf7aa62556 (diff)
spring-jdbc WIP
Diffstat (limited to 'src/main/java/com/juick/api/Messages.java')
-rw-r--r--src/main/java/com/juick/api/Messages.java54
1 files changed, 45 insertions, 9 deletions
diff --git a/src/main/java/com/juick/api/Messages.java b/src/main/java/com/juick/api/Messages.java
index cde3987f..e3dcabfd 100644
--- a/src/main/java/com/juick/api/Messages.java
+++ b/src/main/java/com/juick/api/Messages.java
@@ -1,17 +1,21 @@
package com.juick.api;
+import com.juick.Tag;
+import com.juick.User;
import com.juick.json.MessageSerializer;
import com.juick.server.MessagesQueries;
+import com.juick.server.TagQueries;
+import com.juick.server.UserQueries;
import com.juick.xmpp.JID;
import com.juick.xmpp.Message;
import com.juick.xmpp.Stream;
import com.juick.xmpp.extensions.JuickMessage;
+import org.springframework.jdbc.core.JdbcTemplate;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.sql.Connection;
import java.util.List;
/**
@@ -20,11 +24,32 @@ import java.util.List;
*/
public class Messages {
- Connection sql;
+ JdbcTemplate sql;
MessageSerializer messageSerializer = new MessageSerializer();
- public Messages(Connection sql) {
+ enum MediaType {
+ ALL("all"),
+ PHOTO("photo"),
+ VIDEO("video"),
+ NONE("");
+
+ private final String value;
+
+ MediaType(final String value) {
+ this.value = value;
+ }
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ return this.getValue();
+ }
+ }
+
+ public Messages(JdbcTemplate sql) {
this.sql = sql;
}
@@ -45,8 +70,19 @@ public class Messages {
}
}
- public void doGetRecommended(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException {
+ public void doGet(HttpServletRequest request, HttpServletResponse response, int vuid)
+ throws ServletException, IOException {
+ User user = UserQueries.getUserByName(sql, request.getParameter("uname"));
int before_mid = Utils.parseInt(request.getParameter("before_mid"), 0);
+ int page = Utils.parseInt(request.getParameter("page"), 0);
+ MediaType media = MediaType.valueOf(request.getParameter("media"));
+ boolean popular = Boolean.valueOf(request.getParameter("popular"));
+ Tag tag = TagQueries.getTag(sql, request.getParameter("tag"), false);
+
+ }
+
+ public void doGetRecommended(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException {
+ /*int before_mid = Utils.parseInt(request.getParameter("before_mid"), 0);
List<Integer> mids = MessagesQueries.getUserRecommendations(sql, vuid, before_mid);
if (mids != null && !mids.isEmpty()) {
@@ -59,21 +95,21 @@ public class Messages {
}
} else {
response.sendError(404);
- }
+ }*/
}
public void doSetPrivacy(HttpServletRequest request, HttpServletResponse response, Stream xmpp, int vuid) throws ServletException, IOException {
- int mid = Utils.parseInt(request.getParameter("mid"), 0);
+ /*int mid = Utils.parseInt(request.getParameter("mid"), 0);
com.juick.User user = MessagesQueries.getMessageAuthor(sql, mid);
if (user != null && user.UID == vuid && MessagesQueries.setMessagePrivacy(sql, mid)) {
Main.replyJSON(request, response, "{\"status\":\"ok\"}");
} else {
response.sendError(400);
- }
+ }*/
}
public void doSetPopular(HttpServletRequest request, HttpServletResponse response, Stream xmpp) throws ServletException, IOException {
- int mid = Utils.parseInt(request.getParameter("mid"), 0);
+ /*int mid = Utils.parseInt(request.getParameter("mid"), 0);
int popular = Utils.parseInt(request.getParameter("popular"), 0);
if (mid > 0) {
@@ -105,6 +141,6 @@ public class Messages {
}
Main.replyJSON(request, response, "{\"status\":\"ok\"}");
- }
+ }*/
}
}