From 8abdac5ade33c71125eb3f7409cb6dafe8aff278 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 8 Jan 2023 16:52:52 +0300 Subject: Fix ActivityPub redirects --- src/main/java/com/juick/www/controllers/Site.java | 11 ++++++----- 1 file changed, 6 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 cbc14496..1dc4c338 100644 --- a/src/main/java/com/juick/www/controllers/Site.java +++ b/src/main/java/com/juick/www/controllers/Site.java @@ -43,6 +43,7 @@ import org.springframework.security.web.WebAttributes; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.view.RedirectView; import javax.inject.Inject; import java.net.URLEncoder; @@ -477,14 +478,14 @@ public class Site { return "views/pm_sent"; } - @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) { + @GetMapping(value = "/{uname}/{mid}", produces = { MediaType.APPLICATION_JSON_VALUE, Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_MEDIA_TYPE, + Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE }) + public RedirectView threadRedirect(@PathVariable String uname, @PathVariable int mid) { String linkedDataLocation = "/n/" + mid + "-0"; - return "redirect:" + linkedDataLocation; + return new RedirectView(linkedDataLocation); } - @GetMapping(value = "/{uname}/{mid}", consumes = MediaType.ALL_VALUE, produces = MediaType.TEXT_HTML_VALUE) + @GetMapping(value = "/{uname}/{mid}", produces = { MediaType.TEXT_HTML_VALUE, MediaType.ALL_VALUE }) protected String threadAction(@ModelAttribute User visitor, ModelMap model, @PathVariable String uname, @PathVariable int mid, @CookieValue(name = "sape_cookie", required = false, defaultValue = StringUtils.EMPTY) String sapeCookie) { -- cgit v1.2.3