aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2021-10-18 22:18:52 +0300
committerGravatar Vitaly Takmazov2021-10-18 22:18:52 +0300
commit40b67e7f1078e0514f76322c66c334dede5cea60 (patch)
treec6c49be406039f6c50556029507c699c8432a7c4
parenta2348e95bbacbc9a9961afcabb7bbe82f3c7fe9d (diff)
Added user RSS feed with recommendations
-rw-r--r--src/main/java/com/juick/www/rss/Feeds.java11
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java2
2 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/com/juick/www/rss/Feeds.java b/src/main/java/com/juick/www/rss/Feeds.java
index 18d5639b..34ad7e5e 100644
--- a/src/main/java/com/juick/www/rss/Feeds.java
+++ b/src/main/java/com/juick/www/rss/Feeds.java
@@ -42,11 +42,16 @@ public class Feeds {
@Inject
private UserService userService;
- @GetMapping("/rss/{userName}/blog")
- public ModelAndView getBlog(@Visitor User visitor, @PathVariable String userName) {
+ public enum FeedType {
+ blog,
+ feed
+ }
+
+ @GetMapping("/rss/{userName}/{feedType}")
+ public ModelAndView getBlog(@Visitor User visitor, @PathVariable String userName, @PathVariable FeedType feedType) {
User user = userService.getUserByName(userName);
if (!user.isAnonymous() && !user.isBanned()) {
- List<Integer> mids = messagesService.getUserBlog(user.getUid(), 0, 0);
+ List<Integer> mids = feedType == FeedType.blog ? messagesService.getUserBlog(user.getUid(), 0, 0) : messagesService.getUserBlogWithRecommendations(user.getUid(), 0, 0);
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("messagesView");
modelAndView.addObject("user", user);
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index 3c8afa9e..edb43db4 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -2256,6 +2256,8 @@ public class ServerTests {
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;"
+ "q=0.8,application/signed-exchange;v=b3"))
.andExpect(status().isOk()).andExpect(content().contentType("application/rss+xml;charset=UTF-8"));
+ mockMvc.perform(get("/rss/ugnich/feed").accept(MediaType.TEXT_XML)).andExpect(status().isOk());
+ mockMvc.perform(get("/rss/ugnich/diary").accept(MediaType.TEXT_XML)).andExpect(status().isBadRequest());
}
@Test