aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/api')
-rw-r--r--src/main/java/com/juick/api/Messages.java23
-rw-r--r--src/main/java/com/juick/api/Others.java4
-rw-r--r--src/main/java/com/juick/api/PM.java16
-rw-r--r--src/main/java/com/juick/api/Users.java20
4 files changed, 42 insertions, 21 deletions
diff --git a/src/main/java/com/juick/api/Messages.java b/src/main/java/com/juick/api/Messages.java
index fb9be051..e242d05b 100644
--- a/src/main/java/com/juick/api/Messages.java
+++ b/src/main/java/com/juick/api/Messages.java
@@ -53,7 +53,9 @@ public class Messages {
this.sql = sql;
}
- public void doGetHome(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException {
+ public void doGetHome(HttpServletRequest request,
+ HttpServletResponse response, int vuid)
+ throws ServletException, IOException {
int before_mid = Utils.parseInt(request.getParameter("before_mid"), 0);
List<Integer> mids = MessagesQueries.getMyFeed(sql, vuid, before_mid);
@@ -70,7 +72,8 @@ public class Messages {
}
}
- public void doGet(HttpServletRequest request, HttpServletResponse response, int vuid)
+ 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);
@@ -81,7 +84,9 @@ public class Messages {
}
- public void doGetRecommended(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException {
+ 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);
@@ -98,17 +103,21 @@ public class Messages {
}
}
- public void doSetPrivacy(HttpServletRequest request, HttpServletResponse response, Stream xmpp, int vuid) throws ServletException, IOException {
+ 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)) {
+ if (user != null && user.getUID() == 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 {
+ 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);
@@ -123,7 +132,7 @@ public class Messages {
msg.from = new JID("juick", "juick.com", null);
msg.to = new JID(null, "crosspost.juick.com", null);
JuickMessage jmsg = new JuickMessage(m);
- jmsg.User.UID = 11574;
+ jmsg.setUser(UserQueries.getUserByUID(sql, 11574));
msg.childs.add(jmsg);
msg.to.Username = "twitter";
diff --git a/src/main/java/com/juick/api/Others.java b/src/main/java/com/juick/api/Others.java
index 3c8d4a96..12849f90 100644
--- a/src/main/java/com/juick/api/Others.java
+++ b/src/main/java/com/juick/api/Others.java
@@ -26,7 +26,9 @@ public class Others {
this.sql = sql;
}
- public void doGetGroupsPMs(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException {
+ public void doGetGroupsPMs(HttpServletRequest request,
+ HttpServletResponse response, int vuid)
+ throws ServletException, IOException {
int cnt = 5;
try {
String cntStr = request.getParameter("cnt");
diff --git a/src/main/java/com/juick/api/PM.java b/src/main/java/com/juick/api/PM.java
index 01a5669a..3ca9eada 100644
--- a/src/main/java/com/juick/api/PM.java
+++ b/src/main/java/com/juick/api/PM.java
@@ -29,7 +29,9 @@ public class PM {
this.sql = sql;
}
- public void doGetPM(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException {
+ public void doGetPM(HttpServletRequest request,
+ HttpServletResponse response, int vuid)
+ throws ServletException, IOException {
String uname = request.getParameter("uname");
int uid = 0;
if (uname != null && uname.matches("^[a-zA-Z0-9\\-]{2,16}$")) {
@@ -50,7 +52,9 @@ public class PM {
}
}
- public void doPostPM(HttpServletRequest request, HttpServletResponse response, Stream xmpp, int vuid) throws ServletException, IOException {
+ public void doPostPM(HttpServletRequest request,
+ HttpServletResponse response, Stream xmpp, int vuid)
+ throws ServletException, IOException {
String uname = request.getParameter("uname");
int uid = 0;
if (UserQueries.checkUserNameValid(uname)) {
@@ -73,8 +77,8 @@ public class PM {
msg.from = new JID("juick", "juick.com", null);
msg.to = new JID(Integer.toString(uid), "push.juick.com", null);
JuickMessage jmsg = new JuickMessage();
- jmsg.User = UserQueries.getUserByUID(sql, vuid);
- jmsg.Text = body;
+ jmsg.setUser(UserQueries.getUserByUID(sql, vuid));
+ jmsg.setText(body);
msg.childs.add(jmsg);
xmpp.send(msg);
@@ -89,11 +93,11 @@ public class PM {
mm.to = new JID(jid);
mm.type = Message.Type.chat;
if (PMQueries.havePMinRoster(sql, vuid, jid)) {
- mm.from = new JID(jmsg.User.UName, "juick.com", "Juick");
+ mm.from = new JID(jmsg.getUser().getUName(), "juick.com", "Juick");
mm.body = body;
} else {
mm.from = new JID("juick", "juick.com", "Juick");
- mm.body = "Private message from @" + jmsg.User.UName + ":\n" + body;
+ mm.body = "Private message from @" + jmsg.getUser().getUName() + ":\n" + body;
}
xmpp.send(mm);
}
diff --git a/src/main/java/com/juick/api/Users.java b/src/main/java/com/juick/api/Users.java
index d3818a5a..57f8c4b9 100644
--- a/src/main/java/com/juick/api/Users.java
+++ b/src/main/java/com/juick/api/Users.java
@@ -27,7 +27,9 @@ public class Users {
this.sql = sql;
}
- public void doGetUsers(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException {
+ public void doGetUsers(HttpServletRequest request,
+ HttpServletResponse response, int vuid)
+ throws ServletException, IOException {
List<com.juick.User> users = new ArrayList<>();
String punames[] = request.getParameterValues("uname");
@@ -66,7 +68,9 @@ public class Users {
}
}
- public void doGetUserRead(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException {
+ public void doGetUserRead(HttpServletRequest request,
+ HttpServletResponse response, int vuid)
+ throws ServletException, IOException {
int uid = 0;
String uname = request.getParameter("uname");
if (uname == null) {
@@ -74,8 +78,8 @@ public class Users {
} else {
if (UserQueries.checkUserNameValid(uname)) {
com.juick.User u = UserQueries.getUserByName(sql, uname);
- if (u != null && u.UID > 0) {
- uid = u.UID;
+ if (u != null && u.getUID() > 0) {
+ uid = u.getUID();
}
}
}
@@ -94,7 +98,9 @@ public class Users {
response.sendError(404);
}
- public void doGetUserReaders(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException {
+ public void doGetUserReaders(HttpServletRequest request,
+ HttpServletResponse response, int vuid)
+ throws ServletException, IOException {
int uid = 0;
String uname = request.getParameter("uname");
if (uname == null) {
@@ -102,8 +108,8 @@ public class Users {
} else {
if (UserQueries.checkUserNameValid(uname)) {
com.juick.User u = UserQueries.getUserByName(sql, uname);
- if (u != null && u.UID > 0) {
- uid = u.UID;
+ if (u != null && u.getUID() > 0) {
+ uid = u.getUID();
}
}
}