diff options
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/Settings.java')
-rw-r--r-- | juick-www/src/main/java/com/juick/www/Settings.java | 54 |
1 files changed, 27 insertions, 27 deletions
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<String> pages = Arrays.asList("main", "password", "about", "auth-email", "privacy"); @@ -95,17 +95,17 @@ public class Settings { List<String> 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 = "<p>Password has been changed.</p>"; - 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("<p>Your info is updated.</p><p><a href='/%s/'>Back to blog</a>.</p>", visitor.getUName()); + result = String.format("<p>Your info is updated.</p><p><a href='/%s/'>Back to blog</a>.</p>", 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 = "<p>Deleted. <a href=\"/settings\">Back</a>.</p>"; @@ -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 = "<p>Deleted. <a href=\"/settings\">Back</a>.</p>"; } else { result = "<p>An error occured while deleting.</p>"; } 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("<p>Saved! Will send to <strong>%s</strong> at <strong>%s:00 GMT</strong>." + "</p><p><a href=\"/settings\">Back</a></p>", 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 = "<p><a href=\"/settings\">Back</a></p>"; 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 = "<p><a href=\"/settings\">Back</a></p>"; 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 = "<p><a href=\"/settings\">Back</a></p>"; 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 = "<p><a href=\"/settings\">Back</a></p>"; 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 = "<p><a href=\"/settings\">Back</a></p>"; break; default: |