aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/www
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-01-22 20:27:45 +0300
committerGravatar Vitaly Takmazov2023-01-22 20:57:06 +0300
commit478a7bfba88401c1996d0be5a144459011b60e10 (patch)
tree2bdbf40a9910c799673874d64a87a4ef0e5dc04b /src/main/java/com/juick/www
parent9ad08dc78e0cdbe2cdebf10a96c800e72d48e48b (diff)
db refactoring: merge getMessages with isSubscribed query
Diffstat (limited to 'src/main/java/com/juick/www')
-rw-r--r--src/main/java/com/juick/www/api/Mastodon.java2
-rw-r--r--src/main/java/com/juick/www/api/Messages.java6
-rw-r--r--src/main/java/com/juick/www/api/activity/Profile.java2
-rw-r--r--src/main/java/com/juick/www/controllers/Site.java9
-rw-r--r--src/main/java/com/juick/www/rss/Feeds.java4
5 files changed, 11 insertions, 12 deletions
diff --git a/src/main/java/com/juick/www/api/Mastodon.java b/src/main/java/com/juick/www/api/Mastodon.java
index a190defe..91de2162 100644
--- a/src/main/java/com/juick/www/api/Mastodon.java
+++ b/src/main/java/com/juick/www/api/Mastodon.java
@@ -353,7 +353,7 @@ public class Mastodon {
} else if (timeline.equals("home")) {
mids = messagesService.getMyFeed(visitor.getUid(), before, true);
}
- return messagesService.getMessages(visitor, mids).stream()
+ return messagesService.getMessages(visitor.getUid(), mids).stream()
.map(m -> {
m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()));
return toStatus(m);
diff --git a/src/main/java/com/juick/www/api/Messages.java b/src/main/java/com/juick/www/api/Messages.java
index fb10d7a7..ecdd304f 100644
--- a/src/main/java/com/juick/www/api/Messages.java
+++ b/src/main/java/com/juick/www/api/Messages.java
@@ -73,7 +73,7 @@ public class Messages {
@RequestParam(defaultValue = "0") int before_mid) {
int vuid = visitor.getUid();
List<Integer> mids = messagesService.getMyFeed(vuid, before_mid, true);
- List<Message> msgs = messagesService.getMessages(visitor, mids);
+ List<Message> msgs = messagesService.getMessages(vuid, mids);
msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser())));
return msgs;
}
@@ -131,7 +131,7 @@ public class Messages {
mids = messagesService.getAll(visitor.getUid(), before);
}
}
- List<Message> msgs = messagesService.getMessages(visitor, mids);
+ List<Message> msgs = messagesService.getMessages(visitor.getUid(), mids);
msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser())));
return msgs;
}
@@ -153,7 +153,7 @@ public class Messages {
@GetMapping("/api/messages/discussions")
public List<Message> getDiscussions(@Parameter(hidden = true) User visitor,
@RequestParam(required = false, defaultValue = "0") Long to) {
- List<Message> msgs = messagesService.getMessages(visitor, messagesService.getDiscussions(visitor.getUid(), to));
+ List<Message> msgs = messagesService.getMessages(visitor.getUid(), messagesService.getDiscussions(visitor.getUid(), to));
msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser())));
return msgs;
}
diff --git a/src/main/java/com/juick/www/api/activity/Profile.java b/src/main/java/com/juick/www/api/activity/Profile.java
index 7b440a6a..580ed340 100644
--- a/src/main/java/com/juick/www/api/activity/Profile.java
+++ b/src/main/java/com/juick/www/api/activity/Profile.java
@@ -141,7 +141,7 @@ public class Profile {
UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri);
String personUri = uri.path(String.format("/u/%s", userName)).toUriString();
List<Integer> mids = messagesService.getUserBlog(user.getUid(), 0, before);
- List<Note> notes = messagesService.getMessages(visitor, mids).stream().map(activityPubManager::makeNote)
+ List<Note> notes = messagesService.getMessages(visitor.getUid(), mids).stream().map(activityPubManager::makeNote)
.toList();
OrderedCollectionPage page = new OrderedCollectionPage();
page.setPartOf(uri.replacePath(String.format("/u/%s/blog/toc", userName)).toUriString());
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<Message> msgs = messagesService.getMessages(visitor, mids);
+ List<Message> 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<Message> msgs = messagesService.getMessages(visitor, mids);
+ List<Message> msgs = messagesService.getMessages(visitor.getUid(), mids);
msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser())));
if (!visitor.isAnonymous()) {
List<Integer> unread = messagesService.getUnread(visitor);
@@ -423,7 +423,7 @@ public class Site {
model.addAttribute("title", title);
List<Integer> mids = messagesService.getTag(paramTag.TID, visitor.getUid(), before,
(visitor.isAnonymous()) ? 40 : 20);
- List<Message> msgs = messagesService.getMessages(visitor, mids);
+ List<Message> msgs = messagesService.getMessages(visitor.getUid(), mids);
msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser())));
if (!visitor.isAnonymous()) {
List<Integer> unread = messagesService.getUnread(visitor);
@@ -504,7 +504,7 @@ public class Site {
throw new HttpForbiddenException();
}
visitor.setAvatar(webApp.getAvatarWebPath(visitor));
- Optional<Message> message = messagesService.getMessage(mid);
+ Optional<Message> 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<Integer> blUIDs = new ArrayList<>();
for (Message reply : replies) {
diff --git a/src/main/java/com/juick/www/rss/Feeds.java b/src/main/java/com/juick/www/rss/Feeds.java
index 4e64bc5a..f19f1505 100644
--- a/src/main/java/com/juick/www/rss/Feeds.java
+++ b/src/main/java/com/juick/www/rss/Feeds.java
@@ -58,7 +58,7 @@ public class Feeds {
modelAndView.setViewName("messagesView");
modelAndView.addObject("user", user);
modelAndView.addObject("feedType", feedType.name());
- modelAndView.addObject("messages", messagesService.getMessages(visitor, mids));
+ modelAndView.addObject("messages", messagesService.getMessages(visitor.getUid(), mids));
return modelAndView;
}
throw new HttpNotFoundException();
@@ -72,7 +72,7 @@ public class Feeds {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("messagesView");
modelAndView.addObject("user", visitor);
- modelAndView.addObject("messages", messagesService.getMessages(visitor, mids));
+ modelAndView.addObject("messages", messagesService.getMessages(visitor.getUid(), mids));
return modelAndView;
}
@GetMapping("/rss/comments")