From 156ab97673d7552c11784d0cdd53f8f37923a294 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 10 Jul 2016 22:56:58 +0300 Subject: fix getUserByHash usage, part 2 --- juick-www/src/main/java/com/juick/www/Discover.java | 2 +- juick-www/src/main/java/com/juick/www/Home.java | 8 ++++---- juick-www/src/main/java/com/juick/www/Main.java | 2 +- .../src/main/java/com/juick/www/PageTemplates.java | 20 +++++++++----------- juick-www/src/main/java/com/juick/www/User.java | 2 +- 5 files changed, 16 insertions(+), 18 deletions(-) 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 1811951b..240d0fdd 100644 --- a/juick-www/src/main/java/com/juick/www/Discover.java +++ b/juick-www/src/main/java/com/juick/www/Discover.java @@ -91,7 +91,7 @@ public class Discover { out.println("
"); if (mids.size() > 0) { - int vuid = visitor != null ? visitor.getUID() : 0; + 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 9241c5e6..b0013202 100644 --- a/juick-www/src/main/java/com/juick/www/Home.java +++ b/juick-www/src/main/java/com/juick/www/Home.java @@ -58,7 +58,7 @@ public class Home { title = "Поиск: " + Utils.encodeHTML(paramSearch); mids = MessagesQueries.getSearch(sql, sqlSearch, Utils.encodeSphinx(paramSearch), paramBefore); } else if (paramShow == null) { - if (visitor != null) { + if (visitor.getUID() > 0) { title = "Популярные"; mids = MessagesQueries.getPopular(sql, visitor.getUID(), paramBefore); } else { @@ -116,7 +116,7 @@ public class Home { out.println(""); } - if (visitor != null) { + if (visitor.getUID() > 0) { out.println("
"); out.println("
"); out.println(" "); @@ -132,7 +132,7 @@ public class Home { if (mids.size() > 0) { int ad_mid = 0; if (paramShow == null || paramShow.equals("top") || paramShow.equals("all")) { - int vuid = visitor != null ? visitor.getUID() : 0; + int vuid = visitor.getUID(); ad_mid = AdsQueries.getAdMID(sql, vuid); if (ad_mid > 0 && mids.indexOf(ad_mid) == -1) { mids.add(0, ad_mid); @@ -142,7 +142,7 @@ public class Home { } } - PageTemplates.printMessages(out, sql, null, mids, visitor, visitor == null ? 2 : 3, ad_mid); + PageTemplates.printMessages(out, sql, null, mids, visitor, visitor.getUID() == 0 ? 2 : 3, ad_mid); } if (mids.size() >= 20) { 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 4d340cd8..e69d3c02 100644 --- a/juick-www/src/main/java/com/juick/www/Main.java +++ b/juick-www/src/main/java/com/juick/www/Main.java @@ -136,7 +136,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 != null) { + if (visitor.getUID() > 0) { pagesNewMessage.doGetNewMessage(sql, request, response, visitor); } else { Utils.sendTemporaryRedirect(response, "/login"); 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 f2483ac0..b7883a79 100644 --- a/juick-www/src/main/java/com/juick/www/PageTemplates.java +++ b/juick-www/src/main/java/com/juick/www/PageTemplates.java @@ -87,7 +87,7 @@ public class PageTemplates { } out.println("/>"); out.println("
"); - if (visitor != null) { + if (visitor.getUID() > 0) { out.print("