diff options
author | 2018-11-20 16:37:42 +0300 | |
---|---|---|
committer | 2018-11-20 16:37:42 +0300 | |
commit | a3ec3587e1fa33e4e08da9783d9d66c55ac84550 (patch) | |
tree | 9311de2f6511421eefed3e2e10bc821d2179dbd4 /src/main/java/com/juick/server/www/controllers/MessagesWWW.java | |
parent | d2b04d9b719b79a35e90b1c5569722ba5cbf794b (diff) |
avatar public url
Diffstat (limited to 'src/main/java/com/juick/server/www/controllers/MessagesWWW.java')
-rw-r--r-- | src/main/java/com/juick/server/www/controllers/MessagesWWW.java | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/main/java/com/juick/server/www/controllers/MessagesWWW.java b/src/main/java/com/juick/server/www/controllers/MessagesWWW.java index 9ccd099b..ba8e7b66 100644 --- a/src/main/java/com/juick/server/www/controllers/MessagesWWW.java +++ b/src/main/java/com/juick/server/www/controllers/MessagesWWW.java @@ -30,7 +30,6 @@ import com.juick.util.MessageUtils; import org.apache.commons.codec.CharEncoding; import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.StringEscapeUtils; -import org.springframework.context.ApplicationEventPublisher; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -72,7 +71,7 @@ public class MessagesWWW { private WebApp webApp; private void fillUserModel(ModelMap model, com.juick.User user, com.juick.User visitor) { - user.setAvatar(webApp.getAvatarUrl(user)); + user.setAvatar(webApp.getAvatarWebPath(user)); model.addAttribute("user", user); model.addAttribute("isSubscribed", userService.isSubscribed(visitor.getUid(), user.getUid())); model.addAttribute("isInBL", userService.isInBL(visitor.getUid(), user.getUid())); @@ -102,7 +101,7 @@ public class MessagesWWW { } com.juick.User visitor = UserUtils.getCurrentUser(); - visitor.setAvatar(webApp.getAvatarUrl(visitor)); + visitor.setAvatar(webApp.getAvatarWebPath(visitor)); if (paramSearch != null && paramSearch.length() > 64) { paramSearch = null; @@ -156,7 +155,7 @@ public class MessagesWWW { model.addAttribute("visitor", visitor); model.addAttribute("noindex", !(paramShow == null && paramBefore == 0)); List<com.juick.Message> msgs = messagesService.getMessages(visitor, mids); - msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); + msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser()))); if (!visitor.isAnonymous()) { fillUserModel(model, visitor, visitor); List<Integer> unread = messagesService.getUnread(visitor); @@ -208,7 +207,7 @@ public class MessagesWWW { if (user.isBanned() || user.isAnonymous()) { throw new HttpNotFoundException(); } - visitor.setAvatar(webApp.getAvatarUrl(visitor)); + visitor.setAvatar(webApp.getAvatarWebPath(visitor)); List<Integer> mids; @@ -275,7 +274,7 @@ public class MessagesWWW { fillUserModel(model, user, visitor); model.addAttribute("paramTag", paramTag); List<com.juick.Message> msgs = messagesService.getMessages(visitor, mids); - msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); + msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser()))); if (!visitor.isAnonymous()) { List<Integer> unread = messagesService.getUnread(visitor); visitor.setUnreadCount(unread.size()); @@ -320,7 +319,7 @@ public class MessagesWWW { if (visitor.isBanned()) { throw new HttpNotFoundException(); } - visitor.setAvatar(webApp.getAvatarUrl(visitor)); + visitor.setAvatar(webApp.getAvatarWebPath(visitor)); model.addAttribute("title", "Теги " + user.getName()); model.addAttribute("headers", "<meta name=\"robots\" content=\"noindex,nofollow\"/>"); @@ -339,7 +338,7 @@ public class MessagesWWW { if (visitor.isBanned()) { throw new HttpNotFoundException(); } - visitor.setAvatar(webApp.getAvatarUrl(visitor)); + visitor.setAvatar(webApp.getAvatarWebPath(visitor)); model.addAttribute("title", "Подписки " + user.getName()); model.addAttribute("headers", "<meta name=\"robots\" content=\"noindex\"/>"); model.addAttribute("visitor", visitor); @@ -356,7 +355,7 @@ public class MessagesWWW { if (visitor.isBanned()) { throw new HttpForbiddenException(); } - visitor.setAvatar(webApp.getAvatarUrl(visitor)); + visitor.setAvatar(webApp.getAvatarWebPath(visitor)); model.addAttribute("title", "Читатели " + user.getName()); model.addAttribute("headers", "<meta name=\"robots\" content=\"noindex\"/>"); model.addAttribute("visitor", visitor); @@ -373,7 +372,7 @@ public class MessagesWWW { if (visitor.isBanned() || visitor.getUid() != user.getUid()) { throw new HttpForbiddenException(); } - visitor.setAvatar(webApp.getAvatarUrl(visitor)); + visitor.setAvatar(webApp.getAvatarWebPath(visitor)); model.addAttribute("title", "Черный список " + user.getName()); model.addAttribute("headers", "<meta name=\"robots\" content=\"noindex\"/>"); model.addAttribute("visitor", visitor); @@ -389,7 +388,7 @@ public class MessagesWWW { @RequestParam(required = false, defaultValue = "0") int before, ModelMap model) throws IOException { com.juick.User visitor = UserUtils.getCurrentUser(); - visitor.setAvatar(webApp.getAvatarUrl(visitor)); + visitor.setAvatar(webApp.getAvatarWebPath(visitor)); String paramTagStr = StringEscapeUtils.unescapeHtml4(tagName); com.juick.Tag paramTag = tagService.getTag(paramTagStr, false); if (paramTag == null) { @@ -413,7 +412,7 @@ public class MessagesWWW { model.addAttribute("title", title); List<Integer> mids = messagesService.getTag(paramTag.TID, visitor.getUid(), before, (visitor.isAnonymous()) ? 40 : 20); List<com.juick.Message> msgs = messagesService.getMessages(visitor, mids); - msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); + msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser()))); if (!visitor.isAnonymous()) { List<Integer> unread = messagesService.getUnread(visitor); visitor.setUnreadCount(unread.size()); @@ -463,10 +462,10 @@ public class MessagesWWW { if (visitor.isAnonymous()) { return "redirect:/login"; } - visitor.setAvatar(webApp.getAvatarUrl(visitor)); + visitor.setAvatar(webApp.getAvatarWebPath(visitor)); String title = "PM: Inbox"; List<com.juick.Message> msgs = pmQueriesService.getLastPMInbox(visitor.getUid()); - msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); + msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser()))); fillUserModel(model, visitor, visitor); model.addAttribute("title", title); model.addAttribute("visitor", visitor); @@ -482,10 +481,10 @@ public class MessagesWWW { if (visitor.isAnonymous()) { return "redirect:/login"; } - visitor.setAvatar(webApp.getAvatarUrl(visitor)); + visitor.setAvatar(webApp.getAvatarWebPath(visitor)); String title = "PM: Sent"; List<com.juick.Message> msgs = pmQueriesService.getLastPMSent(visitor.getUid()); - msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); + msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser()))); if (WebUtils.isNotUserName(uname)) { uname = StringUtils.EMPTY; } @@ -508,7 +507,7 @@ public class MessagesWWW { if (!messagesService.canViewThread(mid, visitor.getUid())) { throw new HttpForbiddenException(); } - visitor.setAvatar(webApp.getAvatarUrl(visitor)); + visitor.setAvatar(webApp.getAvatarWebPath(visitor)); Optional<com.juick.Message> message = messagesService.getMessage(mid); if (!message.isPresent() || message.get().getUser().isBanned()) { @@ -522,7 +521,7 @@ public class MessagesWWW { return String.format("redirect:/%s/%d", msg.getUser().getName(), mid); } msg.VisitorCanComment = !visitor.isAnonymous(); - msg.getUser().setAvatar(webApp.getAvatarUrl(msg.getUser())); + msg.getUser().setAvatar(webApp.getAvatarWebPath(msg.getUser())); List<com.juick.Message> replies = messagesService.getReplies(visitor, msg.getMid()); // this should be after getReplies to mark thread as read fillUserModel(model, user, visitor); @@ -552,7 +551,7 @@ public class MessagesWWW { headers += "<meta property=\"og:image\" content=\"" + msgImage + "\" />"; } } else { - String msgImage ="https://i.juick.com/a/" + msg.getUser().getUid() + ".png"; + String msgImage = webApp.getAvatarPublicUrl(msg.getUser()); headers += "<meta property=\"og:image\" content=\"" + msgImage + "\" />"; } model.addAttribute("ogtype", "article"); @@ -582,7 +581,7 @@ public class MessagesWWW { blUIDs.add(reply.getUser().getUid()); } reply.VisitorCanComment = !visitor.isAnonymous(); - reply.getUser().setAvatar(webApp.getAvatarUrl(reply.getUser())); + reply.getUser().setAvatar(webApp.getAvatarWebPath(reply.getUser())); if (!visitor.isAnonymous()) { boolean isMsgAuthor = visitor.getUid() == msg.getUser().getUid(); boolean isReplyAuthor = visitor.getUid() == reply.getUser().getUid(); |