diff options
author | Vitaly Takmazov | 2023-01-04 20:42:34 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-04 20:42:34 +0300 |
commit | e17ac99c67e5069745f3f19a91c18b6d3288b6e9 (patch) | |
tree | 5ed1cb7207a4bb52bd3f7c1233a7ea66ef89cea3 /src/main/java/com/juick/www/controllers/Site.java | |
parent | cf265cbed048b9324aea4b0bd591dbb34fd6c07b (diff) |
ActivityPub: cleanup media types and redirects
Diffstat (limited to 'src/main/java/com/juick/www/controllers/Site.java')
-rw-r--r-- | src/main/java/com/juick/www/controllers/Site.java | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/main/java/com/juick/www/controllers/Site.java b/src/main/java/com/juick/www/controllers/Site.java index e8acc650..cbc14496 100644 --- a/src/main/java/com/juick/www/controllers/Site.java +++ b/src/main/java/com/juick/www/controllers/Site.java @@ -477,11 +477,16 @@ public class Site { return "views/pm_sent"; } - @GetMapping(value = "/{uname}/{mid}", produces = { MediaType.TEXT_HTML_VALUE, Context.ACTIVITY_MEDIA_TYPE, - Context.LD_JSON_MEDIA_TYPE }) + @GetMapping(value = "/{uname}/{mid}", produces = { Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_MEDIA_TYPE, + Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE }) + public String threadRedirect(@PathVariable int mid) { + String linkedDataLocation = "/n/" + mid + "-0"; + return "redirect:" + linkedDataLocation; + } + + @GetMapping(value = "/{uname}/{mid}", consumes = MediaType.ALL_VALUE, produces = MediaType.TEXT_HTML_VALUE) protected String threadAction(@ModelAttribute User visitor, ModelMap model, @PathVariable String uname, @PathVariable int mid, - @RequestHeader(name = HttpHeaders.ACCEPT, required = false) String acceptHeader, @CookieValue(name = "sape_cookie", required = false, defaultValue = StringUtils.EMPTY) String sapeCookie) { if (!messagesService.canViewThread(mid, visitor.getUid())) { throw new HttpForbiddenException(); @@ -499,16 +504,6 @@ public class Site { if (user.isAnonymous() || !msg.getUser().equals(user)) { return String.format("redirect:/%s/%d", msg.getUser().getName(), mid); } - String linkedDataLocation = "/n/" + mid + "-0"; - if (StringUtils.isNotBlank(acceptHeader)) { - var mediaTypes = MediaType.parseMediaTypes(acceptHeader); - var isLinkedDataRequest = (mediaTypes.stream().anyMatch(mediaType -> !mediaType.isWildcardType() - && (mediaType.isCompatibleWith(MediaType.valueOf(Context.ACTIVITY_MEDIA_TYPE)) - || mediaType.isCompatibleWith(MediaType.valueOf(Context.LD_JSON_MEDIA_TYPE))))); - if (isLinkedDataRequest) { - return "redirect:" + linkedDataLocation; - } - } msg.VisitorCanComment = !visitor.isAnonymous(); msg.getUser().setAvatar(webApp.getAvatarWebPath(msg.getUser())); List<Message> replies = messagesService.getReplies(visitor, msg.getMid()); |