From a1224e0db03b6116e4f7f2ed7f8ce265c41ca230 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 3 Nov 2015 16:08:42 +0300 Subject: try to use uid from url --- src/main/java/com/juick/http/www/Main.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/main/java/com/juick/http') diff --git a/src/main/java/com/juick/http/www/Main.java b/src/main/java/com/juick/http/www/Main.java index ced7fb98..4c7f7e14 100644 --- a/src/main/java/com/juick/http/www/Main.java +++ b/src/main/java/com/juick/http/www/Main.java @@ -228,16 +228,21 @@ public class Main extends HttpServlet implements Stream.StreamListener { closeSqlSearch(); } else if (uri.matches("^/\\d+$")) { String strID = request.getRequestURI().substring(1); - int mid = 0; + int uid = 0; try { - mid = Integer.parseInt(strID); + uid = Integer.parseInt(strID); } catch (NumberFormatException e) { } - if (mid > 0) { - com.juick.User author = com.juick.server.MessagesQueries.getMessageAuthor(sql, mid); + if (uid > 0) { + com.juick.User author = UserQueries.getUserByUID(sql, uid); if (author != null) { - Utils.sendPermanentRedirect(response, "/" + author.UName + "/" + mid); - return; + if (author.UName != null) { + Utils.sendPermanentRedirect(response, "/" + author.UName); + return; + } else { + pagesUser.doGetBlog(sql, getSqlSearch(), request, response, author); + return; + } } } Errors.doGet404(sql, request, response); -- cgit v1.2.3