From 51d9de02265d6cc9d6045d79497d2a987ae2f7f7 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 15 Nov 2016 14:21:27 +0300 Subject: core classes are now serializeable with JAXB (to use as babbler extension) --- .../src/main/java/com/juick/www/Discover.java | 4 +- juick-www/src/main/java/com/juick/www/Home.java | 24 ++-- juick-www/src/main/java/com/juick/www/Login.java | 6 +- juick-www/src/main/java/com/juick/www/Main.java | 26 ++-- .../src/main/java/com/juick/www/NewMessage.java | 34 +++--- juick-www/src/main/java/com/juick/www/PM.java | 14 +-- .../src/main/java/com/juick/www/PageTemplates.java | 54 ++++----- .../src/main/java/com/juick/www/Settings.java | 54 ++++----- juick-www/src/main/java/com/juick/www/SignUp.java | 4 +- .../src/main/java/com/juick/www/TwitterAuth.java | 2 +- juick-www/src/main/java/com/juick/www/User.java | 104 ++++++++-------- .../src/main/java/com/juick/www/UserThread.java | 134 ++++++++++----------- juick-www/src/main/java/com/juick/www/Utils.java | 4 +- 13 files changed, 232 insertions(+), 232 deletions(-) (limited to 'juick-www/src/main/java/com/juick') diff --git a/juick-www/src/main/java/com/juick/www/Discover.java b/juick-www/src/main/java/com/juick/www/Discover.java index 4fd8c3b6..860ad893 100644 --- a/juick-www/src/main/java/com/juick/www/Discover.java +++ b/juick-www/src/main/java/com/juick/www/Discover.java @@ -72,7 +72,7 @@ public class Discover { } } - int visitor_uid = visitor.getUID(); + int visitor_uid = visitor.getUid(); String title = "*" + StringEscapeUtils.escapeHtml4(paramTag.getName()); List mids = MessagesQueries.getTag(sql, paramTag.TID, visitor_uid, paramBefore, (visitor_uid == 0) ? 40 : 20); @@ -91,7 +91,7 @@ public class Discover { out.println("
"); if (mids.size() > 0) { - int vuid = visitor.getUID(); + int vuid = visitor.getUid(); int ad_mid = AdsQueries.getAdMID(sql, vuid); if (ad_mid > 0 && mids.indexOf(ad_mid) == -1) { mids.add(0, ad_mid); diff --git a/juick-www/src/main/java/com/juick/www/Home.java b/juick-www/src/main/java/com/juick/www/Home.java index d8688b68..870c2d55 100644 --- a/juick-www/src/main/java/com/juick/www/Home.java +++ b/juick-www/src/main/java/com/juick/www/Home.java @@ -53,9 +53,9 @@ public class Home { title = "Поиск: " + StringEscapeUtils.escapeHtml4(paramSearch); mids = MessagesQueries.getSearch(sql, sqlSearch, Utils.encodeSphinx(paramSearch), paramBefore); } else if (paramShow == null) { - if (visitor.getUID() > 0) { + if (visitor.getUid() > 0) { title = "Популярные"; - mids = MessagesQueries.getPopular(sql, visitor.getUID(), paramBefore); + mids = MessagesQueries.getPopular(sql, visitor.getUid(), paramBefore); } else { title = "Микроблоги Juick: популярные записи"; mids = MessagesQueries.getPopular(sql, 0, paramBefore); @@ -66,27 +66,27 @@ public class Home { return; } else if (paramShow.equals("my") && visitor != null) { title = "Моя лента"; - mids = MessagesQueries.getMyFeed(sql, visitor.getUID(), paramBefore); + mids = MessagesQueries.getMyFeed(sql, visitor.getUid(), paramBefore); } else if (paramShow.equals("private") && visitor != null) { title = "Приватные"; - mids = MessagesQueries.getPrivate(sql, visitor.getUID(), paramBefore); + mids = MessagesQueries.getPrivate(sql, visitor.getUid(), paramBefore); } else if (paramShow.equals("discuss") && visitor != null) { title = "Обсуждения"; - mids = MessagesQueries.getDiscussions(sql, visitor.getUID(), paramBefore); + mids = MessagesQueries.getDiscussions(sql, visitor.getUid(), paramBefore); } else if (paramShow.equals("recommended") && visitor != null) { title = "Рекомендации"; - mids = MessagesQueries.getRecommended(sql, visitor.getUID(), paramBefore); + mids = MessagesQueries.getRecommended(sql, visitor.getUid(), paramBefore); } else if (paramShow.equals("photos")) { title = "Фотографии"; if (visitor != null) { - mids = MessagesQueries.getPhotos(sql, visitor.getUID(), paramBefore); + mids = MessagesQueries.getPhotos(sql, visitor.getUid(), paramBefore); } else { mids = MessagesQueries.getPhotos(sql, 0, paramBefore); } } else if (paramShow.equals("all")) { title = "Все сообщения"; if (visitor != null) { - mids = MessagesQueries.getAll(sql, visitor.getUID(), paramBefore); + mids = MessagesQueries.getAll(sql, visitor.getUid(), paramBefore); } else { mids = MessagesQueries.getAll(sql, 0, paramBefore); } @@ -110,7 +110,7 @@ public class Home { out.println(""); } - if (visitor.getUID() > 0) { + if (visitor.getUid() > 0) { out.println("
"); out.println("
"); out.println(" "); @@ -129,7 +129,7 @@ public class Home { if (mids.size() > 0) { int ad_mid = 0; if (paramShow == null || paramShow.equals("top") || paramShow.equals("all")) { - int vuid = visitor.getUID(); + int vuid = visitor.getUid(); ad_mid = AdsQueries.getAdMID(sql, vuid); if (ad_mid > 0 && mids.indexOf(ad_mid) == -1) { mids.add(0, ad_mid); @@ -139,7 +139,7 @@ public class Home { } } - PageTemplates.printMessages(out, sql, null, mids, visitor, visitor.getUID() == 0 ? 2 : 3, ad_mid); + PageTemplates.printMessages(out, sql, null, mids, visitor, visitor.getUid() == 0 ? 2 : 3, ad_mid); } if (mids.size() >= 20) { @@ -160,7 +160,7 @@ public class Home { out.println("
"); - PageTemplates.pageHomeColumn(out, sql, visitor, paramShow == null && paramBefore == 0 && paramSearch == null && visitor.getUID() == 0); + PageTemplates.pageHomeColumn(out, sql, visitor, paramShow == null && paramBefore == 0 && paramSearch == null && visitor.getUid() == 0); PageTemplates.pageFooter(request, out, visitor, true); PageTemplates.pageEnd(out); diff --git a/juick-www/src/main/java/com/juick/www/Login.java b/juick-www/src/main/java/com/juick/www/Login.java index 55cfa03c..19cc855b 100644 --- a/juick-www/src/main/java/com/juick/www/Login.java +++ b/juick-www/src/main/java/com/juick/www/Login.java @@ -34,7 +34,7 @@ public class Login { protected void doGetLoginForm(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() > 0) { + if (visitor.getUid() > 0) { Utils.sendTemporaryRedirect(response, "/"); return; } @@ -228,8 +228,8 @@ public class Login { protected void doGetLogout(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() > 0) { - sql.update("DELETE FROM logins WHERE user_id=?", visitor.getUID()); + if (visitor.getUid() > 0) { + sql.update("DELETE FROM logins WHERE user_id=?", visitor.getUid()); } Cookie c = new Cookie("hash", "-"); diff --git a/juick-www/src/main/java/com/juick/www/Main.java b/juick-www/src/main/java/com/juick/www/Main.java index 35617295..4a873cf3 100644 --- a/juick-www/src/main/java/com/juick/www/Main.java +++ b/juick-www/src/main/java/com/juick/www/Main.java @@ -172,7 +172,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { } } else if (uri.equals("/post")) { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() > 0) { + if (visitor.getUid() > 0) { pagesNewMessage.doGetNewMessage(sql, request, response, visitor); } else { Utils.sendTemporaryRedirect(response, "/login"); @@ -185,7 +185,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { } } else if (uri.startsWith("/pm/")) { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() == 0) { + if (visitor.getUid() == 0) { Utils.sendTemporaryRedirect(response, "/login"); } else { switch (uri) { @@ -269,7 +269,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { if (mid > 0) { com.juick.User author = com.juick.server.MessagesQueries.getMessageAuthor(sql, mid); if (author != null) { - Utils.sendPermanentRedirect(response, "/" + author.getUName() + "/" + mid); + Utils.sendPermanentRedirect(response, "/" + author.getName() + "/" + mid); return; } } @@ -277,14 +277,14 @@ public class Main extends HttpServlet implements Stream.StreamListener { } else if (uri.matches("^/[^/]+$")) { com.juick.User user = com.juick.server.UserQueries.getUserByName(sql, request.getRequestURI().substring(1)); if (user != null) { - Utils.sendPermanentRedirect(response, "/" + user.getUName() + "/"); + Utils.sendPermanentRedirect(response, "/" + user.getName() + "/"); } else { Errors.doGet404(sql, request, response); } } else if (uri.matches("^/.+/.*")) { String uriparts[] = uri.split("/"); com.juick.User user = com.juick.server.UserQueries.getUserByName(sql, uriparts[1]); - if (user != null && user.getUName().equals(uriparts[1]) && !user.Banned) { + if (user != null && user.getName().equals(uriparts[1]) && !user.isBanned()) { if (uriparts.length == 2) { // http://juick.com/username/ pagesUser.doGetBlog(sql, sqlSearch, request, response, user); } else if (uriparts[2].equals("tags")) { @@ -302,8 +302,8 @@ public class Main extends HttpServlet implements Stream.StreamListener { if (mid > 0) { com.juick.User author = com.juick.server.MessagesQueries.getMessageAuthor(sql, mid); if (author != null) { - if (!author.getUName().equals(user.getUName())) { - Utils.sendPermanentRedirect(response, "/" + author.getUName() + "/" + mid); + if (!author.getName().equals(user.getName())) { + Utils.sendPermanentRedirect(response, "/" + author.getName() + "/" + mid); } else { pagesUserThread.doGetThread(sql, request, response, mid); } @@ -314,8 +314,8 @@ public class Main extends HttpServlet implements Stream.StreamListener { Errors.doGet404(sql, request, response); } } - } else if (user != null && !user.Banned) { - Utils.sendPermanentRedirect(response, "/" + user.getUName() + "/" + (uriparts.length > 2 ? uriparts[2] : "")); + } else if (user != null && !user.isBanned()) { + Utils.sendPermanentRedirect(response, "/" + user.getName() + "/" + (uriparts.length > 2 ? uriparts[2] : "")); } else { Errors.doGet404(sql, request, response); } @@ -341,7 +341,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { switch (uri) { case "/post": { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() > 0 && !visitor.Banned) { + if (visitor.getUid() > 0 && !visitor.isBanned()) { pagesNewMessage.doPostMessage(sql, request, response, xmpp, visitor); } else { response.sendError(403); @@ -350,7 +350,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { } case "/comment": { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() > 0 && !visitor.Banned) { + if (visitor.getUid() > 0 && !visitor.isBanned()) { pagesNewMessage.doPostComment(sql, request, response, xmpp, visitor); } else { response.sendError(403); @@ -359,7 +359,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { } case "/like": { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() > 0 && !visitor.Banned) { + if (visitor.getUid() > 0 && !visitor.isBanned()) { pagesNewMessage.doPostRecomm(sql, request, response, xmpp, visitor); } else { response.sendError(403); @@ -368,7 +368,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { } case "/pm/send": { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() > 0 && !visitor.Banned) { + if (visitor.getUid() > 0 && !visitor.isBanned()) { pm.doPostPM(sql, request, response, xmpp, visitor); } else { response.sendError(403); diff --git a/juick-www/src/main/java/com/juick/www/NewMessage.java b/juick-www/src/main/java/com/juick/www/NewMessage.java index aaa3e550..310ede73 100644 --- a/juick-www/src/main/java/com/juick/www/NewMessage.java +++ b/juick-www/src/main/java/com/juick/www/NewMessage.java @@ -101,7 +101,7 @@ public class NewMessage { } void printUserTags(JdbcTemplate sql, PrintWriter out, com.juick.User visitor) { - List tags = TagQueries.getUserTagsAll(sql, visitor.getUID()); + List tags = TagQueries.getUserTagsAll(sql, visitor.getUid()); if (tags.isEmpty()) { return; @@ -128,7 +128,7 @@ public class NewMessage { String taglink = ""; try { taglink = "" + StringEscapeUtils.escapeHtml4(tags.get(i).getName()) + ""; } catch (UnsupportedEncodingException e) { } @@ -197,8 +197,8 @@ public class NewMessage { } String attachmentType = attachmentFName != null ? attachmentFName.substring(attachmentFName.length() - 3) : null; - int mid = MessagesQueries.createMessage(sql, visitor.getUID(), body, attachmentType, tags); - SubscriptionsQueries.subscribeMessage(sql, mid, visitor.getUID()); + int mid = MessagesQueries.createMessage(sql, visitor.getUid(), body, attachmentType, tags); + SubscriptionsQueries.subscribeMessage(sql, mid, visitor.getUid()); Message xmsg = new Message(); xmsg.from = new JID("juick", "juick.com", null); @@ -209,7 +209,7 @@ public class NewMessage { xmsg.addChild(jmsg); Nickname nick = new Nickname(); - nick.Nickname = "@" + jmsg.getUser().getUName(); + nick.Nickname = "@" + jmsg.getUser().getName(); xmsg.addChild(nick); if (attachmentFName != null) { @@ -236,7 +236,7 @@ public class NewMessage { 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); @@ -289,12 +289,12 @@ public class NewMessage { out.println("
"); out.println("

Сообщение опубликовано

"); out.println("

Поделитесь своим новым постом в социальных сетях:

"); - if (CrosspostQueries.getTwitterTokens(sql, visitor.getUID()).isPresent()) { + if (CrosspostQueries.getTwitterTokens(sql, visitor.getUid()).isPresent()) { out.println("

Отправить в Twitter

"); } out.println("

Отправить в LiveJournal

"); out.println("

Отправить в ВКонтакте

"); - if (CrosspostQueries.getFacebookToken(sql, visitor.getUID()).isPresent()) { + if (CrosspostQueries.getFacebookToken(sql, visitor.getUid()).isPresent()) { out.println("

Отправить в Facebook

"); } out.println("

Отправить в Google+

"); @@ -337,7 +337,7 @@ public class NewMessage { } body = body.replace("\r", ""); - if ((msg.ReadOnly && msg.getUser().getUID() != visitor.getUID()) || UserQueries.isInBLAny(sql, msg.getUser().getUID(), visitor.getUID()) || (reply != null && UserQueries.isInBLAny(sql, reply.getUser().getUID(), visitor.getUID()))) { + if ((msg.ReadOnly && msg.getUser().getUid() != visitor.getUid()) || UserQueries.isInBLAny(sql, msg.getUser().getUid(), visitor.getUid()) || (reply != null && UserQueries.isInBLAny(sql, reply.getUser().getUid(), visitor.getUid()))) { response.sendError(403); return; } @@ -363,8 +363,8 @@ public class NewMessage { } String attachmentType = attachmentFName != null ? attachmentFName.substring(attachmentFName.length() - 3) : null; - int ridnew = MessagesQueries.createReply(sql, mid, rid, visitor.getUID(), body, attachmentType); - SubscriptionsQueries.subscribeMessage(sql, mid, visitor.getUID()); + int ridnew = MessagesQueries.createReply(sql, mid, rid, visitor.getUid(), body, attachmentType); + SubscriptionsQueries.subscribeMessage(sql, mid, visitor.getUid()); Message xmsg = new Message(); xmsg.from = new JID("juick", "juick.com", null); @@ -380,7 +380,7 @@ public class NewMessage { } Nickname nick = new Nickname(); - nick.Nickname = "@" + jmsg.getUser().getUName(); + nick.Nickname = "@" + jmsg.getUser().getName(); xmsg.addChild(nick); if (attachmentFName != null) { @@ -404,7 +404,7 @@ public class NewMessage { if (xmpp != null) { - 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); @@ -418,7 +418,7 @@ public class NewMessage { logger.warn("XMPP unavailable"); } - Utils.sendTemporaryRedirect(response, "/" + msg.getUser().getUName() + "/" + mid + "#" + ridnew); + Utils.sendTemporaryRedirect(response, "/" + msg.getUser().getName() + "/" + mid + "#" + ridnew); } public void doPostRecomm(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, Stream xmpp, com.juick.User visitor) throws ServletException, IOException { @@ -432,12 +432,12 @@ public class NewMessage { response.sendError(404); return; } - if (msg.getUser().getUID() == visitor.getUID()) { + if (msg.getUser().getUid() == visitor.getUid()) { response.sendError(403); return; } - boolean res = MessagesQueries.recommendMessage(sql, mid, visitor.getUID()); + boolean res = MessagesQueries.recommendMessage(sql, mid, visitor.getUid()); if (res) { if (xmpp != null) { @@ -445,7 +445,7 @@ public class NewMessage { xmsg.from = new JID("juick", "juick.com", null); xmsg.to = new JID("recomm", "s2s.juick.com", null); JuickMessage jmsg = new JuickMessage(); - jmsg.setMID(mid); + jmsg.setMid(mid); jmsg.setUser(new JuickUser(visitor)); xmsg.addChild(jmsg); xmpp.send(xmsg); diff --git a/juick-www/src/main/java/com/juick/www/PM.java b/juick-www/src/main/java/com/juick/www/PM.java index 8190d65b..2e35ec1c 100644 --- a/juick-www/src/main/java/com/juick/www/PM.java +++ b/juick-www/src/main/java/com/juick/www/PM.java @@ -50,7 +50,7 @@ public class PM { protected void doGetInbox(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException, PebbleException { String title = "PM: Inbox"; - List msgs = PMQueries.getLastPMInbox(sql, visitor.getUID()); + List msgs = PMQueries.getLastPMInbox(sql, visitor.getUid()); msgs.forEach(m -> m.setText(Utils.formatMessage(m.getText()))); response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { @@ -67,7 +67,7 @@ public class PM { protected void doGetSent(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException, PebbleException { String title = "PM: Sent"; - List msgs = PMQueries.getLastPMSent(sql, visitor.getUID()); + List msgs = PMQueries.getLastPMSent(sql, visitor.getUid()); String uname = request.getParameter("uname"); if (!UserUtils.checkUserNameValid(uname)) { @@ -103,12 +103,12 @@ public class PM { return; } - if (UserQueries.isInBLAny(sql, uid, visitor.getUID())) { + if (UserQueries.isInBLAny(sql, uid, visitor.getUid())) { response.sendError(403); return; } - if (PMQueries.createPM(sql, visitor.getUID(), uid, body)) { + if (PMQueries.createPM(sql, visitor.getUid(), uid, body)) { if (xmpp != null) { Message msg = new Message(); msg.from = new JID("juick", "juick.com", null); @@ -127,12 +127,12 @@ public class PM { Message mm = new Message(); mm.to = new JID(jid); mm.type = Message.Type.chat; - if (PMQueries.havePMinRoster(sql, visitor.getUID(), jid)) { - mm.from = new JID(jmsg.getUser().getUName(), "juick.com", "Juick"); + if (PMQueries.havePMinRoster(sql, visitor.getUid(), jid)) { + 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-www/src/main/java/com/juick/www/PageTemplates.java b/juick-www/src/main/java/com/juick/www/PageTemplates.java index f8873739..4f7e17b7 100644 --- a/juick-www/src/main/java/com/juick/www/PageTemplates.java +++ b/juick-www/src/main/java/com/juick/www/PageTemplates.java @@ -72,7 +72,7 @@ public class PageTemplates { out.println(""); out.println(""); out.flush(); - if (visitor.getUID() > 0) { + if (visitor.getUid() > 0) { out.println(""); } else { out.println(""); @@ -93,7 +93,7 @@ public class PageTemplates { } out.println("/>"); out.println("
"); - if (visitor.getUID() > 0) { + if (visitor.getUid() > 0) { out.print(" "); out.print(" "); } else { @@ -151,7 +151,7 @@ public class PageTemplates { String queryString = request.getQueryString(); String requestURI = request.getRequestURI(); - if (sapeon && sape != null && (visitor.getUID() == 0 || visitor.getUID() == 1) && queryString == null) { + if (sapeon && sape != null && (visitor.getUid() == 0 || visitor.getUid() == 1) && queryString == null) { String links = sape.getPageLinks(requestURI, request.getCookies()).render(); if (links != null && !links.isEmpty()) { out.print("
Спонсоры: " + links); @@ -284,7 +284,7 @@ public class PageTemplates { for (int i = 0; i < msgs.size(); i++) { com.juick.Message msg = msgs.get(i); - if (msg.getMID() == ad_mid) { + if (msg.getMid() == ad_mid) { msgs.remove(i); msgs.add(0, msg); break; @@ -294,43 +294,43 @@ public class PageTemplates { List blUIDs = new ArrayList(20); if (visitor != null) { for (Message msg : msgs) { - blUIDs.add(msg.getUser().getUID()); + blUIDs.add(msg.getUser().getUid()); } - blUIDs = UserQueries.checkBL(sql, visitor.getUID(), blUIDs); + blUIDs = UserQueries.checkBL(sql, visitor.getUid(), blUIDs); } for (Message msg : msgs) { - List tags = MessagesQueries.getMessageTags(sql, msg.getMID()); + List tags = MessagesQueries.getMessageTags(sql, msg.getMid()); String tagsStr = formatTags(tags); if (msg.ReadOnly) { tagsStr += "readonly"; } - if (msg.Privacy < 0) { + if (msg.getPrivacy() < 0) { tagsStr += "friends"; } - if (msg.getMID() == ad_mid) { + if (msg.getMid() == ad_mid) { tagsStr += "реклама"; } String txt; - if (msg.Tags.stream().anyMatch(t -> t.getName().equals("code"))) { + if (msg.getTags().stream().anyMatch(t -> t.getName().equals("code"))) { txt = Utils.formatMessageCode(msg.getText()); } else { txt = Utils.formatMessage(msg.getText()); } - out.println("
"); + out.println("
"); out.println("
"); - out.println(" @" + msg.getUser().getUName() + ":"); - out.println("
\""
"); - out.println(" "); + out.println(" @" + msg.getUser().getName() + ":"); + out.println("
\""
"); + out.println(" "); out.println("
" + tagsStr + "
"); out.println("
"); if (msg.AttachmentType != null) { - String fname = msg.getMID() + "." + msg.AttachmentType; + String fname = msg.getMid() + "." + msg.AttachmentType; out.println("

\"\"/

"); } out.println("

" + txt + "

"); @@ -338,21 +338,21 @@ public class PageTemplates { out.println("
"); } out.print("
"); diff --git a/juick-www/src/main/java/com/juick/www/Settings.java b/juick-www/src/main/java/com/juick/www/Settings.java index 6be16acc..5c25564f 100644 --- a/juick-www/src/main/java/com/juick/www/Settings.java +++ b/juick-www/src/main/java/com/juick/www/Settings.java @@ -71,7 +71,7 @@ public class Settings { protected void doGet(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, PebbleException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() == 0) { + if (visitor.getUid() == 0) { response.sendRedirect("/login"); } List pages = Arrays.asList("main", "password", "about", "auth-email", "privacy"); @@ -95,17 +95,17 @@ public class Settings { List hours = IntStream.rangeClosed(0, 23).boxed() .map(i -> StringUtils.leftPad(String.format("%d", i), 2, "0")).collect(Collectors.toList()); context.put("hours", hours); - context.put("fbstatus", CrosspostQueries.isFBCrossPostEnabled(sql, visitor.getUID())); - context.put("twitter_name", CrosspostQueries.getTwitterName(sql, visitor.getUID())); - context.put("telegram_name", CrosspostQueries.getTelegramName(sql, visitor.getUID())); + context.put("fbstatus", CrosspostQueries.isFBCrossPostEnabled(sql, visitor.getUid())); + context.put("twitter_name", CrosspostQueries.getTwitterName(sql, visitor.getUid())); + context.put("telegram_name", CrosspostQueries.getTelegramName(sql, visitor.getUid())); context.put("notify_options", SubscriptionsQueries.getNotifyOptions(sql, visitor)); context.put("userinfo", UserQueries.getUserInfo(sql, visitor)); if (page.equals("auth-email")) { try { String account = sql.queryForObject("SELECT account FROM auth WHERE user_id=? AND protocol='email' AND authcode=?", - String.class, visitor.getUID(), request.getParameter("code")); - sql.update("INSERT INTO emails(user_id,email) VALUES (?,?)", visitor.getUID(), account); - sql.update("DELETE FROM auth WHERE user_id=? AND authcode=?", visitor.getUID(), request.getParameter("code")); + String.class, visitor.getUid(), request.getParameter("code")); + sql.update("INSERT INTO emails(user_id,email) VALUES (?,?)", visitor.getUid(), account); + sql.update("DELETE FROM auth WHERE user_id=? AND authcode=?", visitor.getUid(), request.getParameter("code")); context.put("result", "OK!"); } catch (EmptyResultDataAccessException e) { context.put("result", "Sorry, code unknown."); @@ -117,7 +117,7 @@ public class Settings { protected void doPost(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, PebbleException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() == 0) { + if (visitor.getUid() == 0) { response.sendError(400); return; } @@ -134,7 +134,7 @@ public class Settings { case "password": if (UserQueries.updatePassword(sql, visitor, request.getParameter("password"))) { result = "

Password has been changed.

"; - String hash = com.juick.server.UserQueries.getHashByUID(sql, visitor.getUID()); + String hash = com.juick.server.UserQueries.getHashByUID(sql, visitor.getUid()); Cookie c = new Cookie("hash", hash); c.setMaxAge(365 * 24 * 60 * 60); response.addCookie(c); @@ -158,8 +158,8 @@ public class Settings { String avatarTmpPath = Utils.receiveMultiPartFile(request, "avatar"); if (StringUtils.isNotEmpty(avatarTmpPath)) { String originalExtension = FilenameUtils.getExtension(avatarTmpPath); - String originalName = String.format("%s.%s", visitor.getUID(), originalExtension); - String targetName = String.format("%s.png", visitor.getUID()); + String originalName = String.format("%s.%s", visitor.getUid(), originalExtension); + String targetName = String.format("%s.png", visitor.getUid()); Path ao = Paths.get(imgPath, "ao", originalName); Path a = Paths.get(imgPath, "a", targetName); Path as = Paths.get(imgPath, "as", targetName); @@ -168,16 +168,16 @@ public class Settings { Thumbnails.of(ao.toFile()).size(32, 32).toFile(as.toFile()); } if (UserQueries.updateUserInfo(sql, visitor, info)) { - result = String.format("

Your info is updated.

Back to blog.

", visitor.getUName()); + result = String.format("

Your info is updated.

Back to blog.

", visitor.getName()); } break; case "jid-del": String[] params = request.getParameter("delete").split(";", 2); int res = -1; if (params[0].equals("xmpp")) { - res = sql.update("DELETE FROM jids WHERE user_id=? AND jid=?", visitor.getUID(), params[1]); + res = sql.update("DELETE FROM jids WHERE user_id=? AND jid=?", visitor.getUid(), params[1]); } else if (params[0].equals("xmpp-unauth")) { - res = sql.update("DELETE FROM auth WHERE user_id=? AND protocol='xmpp' AND account=?", visitor.getUID(), params[1]); + res = sql.update("DELETE FROM auth WHERE user_id=? AND protocol='xmpp' AND account=?", visitor.getUid(), params[1]); } if (res == 1) { result = "

Deleted. Back.

"; @@ -198,11 +198,11 @@ public class Settings { case "email-add": try { sql.queryForObject("SELECT authcode FROM auth WHERE user_id=? AND protocol='email' " + - "AND account=?", String.class, visitor.getUID(), request.getParameter("account")); + "AND account=?", String.class, visitor.getUid(), request.getParameter("account")); } catch (EmptyResultDataAccessException e) { String authCode = UserUtils.generateHash(8); if (sql.update("INSERT INTO auth(user_id,protocol,account,authcode) VALUES (?,'email',?,?)", - visitor.getUID(), request.getParameter("account"), authCode) > 0) { + visitor.getUid(), request.getParameter("account"), authCode) > 0) { Session session = Session.getDefaultInstance(System.getProperties()); try { MimeMessage message = new MimeMessage(session); @@ -225,18 +225,18 @@ public class Settings { } break; case "email-del": - if (sql.update("DELETE FROM emails WHERE user_id=? AND email=?", visitor.getUID(), request.getParameter("account")) > 0) { + if (sql.update("DELETE FROM emails WHERE user_id=? AND email=?", visitor.getUid(), request.getParameter("account")) > 0) { result = "

Deleted. Back.

"; } else { result = "

An error occured while deleting.

"; } break; case "email-subscr": - sql.update("UPDATE emails SET subscr_hour=NULL WHERE user_id=?", visitor.getUID()); + sql.update("UPDATE emails SET subscr_hour=NULL WHERE user_id=?", visitor.getUid()); String email = request.getParameter("account"); if (StringUtils.isNotEmpty(email)) { sql.update("UPDATE emails SET subscr_hour=? WHERE user_id=? AND email=?", - request.getParameter("time"), visitor.getUID(), email); + request.getParameter("time"), visitor.getUid(), email); result = String.format("

Saved! Will send to %s at %s:00 GMT." + "

Back

", email, request.getParameter("time")); } else { @@ -244,8 +244,8 @@ public class Settings { } break; case "twitter-del": - sql.update("DELETE FROM twitter WHERE user_id=?", visitor.getUID()); - sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=1741", visitor.getUID()); + sql.update("DELETE FROM twitter WHERE user_id=?", visitor.getUid()); + sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=1741", visitor.getUid()); for (Cookie cookie : request.getCookies()) { if (cookie.getName().equals("request_token")) { cookie.setMaxAge(0); @@ -259,21 +259,21 @@ public class Settings { result = "

Back

"; break; case "telegram-del": - sql.update("DELETE FROM telegram WHERE user_id=?", visitor.getUID()); + sql.update("DELETE FROM telegram WHERE user_id=?", visitor.getUid()); result = "

Back

"; break; case "facebook-disable": - sql.update("UPDATE facebook SET crosspost=0 WHERE user_id=?", visitor.getUID()); - sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=5863", visitor.getUID()); + sql.update("UPDATE facebook SET crosspost=0 WHERE user_id=?", visitor.getUid()); + sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=5863", visitor.getUid()); result = "

