From d2b04d9b719b79a35e90b1c5569722ba5cbf794b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 20 Nov 2018 16:05:12 +0300 Subject: avatars for visitors --- .../java/com/juick/server/www/controllers/MessagesWWW.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/main/java') 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 50d90555..9ccd099b 100644 --- a/src/main/java/com/juick/server/www/controllers/MessagesWWW.java +++ b/src/main/java/com/juick/server/www/controllers/MessagesWWW.java @@ -156,7 +156,7 @@ public class MessagesWWW { model.addAttribute("visitor", visitor); model.addAttribute("noindex", !(paramShow == null && paramBefore == 0)); List msgs = messagesService.getMessages(visitor, mids); - + msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); if (!visitor.isAnonymous()) { fillUserModel(model, visitor, visitor); List unread = messagesService.getUnread(visitor); @@ -164,7 +164,6 @@ public class MessagesWWW { List blUIDs = userService.checkBL(visitor.getUid(), msgs.stream().map(m -> m.getUser().getUid()).collect(Collectors.toList())); msgs.forEach(m -> { - m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser())); m.ReadOnly |= blUIDs.contains(m.getUser().getUid()); m.setUnread(unread.contains(m.getMid())); }); @@ -276,14 +275,13 @@ public class MessagesWWW { fillUserModel(model, user, visitor); model.addAttribute("paramTag", paramTag); List msgs = messagesService.getMessages(visitor, mids); - + msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); if (!visitor.isAnonymous()) { List unread = messagesService.getUnread(visitor); visitor.setUnreadCount(unread.size()); List blUIDs = userService.checkBL(visitor.getUid(), msgs.stream().map(m -> m.getUser().getUid()).collect(Collectors.toList())); msgs.forEach(m -> { - m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser())); m.ReadOnly |= blUIDs.contains(m.getUser().getUid()); m.setUnread(unread.contains(m.getMid())); }); @@ -415,6 +413,7 @@ public class MessagesWWW { model.addAttribute("title", title); List mids = messagesService.getTag(paramTag.TID, visitor.getUid(), before, (visitor.isAnonymous()) ? 40 : 20); List msgs = messagesService.getMessages(visitor, mids); + msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); if (!visitor.isAnonymous()) { List unread = messagesService.getUnread(visitor); visitor.setUnreadCount(unread.size()); @@ -423,7 +422,6 @@ public class MessagesWWW { msgs.stream().map(m -> m.getUser().getUid()).collect(Collectors.toList()) ); msgs.forEach(m -> { - m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser())); m.ReadOnly |= blUIDs.contains(m.getUser().getUid()); m.setUnread(unread.contains(m.getMid())); }); @@ -524,6 +522,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())); List replies = messagesService.getReplies(visitor, msg.getMid()); // this should be after getReplies to mark thread as read fillUserModel(model, user, visitor); @@ -532,7 +531,6 @@ public class MessagesWWW { visitor.setUnreadCount(unread.size()); boolean isMsgAuthor = visitor.getUid() == msg.getUser().getUid(); boolean isInBL = userService.isInBLAny(msg.getUser().getUid(), visitor.getUid()); - msg.getUser().setAvatar(webApp.getAvatarUrl(msg.getUser())); msg.VisitorCanComment = isMsgAuthor || !(msg.ReadOnly || isInBL); } model.addAttribute("msg", msg); @@ -584,10 +582,10 @@ public class MessagesWWW { blUIDs.add(reply.getUser().getUid()); } reply.VisitorCanComment = !visitor.isAnonymous(); + reply.getUser().setAvatar(webApp.getAvatarUrl(reply.getUser())); if (!visitor.isAnonymous()) { boolean isMsgAuthor = visitor.getUid() == msg.getUser().getUid(); boolean isReplyAuthor = visitor.getUid() == reply.getUser().getUid(); - reply.getUser().setAvatar(webApp.getAvatarUrl(reply.getUser())); reply.VisitorCanComment = isMsgAuthor || (!msg.ReadOnly && msg.VisitorCanComment && (isReplyAuthor || !userService.isInBLAny(visitor.getUid(), reply.getUser().getUid()))); } -- cgit v1.2.3