diff options
author | Vitaly Takmazov | 2018-11-20 16:05:12 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-11-20 16:05:12 +0300 |
commit | d2b04d9b719b79a35e90b1c5569722ba5cbf794b (patch) | |
tree | 8d1ee0f0ad5a02b5c5f99ebbf732891b182828ff /src/main/java | |
parent | b0cfa955c77c4e36bd334324d0ccb2ff24ff549f (diff) |
avatars for visitors
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/juick/server/www/controllers/MessagesWWW.java | 12 |
1 files changed, 5 insertions, 7 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 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<com.juick.Message> msgs = messagesService.getMessages(visitor, mids); - + msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); if (!visitor.isAnonymous()) { fillUserModel(model, visitor, visitor); List<Integer> unread = messagesService.getUnread(visitor); @@ -164,7 +164,6 @@ public class MessagesWWW { List<Integer> 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<com.juick.Message> msgs = messagesService.getMessages(visitor, mids); - + msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); if (!visitor.isAnonymous()) { List<Integer> unread = messagesService.getUnread(visitor); visitor.setUnreadCount(unread.size()); List<Integer> 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<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()))); if (!visitor.isAnonymous()) { List<Integer> 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<com.juick.Message> 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()))); } |