From 478a7bfba88401c1996d0be5a144459011b60e10 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 22 Jan 2023 20:27:45 +0300 Subject: db refactoring: merge getMessages with isSubscribed query --- src/main/java/com/juick/www/controllers/Site.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/main/java/com/juick/www/controllers') diff --git a/src/main/java/com/juick/www/controllers/Site.java b/src/main/java/com/juick/www/controllers/Site.java index bfe7d654..d0ea3dee 100644 --- a/src/main/java/com/juick/www/controllers/Site.java +++ b/src/main/java/com/juick/www/controllers/Site.java @@ -190,7 +190,7 @@ public class Site { model.addAttribute("headers", head); model.addAttribute("visitor", visitor); model.addAttribute("noindex", !(paramShow == null && paramBefore == 0)); - List msgs = messagesService.getMessages(visitor, mids); + List msgs = messagesService.getMessages(visitor.getUid(), mids); msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser()))); if (!visitor.isAnonymous()) { fillUserModel(model, visitor, visitor); @@ -301,7 +301,7 @@ public class Site { model.addAttribute("noindex", paramShow == null && before == 0); fillUserModel(model, user, visitor); model.addAttribute("paramTag", paramTag); - List msgs = messagesService.getMessages(visitor, mids); + List msgs = messagesService.getMessages(visitor.getUid(), mids); msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser()))); if (!visitor.isAnonymous()) { List unread = messagesService.getUnread(visitor); @@ -423,7 +423,7 @@ public class Site { model.addAttribute("title", title); List mids = messagesService.getTag(paramTag.TID, visitor.getUid(), before, (visitor.isAnonymous()) ? 40 : 20); - List msgs = messagesService.getMessages(visitor, mids); + List msgs = messagesService.getMessages(visitor.getUid(), mids); msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser()))); if (!visitor.isAnonymous()) { List unread = messagesService.getUnread(visitor); @@ -504,7 +504,7 @@ public class Site { throw new HttpForbiddenException(); } visitor.setAvatar(webApp.getAvatarWebPath(visitor)); - Optional message = messagesService.getMessage(mid); + Optional message = messagesService.getMessage(visitor.getUid(), mid); if (message.isEmpty()) { throw new HttpNotFoundException(); @@ -567,7 +567,6 @@ public class Site { + msg.getTags().stream().map(Tag::getName).collect(Collectors.joining(", ")) + "\" />\n"; } model.addAttribute("headers", headers); - model.addAttribute("visitorSubscribed", messagesService.isSubscribed(visitor.getUid(), msg.getMid())); model.addAttribute("visitorInBL", userService.isInBL(msg.getUser().getUid(), visitor.getUid())); List blUIDs = new ArrayList<>(); for (Message reply : replies) { -- cgit v1.2.3