aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/www/rss
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/www/rss')
-rw-r--r--src/main/java/com/juick/www/rss/Feeds.java10
-rw-r--r--src/main/java/com/juick/www/rss/MessagesView.java62
2 files changed, 35 insertions, 37 deletions
diff --git a/src/main/java/com/juick/www/rss/Feeds.java b/src/main/java/com/juick/www/rss/Feeds.java
index 8111f2df..41b006a6 100644
--- a/src/main/java/com/juick/www/rss/Feeds.java
+++ b/src/main/java/com/juick/www/rss/Feeds.java
@@ -21,16 +21,12 @@ import com.juick.model.User;
import com.juick.util.HttpNotFoundException;
import com.juick.service.MessagesService;
import com.juick.service.UserService;
-import com.juick.service.security.annotation.Visitor;
import org.springframework.core.convert.ConversionFailedException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.inject.Inject;
@@ -53,7 +49,7 @@ public class Feeds {
}
@GetMapping("/rss/{userName}/{feedType}")
- public ModelAndView getBlog(@Visitor User visitor, @PathVariable String userName, @PathVariable FeedType feedType) {
+ public ModelAndView getBlog(@ModelAttribute User visitor, @PathVariable String userName, @PathVariable FeedType feedType) {
User user = userService.getUserByName(userName);
if (!user.isAnonymous() && !user.isBanned()) {
List<Integer> mids = feedType == FeedType.blog ? messagesService.getUserBlog(user.getUid(), 0, 0) : messagesService.getUserBlogWithRecommendations(user, visitor, 0, 0);
@@ -69,7 +65,7 @@ public class Feeds {
@GetMapping("/rss/")
public ModelAndView getLast(
- @Visitor User visitor,
+ @ModelAttribute User visitor,
@RequestParam(value = "hours", required = false, defaultValue = "0") Integer hours) {
List<Integer> mids = messagesService.getLastMessages(hours);
ModelAndView modelAndView = new ModelAndView();
diff --git a/src/main/java/com/juick/www/rss/MessagesView.java b/src/main/java/com/juick/www/rss/MessagesView.java
index 71d63754..d6edeb28 100644
--- a/src/main/java/com/juick/www/rss/MessagesView.java
+++ b/src/main/java/com/juick/www/rss/MessagesView.java
@@ -93,37 +93,39 @@ public class MessagesView extends AbstractRssFeedView {
String feedType = (String) model.get("feedType");
if (userObj != null) {
User user = (User) userObj;
- feed.setDescription(String.format("The latest messages by @%s at Juick", user.getName()));
- String title = String.format("%s - Juick", user.getName());
- feed.setTitle(title);
- String link = String.format("https://juick.com/%s/", user.getName());
- feed.setLink(link);
- try {
- Attachment avatar = storageService.getAvatarMetadata(user);
- Image rssImage = new Image();
- rssImage.setUrl(webApp.getAvatarUrl(user));
- rssImage.setTitle(title);
- rssImage.setLink(link);
- rssImage.setHeight(avatar.getHeight());
- rssImage.setWidth(avatar.getWidth());
- feed.setImage(rssImage);
- } catch (IOException e) {
- logger.warn("Feed avatar not found for {}", user.getName());
+ if (!user.isAnonymous()) {
+ feed.setDescription(String.format("The latest messages by @%s at Juick", user.getName()));
+ String title = String.format("%s - Juick", user.getName());
+ feed.setTitle(title);
+ String link = String.format("https://juick.com/%s/", user.getName());
+ feed.setLink(link);
+ try {
+ Attachment avatar = storageService.getAvatarMetadata(user);
+ Image rssImage = new Image();
+ rssImage.setUrl(webApp.getAvatarUrl(user));
+ rssImage.setTitle(title);
+ rssImage.setLink(link);
+ rssImage.setHeight(avatar.getHeight());
+ rssImage.setWidth(avatar.getWidth());
+ feed.setImage(rssImage);
+ } catch (IOException e) {
+ logger.warn("Feed avatar not found for {}", user.getName());
+ }
+
+ String href = String.format("https://rss.juick.com/%s/%s", user.getName(), feedType);
+ AtomLinkModule atomLinkModule = new AtomLinkModuleImpl();
+ Link atomLink = new Link();
+ atomLink.setHref(href);
+ atomLink.setType("application/rss+xml");
+ atomLink.setRel("self");
+ atomLinkModule.setLinks(Collections.singletonList(atomLink));
+
+ feed.getModules().add(atomLinkModule);
+ } else {
+ feed.setDescription("The latest messages at Juick");
+ feed.setLink("https://juick.com/");
+ feed.setTitle("Juick");
}
-
- String href = String.format("https://rss.juick.com/%s/%s", user.getName(), feedType);
- AtomLinkModule atomLinkModule = new AtomLinkModuleImpl();
- Link atomLink = new Link();
- atomLink.setHref(href);
- atomLink.setType("application/rss+xml");
- atomLink.setRel("self");
- atomLinkModule.setLinks(Collections.singletonList(atomLink));
-
- feed.getModules().add(atomLinkModule);
- } else {
- feed.setDescription("The latest messages at Juick");
- feed.setLink("https://juick.com/");
- feed.setTitle("Juick");
}
MediaModule mediaModule = new MediaModuleImpl();