Back

"; break; case "facebook-enable": - sql.update("UPDATE facebook SET crosspost=1 WHERE user_id=?", visitor.getUID()); - sql.update("INSERT INTO subscr_users(user_id,suser_id,jid,active) VALUES (?,5863,'juick@facebook.juick.com',1)", visitor.getUID()); + sql.update("UPDATE facebook SET crosspost=1 WHERE user_id=?", visitor.getUid()); + sql.update("INSERT INTO subscr_users(user_id,suser_id,jid,active) VALUES (?,5863,'juick@facebook.juick.com',1)", visitor.getUid()); result = "

Back

"; break; case "vk-del": - sql.update("DELETE FROM vk WHERE user_id=?", visitor.getUID()); + sql.update("DELETE FROM vk WHERE user_id=?", visitor.getUid()); result = "

Back

"; break; default: diff --git a/juick-www/src/main/java/com/juick/www/SignUp.java b/juick-www/src/main/java/com/juick/www/SignUp.java index 43c82a9a..ea40c810 100644 --- a/juick-www/src/main/java/com/juick/www/SignUp.java +++ b/juick-www/src/main/java/com/juick/www/SignUp.java @@ -97,7 +97,7 @@ public class SignUp { String action = request.getParameter("action"); if (action.charAt(0) == 'l') { - if (visitor.getUID() == 0) { + if (visitor.getUid() == 0) { String username = request.getParameter("username"); String password = request.getParameter("password"); if (username == null || password == null || username.length() > 32 || password.isEmpty()) { @@ -106,7 +106,7 @@ public class SignUp { } uid = com.juick.server.UserQueries.checkPassword(sql, username, password); } else { - uid = visitor.getUID(); + uid = visitor.getUid(); } if (uid <= 0) { diff --git a/juick-www/src/main/java/com/juick/www/TwitterAuth.java b/juick-www/src/main/java/com/juick/www/TwitterAuth.java index d4be4335..173ad7b7 100644 --- a/juick-www/src/main/java/com/juick/www/TwitterAuth.java +++ b/juick-www/src/main/java/com/juick/www/TwitterAuth.java @@ -48,7 +48,7 @@ public class TwitterAuth { } } com.juick.User user = UserQueries.getUserByHash(sql, hash); - if ( user == null || user.getUID() == 0) { + if ( user == null || user.getUid() == 0) { response.sendError(403); return; } diff --git a/juick-www/src/main/java/com/juick/www/User.java b/juick-www/src/main/java/com/juick/www/User.java index 967d06c7..3cc38b37 100644 --- a/juick-www/src/main/java/com/juick/www/User.java +++ b/juick-www/src/main/java/com/juick/www/User.java @@ -58,7 +58,7 @@ public class User { Errors.doGet404(sql, request, response); return; } else if (!paramTag.getName().equals(paramTagStr)) { - String url = "/" + user.getUName() + "/?tag=" + URLEncoder.encode(paramTag.getName(), "UTF-8"); + String url = "/" + user.getName() + "/?tag=" + URLEncoder.encode(paramTag.getName(), "UTF-8"); Utils.sendPermanentRedirect(response, url); return; } @@ -79,10 +79,10 @@ public class User { } int privacy = 0; - if (visitor.getUID() > 0) { - if (user.getUID() == visitor.getUID() || visitor.getUID() == 1) { + if (visitor.getUid() > 0) { + if (user.getUid() == visitor.getUid() || visitor.getUid() == 1) { privacy = -3; - } else if (UserQueries.isInWL(sql, user.getUID(), visitor.getUID())) { + } else if (UserQueries.isInWL(sql, user.getUid(), visitor.getUid())) { privacy = -2; } } @@ -90,34 +90,34 @@ public class User { String title; if (paramShow == null) { if (paramTag != null) { - title = "Блог " + user.getUName() + ": *" + StringEscapeUtils.escapeHtml4(paramTag.getName()); - mids = MessagesQueries.getUserTag(sql, user.getUID(), paramTag.TID, privacy, paramBefore); + title = "Блог " + user.getName() + ": *" + StringEscapeUtils.escapeHtml4(paramTag.getName()); + mids = MessagesQueries.getUserTag(sql, user.getUid(), paramTag.TID, privacy, paramBefore); } else if (paramSearch != null) { - title = "Блог " + user.getUName() + ": " + StringEscapeUtils.escapeHtml4(paramSearch); - mids = MessagesQueries.getUserSearch(sql, sqlSearch, user.getUID(), Utils.encodeSphinx(paramSearch), privacy, paramBefore); + title = "Блог " + user.getName() + ": " + StringEscapeUtils.escapeHtml4(paramSearch); + mids = MessagesQueries.getUserSearch(sql, sqlSearch, user.getUid(), Utils.encodeSphinx(paramSearch), privacy, paramBefore); } else { - title = "Блог " + user.getUName(); - mids = MessagesQueries.getUserBlog(sql, user.getUID(), privacy, paramBefore); + title = "Блог " + user.getName(); + mids = MessagesQueries.getUserBlog(sql, user.getUid(), privacy, paramBefore); } } else if (paramShow.equals("recomm")) { - title = "Рекомендации " + user.getUName(); - mids = MessagesQueries.getUserRecommendations(sql, user.getUID(), paramBefore); + title = "Рекомендации " + user.getName(); + mids = MessagesQueries.getUserRecommendations(sql, user.getUid(), paramBefore); } else if (paramShow.equals("photos")) { - title = "Фотографии " + user.getUName(); - mids = MessagesQueries.getUserPhotos(sql, user.getUID(), privacy, paramBefore); + title = "Фотографии " + user.getName(); + mids = MessagesQueries.getUserPhotos(sql, user.getUid(), privacy, paramBefore); } else { Errors.doGet404(sql, request, response); return; } - if (visitor.getUID() == 0) { - pageUserRefCookie(request, response, user.getUID()); + if (visitor.getUid() == 0) { + pageUserRefCookie(request, response, user.getUid()); } response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { String head = ""; + user.getName() + "\" href=\"//rss.juick.com/" + user.getName() + "/blog\"/>"; if (paramTag != null && TagQueries.getTagNoIndex(sql, paramTag.TID)) { head += ""; } else if (paramBefore > 0 || paramShow != null) { @@ -136,7 +136,7 @@ public class User { StringEscapeUtils.escapeHtml4(paramTag.getName()) + "

"); } - PageTemplates.printMessages(out, sql, user, mids, visitor, visitor.getUID() == 0 ? 4 : 5, 0); + PageTemplates.printMessages(out, sql, user, mids, visitor, visitor.getUid() == 0 ? 4 : 5, 0); if (mids.size() >= 20) { String nextpage = "?before=" + mids.get(mids.size() - 1); @@ -163,14 +163,14 @@ public class User { protected void doGetTags(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user) throws ServletException, IOException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() == 0) { - pageUserRefCookie(request, response, user.getUID()); + if (visitor.getUid() == 0) { + pageUserRefCookie(request, response, user.getUid()); } response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { String head = ""; - PageTemplates.pageHead(out, visitor, "Теги " + user.getUName(), head); + PageTemplates.pageHead(out, visitor, "Теги " + user.getName(), head); PageTemplates.pageNavigation(out, visitor, null); pageUserColumn(out, sql, user, visitor); @@ -186,28 +186,28 @@ public class User { protected void doGetFriends(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user) throws ServletException, IOException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() == 0) { - pageUserRefCookie(request, response, user.getUID()); + if (visitor.getUid() == 0) { + pageUserRefCookie(request, response, user.getUid()); } response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { String head = ""; - PageTemplates.pageHead(out, visitor, "Подписки " + user.getUName(), head); + PageTemplates.pageHead(out, visitor, "Подписки " + user.getName(), head); PageTemplates.pageNavigation(out, visitor, null); pageUserColumn(out, sql, user, visitor); out.println("
"); out.println(""); - List friends = UserQueries.getUserFriends(sql, user.getUID()); + List friends = UserQueries.getUserFriends(sql, user.getUid()); for (int i = 0; i < friends.size(); i++) { if (i % 3 == 0 && i > 0) { out.print(""); } - out.print(""); + out.print(""); } out.println("
" - + friends.get(i).getUName() + "" + + friends.get(i).getName() + "
"); @@ -221,28 +221,28 @@ public class User { protected void doGetReaders(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user) throws ServletException, IOException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() == 0) { - pageUserRefCookie(request, response, user.getUID()); + if (visitor.getUid() == 0) { + pageUserRefCookie(request, response, user.getUid()); } response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { String head = ""; - PageTemplates.pageHead(out, visitor, "Читатели " + user.getUName(), head); + PageTemplates.pageHead(out, visitor, "Читатели " + user.getName(), head); PageTemplates.pageNavigation(out, visitor, null); pageUserColumn(out, sql, user, visitor); out.println("
"); out.println(""); - List readers = UserQueries.getUserReaders(sql, user.getUID()); + List readers = UserQueries.getUserReaders(sql, user.getUid()); for (int i = 0; i < readers.size(); i++) { if (i % 3 == 0 && i > 0) { out.print(""); } - out.print(""); + out.print(""); } out.println("
" - + readers.get(i).getUName() + "" + + readers.get(i).getName() + "
"); @@ -267,21 +267,21 @@ public class User { public static void pageUserColumn(PrintWriter out, JdbcTemplate sql, com.juick.User user, com.juick.User visitor) { out.println("