aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/juick/api/Main.java6
-rw-r--r--src/main/java/com/juick/api/Messages.java17
2 files changed, 23 insertions, 0 deletions
diff --git a/src/main/java/com/juick/api/Main.java b/src/main/java/com/juick/api/Main.java
index 5ee4027b0..e10b90785 100644
--- a/src/main/java/com/juick/api/Main.java
+++ b/src/main/java/com/juick/api/Main.java
@@ -166,6 +166,12 @@ public class Main extends HttpServlet implements Stream.StreamListener {
} else {
response.sendError(401);
}
+ } else if (uri.equals("/messages/recommended")) {
+ if (vuid > 0) {
+ messages.doGetRecommended(request, response, vuid);
+ } else {
+ response.sendError(401);
+ }
} else if (uri.equals("/messages/set_popular") && vuid == 1) {
messages.doSetPopular(request, response, xmpp);
} else if (uri.equals("/messages/set_privacy") && vuid > 0) {
diff --git a/src/main/java/com/juick/api/Messages.java b/src/main/java/com/juick/api/Messages.java
index b5462258a..76615e44d 100644
--- a/src/main/java/com/juick/api/Messages.java
+++ b/src/main/java/com/juick/api/Messages.java
@@ -41,6 +41,23 @@ public class Messages {
}
}
+ public void doGetRecommended(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException {
+ int before_mid = Utils.parseInt(request.getParameter("before_mid"), 0);
+
+ ArrayList<Integer> mids = MessagesQueries.getRecommended(sql, vuid, before_mid);
+ if (mids != null && !mids.isEmpty()) {
+ ArrayList<com.juick.Message> msgs = MessagesQueries.getMessages(sql, mids);
+ if (msgs != null && !msgs.isEmpty()) {
+ String json = com.juick.json.Messages.arrayToString(msgs);
+ Main.replyJSON(request, response, json);
+ } else {
+ response.sendError(404);
+ }
+ } 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);
com.juick.User user = MessagesQueries.getMessageAuthor(sql, mid);