diff options
author | Vitaly Takmazov | 2016-11-15 14:21:27 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-11-15 14:21:27 +0300 |
commit | 51d9de02265d6cc9d6045d79497d2a987ae2f7f7 (patch) | |
tree | d7dd2e534452cab45b8ebdba1e52c498951c5035 /juick-api/src | |
parent | 32a6feb195171e06d60117ad758cc8beb50e5ca3 (diff) |
core classes are now serializeable with JAXB (to use as babbler extension)
Diffstat (limited to 'juick-api/src')
7 files changed, 31 insertions, 31 deletions
diff --git a/juick-api/src/main/java/com/juick/api/Main.java b/juick-api/src/main/java/com/juick/api/Main.java index 80cbecd4..c102bf18 100644 --- a/juick-api/src/main/java/com/juick/api/Main.java +++ b/juick-api/src/main/java/com/juick/api/Main.java @@ -308,7 +308,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { xmsg.addChild(jmsg); Nickname nick = new Nickname(); - nick.Nickname = "@" + jmsg.getUser().getUName(); + nick.Nickname = "@" + jmsg.getUser().getName(); xmsg.addChild(nick); if (attachmentFName != null) { @@ -334,7 +334,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { for (String tag : tagsArr) { tagsStr2 += " *" + tag; } - xmsg.body = "@" + jmsg.getUser().getUName() + ":" + tagsStr2 + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid; + xmsg.body = "@" + jmsg.getUser().getName() + ":" + tagsStr2 + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid; xmsg.to = new JID("juick", "s2s.juick.com", null); xmpp.send(xmsg); @@ -391,8 +391,8 @@ public class Main extends HttpServlet implements Stream.StreamListener { } body = body.replace("\r", ""); - if ((msg.ReadOnly && msg.getUser().getUID() != vuid) || UserQueries.isInBLAny(sql, msg.getUser().getUID(), vuid) - || (reply != null && UserQueries.isInBLAny(sql, reply.getUser().getUID(), vuid))) { + if ((msg.ReadOnly && msg.getUser().getUid() != vuid) || UserQueries.isInBLAny(sql, msg.getUser().getUid(), vuid) + || (reply != null && UserQueries.isInBLAny(sql, reply.getUser().getUid(), vuid))) { response.sendError(403); return; } @@ -436,7 +436,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { } Nickname nick = new Nickname(); - nick.Nickname = "@" + jmsg.getUser().getUName(); + nick.Nickname = "@" + jmsg.getUser().getName(); xmsg.addChild(nick); if (attachmentFName != null) { @@ -458,7 +458,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { xmsg.addChild(xoob); } - xmsg.body = "Reply by @" + jmsg.getUser().getUName() + ":\n>" + quote + "\n" + body + "\n\n#" + mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew; + xmsg.body = "Reply by @" + jmsg.getUser().getName() + ":\n>" + quote + "\n" + body + "\n\n#" + mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew; xmsg.to = new JID("juick", "s2s.juick.com", null); xmpp.send(xmsg); diff --git a/juick-api/src/main/java/com/juick/api/Messages.java b/juick-api/src/main/java/com/juick/api/Messages.java index d9d506f3..de845d45 100644 --- a/juick-api/src/main/java/com/juick/api/Messages.java +++ b/juick-api/src/main/java/com/juick/api/Messages.java @@ -71,16 +71,16 @@ public class Messages { User user = UserQueries.getUserByName(sql, uname); if (user != null) { if (!StringUtils.isEmpty(media)) { - mids = MessagesQueries.getUserPhotos(sql, user.getUID(), 0, before_mid); + mids = MessagesQueries.getUserPhotos(sql, user.getUid(), 0, before_mid); } else if (!StringUtils.isEmpty(tag)) { Tag tagObject = TagQueries.getTag(sql, tag, false); if (tagObject != null) { - mids = MessagesQueries.getUserTag(sql, user.getUID(), tagObject.TID, 0, before_mid); + mids = MessagesQueries.getUserTag(sql, user.getUid(), tagObject.TID, 0, before_mid); } else { response.sendError(404); } } else { - mids = MessagesQueries.getUserBlog(sql, user.getUID(), 0, before_mid); + mids = MessagesQueries.getUserBlog(sql, user.getUid(), 0, before_mid); } } else { response.sendError(404); @@ -144,7 +144,7 @@ public class Messages { throws ServletException, IOException { int mid = NumberUtils.toInt(request.getParameter("mid"), 0); com.juick.User user = MessagesQueries.getMessageAuthor(sql, mid); - if (user != null && user.getUID() == 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); diff --git a/juick-api/src/main/java/com/juick/api/Notifications.java b/juick-api/src/main/java/com/juick/api/Notifications.java index bec365ba..60fe95f3 100644 --- a/juick-api/src/main/java/com/juick/api/Notifications.java +++ b/juick-api/src/main/java/com/juick/api/Notifications.java @@ -29,7 +29,7 @@ public class Notifications { public void doGet(HttpServletRequest request, HttpServletResponse response, int vuid) throws IOException { User visitor = UserQueries.getUserByUID(jdbc, vuid).orElse(new User()); - if ((visitor.getUID() == 0) || !(visitor.getUName().equals("juick"))) { + if ((visitor.getUid() == 0) || !(visitor.getName().equals("juick"))) { response.sendError(403); return; } @@ -57,13 +57,13 @@ public class Notifications { Message msg = MessagesQueries.getMessage(jdbc, mid); if (msg != null) { List<User> users; - if (msg.getRID() > 0) { - users = SubscriptionsQueries.getUsersSubscribedToComments(jdbc, mid, msg.getUser().getUID()); + if (msg.getRid() > 0) { + users = SubscriptionsQueries.getUsersSubscribedToComments(jdbc, mid, msg.getUser().getUid()); } else { - users = SubscriptionsQueries.getSubscribedUsers(jdbc, msg.getUser().getUID(), mid); + users = SubscriptionsQueries.getSubscribedUsers(jdbc, msg.getUser().getUid(), mid); } - List<Integer> uids = users.stream().map(User::getUID).collect(Collectors.toList()); + List<Integer> uids = users.stream().map(User::getUid).collect(Collectors.toList()); switch (type) { case "gcm": diff --git a/juick-api/src/main/java/com/juick/api/PM.java b/juick-api/src/main/java/com/juick/api/PM.java index 44c43f89..d8f17366 100644 --- a/juick-api/src/main/java/com/juick/api/PM.java +++ b/juick-api/src/main/java/com/juick/api/PM.java @@ -94,11 +94,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.getUser().getUName(), "juick.com", "Juick"); + mm.from = new JID(jmsg.getUser().getName(), "juick.com", "Juick"); mm.body = body; } else { mm.from = new JID("juick", "juick.com", "Juick"); - mm.body = "Private message from @" + jmsg.getUser().getUName() + ":\n" + body; + mm.body = "Private message from @" + jmsg.getUser().getName() + ":\n" + body; } xmpp.send(mm); } diff --git a/juick-api/src/main/java/com/juick/api/Subscriptions.java b/juick-api/src/main/java/com/juick/api/Subscriptions.java index 4c767dc9..f8bd162f 100644 --- a/juick-api/src/main/java/com/juick/api/Subscriptions.java +++ b/juick-api/src/main/java/com/juick/api/Subscriptions.java @@ -26,7 +26,7 @@ public class Subscriptions { } public void doGet(HttpServletRequest request, HttpServletResponse response, int vuid) throws IOException { User visitor = UserQueries.getUserByUID(jdbc, vuid).orElse(new User()); - if ((visitor.getUID() == 0) && !(visitor.getUName().equals("juick"))) { + if ((visitor.getUid() == 0) && !(visitor.getName().equals("juick"))) { response.sendError(403); return; } @@ -39,7 +39,7 @@ public class Subscriptions { // thread Message msg = MessagesQueries.getMessage(jdbc, mid); if (msg != null) { - List<User> users = SubscriptionsQueries.getUsersSubscribedToComments(jdbc, mid, msg.getUser().getUID()); + List<User> users = SubscriptionsQueries.getUsersSubscribedToComments(jdbc, mid, msg.getUser().getUid()); Main.replyJSON(request, response, userSerializer.serializeList(users)); } } diff --git a/juick-api/src/main/java/com/juick/api/TelegramBotHook.java b/juick-api/src/main/java/com/juick/api/TelegramBotHook.java index 2ec380db..e089250b 100644 --- a/juick-api/src/main/java/com/juick/api/TelegramBotHook.java +++ b/juick-api/src/main/java/com/juick/api/TelegramBotHook.java @@ -72,10 +72,10 @@ public class TelegramBotHook { com.juick.Message jmsg = ms.deserialize(new JSONObject(text)); logger.info("got jmsg: " + ms.serialize(jmsg).toString()); String msgUrl = formatUrl(jmsg); - if (jmsg.getRID() == 0) { + if (jmsg.getRid() == 0) { String msg = formatPost(jmsg); - List<Long> users = getSubscribers(jmsg.getUser().getUID()); + List<Long> users = getSubscribers(jmsg.getUser().getUid()); List<Long> chats = getChats(); // registered subscribed users @@ -84,9 +84,9 @@ public class TelegramBotHook { chats.stream().filter(u -> getUser(u) == 0).forEach(c -> telegramNotify(c, msg, msgUrl)); } else { // get quote - com.juick.Message msg = MessagesQueries.getReply(jdbc, jmsg.getMID(), jmsg.getRID()); + com.juick.Message msg = MessagesQueries.getReply(jdbc, jmsg.getMid(), jmsg.getRid()); String fmsg = formatPost(msg); - getSubscribersToComments(jmsg.getMID(), jmsg.getUser().getUID()).stream() + getSubscribersToComments(jmsg.getMid(), jmsg.getUser().getUid()).stream() .forEach(c -> telegramNotify(c, fmsg, msgUrl)); } } @@ -141,7 +141,7 @@ public class TelegramBotHook { } logger.info(String.format("got telegram msg %s", message.toString())); User user_from = UserQueries.getUserByUID(jdbc, getUser(message.chat().id())).orElse(new User()); - logger.info(String.format("Found juick user %d", user_from.getUID())); + logger.info(String.format("Found juick user %d", user_from.getUid())); List<Long> chats = getChats(); String username = message.from().username(); @@ -154,14 +154,14 @@ public class TelegramBotHook { createTelegramUser(message.from().id(), username); telegramSignupNotify(message.from().id().longValue(), UserQueries.getSignUpHashByTelegramID(jdbc, message.from().id().longValue(), username)); } else { - if (user_from.getUID() == 0) { + if (user_from.getUid() == 0) { telegramSignupNotify(message.from().id().longValue(), UserQueries.getSignUpHashByTelegramID(jdbc, message.from().id().longValue(), username)); } else { String text = message.text(); if (text != null) { if (text.equalsIgnoreCase("/login")) { - String msg = String.format("Hi, %s!\nTap to log in", user_from.getUName()); - String msgUrl = "http://juick.com/login?" + UserQueries.getHashByUID(jdbc, user_from.getUID()); + String msg = String.format("Hi, %s!\nTap to log in", user_from.getName()); + String msgUrl = "http://juick.com/login?" + UserQueries.getHashByUID(jdbc, user_from.getUid()); telegramNotify(message.from().id().longValue(), msg, msgUrl); } /* else { ProtocolReply reply = protocol.getReply(user_from, text); diff --git a/juick-api/src/main/java/com/juick/api/Users.java b/juick-api/src/main/java/com/juick/api/Users.java index 2be288bc..a98af7a8 100644 --- a/juick-api/src/main/java/com/juick/api/Users.java +++ b/juick-api/src/main/java/com/juick/api/Users.java @@ -80,8 +80,8 @@ public class Users { } else { if (UserUtils.checkUserNameValid(uname)) { com.juick.User u = UserQueries.getUserByName(sql, uname); - if (u != null && u.getUID() > 0) { - uid = u.getUID(); + if (u != null && u.getUid() > 0) { + uid = u.getUid(); } } } @@ -110,8 +110,8 @@ public class Users { } else { if (UserUtils.checkUserNameValid(uname)) { com.juick.User u = UserQueries.getUserByName(sql, uname); - if (u != null && u.getUID() > 0) { - uid = u.getUID(); + if (u != null && u.getUid() > 0) { + uid = u.getUid(); } } } |