From 0742847f430b02d2d9031f1a11799ac7076e9e26 Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Tue, 5 Aug 2014 04:49:24 +0700 Subject: Messages.setPrivacy --- src/java/com/juick/api/Main.java | 2 ++ src/java/com/juick/api/Messages.java | 10 ++++++++++ 2 files changed, 12 insertions(+) (limited to 'src/java/com') diff --git a/src/java/com/juick/api/Main.java b/src/java/com/juick/api/Main.java index 71b70839..5ee4027b 100644 --- a/src/java/com/juick/api/Main.java +++ b/src/java/com/juick/api/Main.java @@ -168,6 +168,8 @@ public class Main extends HttpServlet implements Stream.StreamListener { } } else if (uri.equals("/messages/set_popular") && vuid == 1) { messages.doSetPopular(request, response, xmpp); + } else if (uri.equals("/messages/set_privacy") && vuid > 0) { + messages.doSetPrivacy(request, response, xmpp, vuid); } else { response.sendError(404); } diff --git a/src/java/com/juick/api/Messages.java b/src/java/com/juick/api/Messages.java index b7d0891e..b5462258 100644 --- a/src/java/com/juick/api/Messages.java +++ b/src/java/com/juick/api/Messages.java @@ -41,6 +41,16 @@ public class Messages { } } + 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); + 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 popular = Utils.parseInt(request.getParameter("popular"), 0); -- cgit v1.2.3