aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/www/api
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-01-04 20:42:34 +0300
committerGravatar Vitaly Takmazov2023-01-04 20:42:34 +0300
commite17ac99c67e5069745f3f19a91c18b6d3288b6e9 (patch)
tree5ed1cb7207a4bb52bd3f7c1233a7ea66ef89cea3 /src/main/java/com/juick/www/api
parentcf265cbed048b9324aea4b0bd591dbb34fd6c07b (diff)
ActivityPub: cleanup media types and redirects
Diffstat (limited to 'src/main/java/com/juick/www/api')
-rw-r--r--src/main/java/com/juick/www/api/activity/Profile.java36
-rw-r--r--src/main/java/com/juick/www/api/activity/model/Context.java3
-rw-r--r--src/main/java/com/juick/www/api/webfinger/Resource.java3
3 files changed, 21 insertions, 21 deletions
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 43a797fb..fba39954 100644
--- a/src/main/java/com/juick/www/api/activity/Profile.java
+++ b/src/main/java/com/juick/www/api/activity/Profile.java
@@ -103,8 +103,8 @@ public class Profile {
@Inject
private ConversionService conversionService;
- @GetMapping(value = "/u/{userName}", produces = { Context.LD_JSON_MEDIA_TYPE,
- Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE, Context.FALLBACK_JSON_MEDIA_TYPE })
+ @GetMapping(value = "/u/{userName}", produces = { Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_MEDIA_TYPE,
+ Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE })
public Actor getUser(@PathVariable String userName) {
User user = userService.getUserByName(userName);
if (!user.isAnonymous()) {
@@ -116,8 +116,8 @@ public class Profile {
throw new HttpNotFoundException();
}
- @GetMapping(value = "/u/{userName}/blog/toc", produces = { Context.LD_JSON_MEDIA_TYPE,
- Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE })
+ @GetMapping(value = "/u/{userName}/blog/toc", produces = { Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_MEDIA_TYPE,
+ Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE })
public OrderedCollection getOutbox(@PathVariable String userName) {
User user = userService.getUserByName(userName);
if (!user.isAnonymous()) {
@@ -131,8 +131,8 @@ public class Profile {
throw new HttpNotFoundException();
}
- @GetMapping(value = "/u/{userName}/blog", produces = { Context.LD_JSON_MEDIA_TYPE,
- Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE })
+ @GetMapping(value = "/u/{userName}/blog", produces = { Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_MEDIA_TYPE,
+ Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE })
public OrderedCollectionPage getOutboxPage(@ModelAttribute User visitor, @PathVariable String userName,
@RequestParam(required = false, defaultValue = "0") int before) {
User user = userService.getUserByName(userName);
@@ -165,8 +165,8 @@ public class Profile {
throw new HttpNotFoundException();
}
- @GetMapping(value = "/u/{userName}/followers/toc", produces = { Context.LD_JSON_MEDIA_TYPE,
- Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE })
+ @GetMapping(value = "/u/{userName}/followers/toc", produces = { Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_MEDIA_TYPE,
+ Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE })
public OrderedCollection getFollowers(@PathVariable String userName) {
User user = userService.getUserByName(userName);
if (!user.isAnonymous()) {
@@ -180,8 +180,8 @@ public class Profile {
throw new HttpNotFoundException();
}
- @GetMapping(value = "/u/{userName}/followers", produces = { Context.LD_JSON_MEDIA_TYPE,
- Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE })
+ @GetMapping(value = "/u/{userName}/followers", produces = { Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_MEDIA_TYPE,
+ Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE })
public OrderedCollectionPage getFollowersPage(@PathVariable String userName,
@RequestParam(required = false, defaultValue = "0") int page) {
User user = userService.getUserByName(userName);
@@ -209,8 +209,8 @@ public class Profile {
throw new HttpNotFoundException();
}
- @GetMapping(value = "/u/{userName}/following/toc", produces = { Context.LD_JSON_MEDIA_TYPE,
- Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE })
+ @GetMapping(value = "/u/{userName}/following/toc", produces = { Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_MEDIA_TYPE,
+ Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE })
public OrderedCollection getFollowing(@PathVariable String userName) {
User user = userService.getUserByName(userName);
if (!user.isAnonymous()) {
@@ -224,8 +224,8 @@ public class Profile {
throw new HttpNotFoundException();
}
- @GetMapping(value = "/u/{userName}/following", produces = { Context.LD_JSON_MEDIA_TYPE,
- Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE })
+ @GetMapping(value = "/u/{userName}/following", produces = { Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_MEDIA_TYPE,
+ Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE })
public OrderedCollectionPage getFollowingPage(@PathVariable String userName,
@RequestParam(required = false, defaultValue = "0") int page) {
User user = userService.getUserByName(userName);
@@ -253,8 +253,8 @@ public class Profile {
throw new HttpNotFoundException();
}
- @GetMapping(value = "/n/{mid}-{rid}", produces = { Context.LD_JSON_MEDIA_TYPE,
- Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE })
+ @GetMapping(value = "/n/{mid}-{rid}", produces = { Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_MEDIA_TYPE,
+ Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE })
public Context showNote(@PathVariable int mid, @PathVariable int rid) {
try {
Message message = rid > 0 ? messagesService.getReply(mid, rid) : messagesService.getMessage(mid).get();
@@ -280,8 +280,8 @@ public class Profile {
}
@CacheEvict(cacheNames = "profiles", key = "{ #visitor.uri }")
- @PostMapping(value = "/api/inbox", consumes = { Context.LD_JSON_MEDIA_TYPE,
- Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE })
+ @PostMapping(value = "/api/inbox", consumes = { Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_MEDIA_TYPE,
+ Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<CommandResult> processInbox(@ModelAttribute User visitor, InputStream inboxData)
throws Exception {
String inbox = IOUtils.toString(inboxData, StandardCharsets.UTF_8);
diff --git a/src/main/java/com/juick/www/api/activity/model/Context.java b/src/main/java/com/juick/www/api/activity/model/Context.java
index 5a66b3b3..950c8f63 100644
--- a/src/main/java/com/juick/www/api/activity/model/Context.java
+++ b/src/main/java/com/juick/www/api/activity/model/Context.java
@@ -96,8 +96,7 @@ public class Context implements Serializable {
public final static String ACTIVITY_STREAMS_URI = "https://www.w3.org/ns/activitystreams";
public final static String SECURITY_URI = "https://w3id.org/security/v1";
- public final static String LD_JSON_MEDIA_TYPE = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"";
- public final static String FALLBACK_JSON_MEDIA_TYPE = "application/json; profile=\"https://www.w3.org/ns/activitystreams\"";
+ public final static String LD_JSON_MEDIA_TYPE = "application/ld+json";
public final static String ACTIVITY_MEDIA_TYPE = "application/activity+json";
public final static String ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE = ACTIVITY_MEDIA_TYPE + "; profile=\"https://www.w3.org/ns/activitystreams\"";
public final static String ACTIVITYSTREAMS_PUBLIC = "https://www.w3.org/ns/activitystreams#Public";
diff --git a/src/main/java/com/juick/www/api/webfinger/Resource.java b/src/main/java/com/juick/www/api/webfinger/Resource.java
index bc478b24..34878b69 100644
--- a/src/main/java/com/juick/www/api/webfinger/Resource.java
+++ b/src/main/java/com/juick/www/api/webfinger/Resource.java
@@ -24,6 +24,7 @@ import com.juick.www.api.webfinger.model.Link;
import com.juick.util.HttpNotFoundException;
import com.juick.service.UserService;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@@ -45,7 +46,7 @@ public class Resource {
private String baseUri;
@GetMapping(value = "/.well-known/webfinger", produces = {
- "application/jrd+json;charset=utf-8", Context.FALLBACK_JSON_MEDIA_TYPE })
+ "application/jrd+json", MediaType.APPLICATION_JSON_VALUE })
public Account getWebResource(@RequestParam String resource) {
if (resource.startsWith("acct:")) {
try {