diff options
author | Vitaly Takmazov | 2018-09-10 23:37:15 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-09-10 23:37:15 +0300 |
commit | a7bd0c5cd2330a84667b9762b4fd2cb35b1c20d4 (patch) | |
tree | 6d4a4e395a4e4c211f8372733cf87a431ccdb21d /juick-server/src/main/java/com | |
parent | da66e1a4e3bd9a9c85d9eee691b31d78f66d6949 (diff) |
fix ActivityPub context
Diffstat (limited to 'juick-server/src/main/java/com')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/api/activity/Profile.java | 14 | ||||
-rw-r--r-- | juick-server/src/main/java/com/juick/server/api/activity/model/ActivityObject.java | 9 |
2 files changed, 15 insertions, 8 deletions
diff --git a/juick-server/src/main/java/com/juick/server/api/activity/Profile.java b/juick-server/src/main/java/com/juick/server/api/activity/Profile.java index 89236f03..06735117 100644 --- a/juick-server/src/main/java/com/juick/server/api/activity/Profile.java +++ b/juick-server/src/main/java/com/juick/server/api/activity/Profile.java @@ -63,7 +63,7 @@ public class Profile { avatar.setUrl(image.toUriString()); avatar.setMediaType("image/png"); person.setIcon(avatar); - return person; + return (Person) ActivityObject.build(person); } throw new HttpNotFoundException(); } @@ -76,7 +76,7 @@ public class Profile { blog.setId(ServletUriComponentsBuilder.fromCurrentRequestUri().toUriString()); blog.setTotalItems(userService.getStatsMessages(user.getUid())); blog.setFirst(uriComponentsBuilder.path(String.format("/u/%s/blog", userName)).toUriString()); - return blog; + return (OrderedCollection) ActivityObject.build(blog); } throw new HttpNotFoundException(); } @@ -124,7 +124,7 @@ public class Profile { if (beforeNext > 0) { page.setNext(uri.queryParam("before", beforeNext).toUriString()); } - return page; + return (OrderedCollectionPage) ActivityObject.build(page); } throw new HttpNotFoundException(); } @@ -137,7 +137,7 @@ public class Profile { followers.setId(ServletUriComponentsBuilder.fromCurrentRequestUri().toUriString()); followers.setTotalItems(userService.getStatsMyReaders(user.getUid())); followers.setFirst(uriComponentsBuilder.path(String.format("/u/%s/followers", userName)).toUriString()); - return followers; + return (OrderedCollection) ActivityObject.build(followers); } throw new HttpNotFoundException(); } @@ -167,7 +167,7 @@ public class Profile { if (hasNext) { result.setNext(uriComponentsBuilder.queryParam("page", page + 1).toUriString()); } - return result; + return (OrderedCollectionPage) ActivityObject.build(result); } throw new HttpNotFoundException(); } @@ -180,7 +180,7 @@ public class Profile { following.setId(ServletUriComponentsBuilder.fromCurrentRequestUri().toUriString()); following.setTotalItems(userService.getUserFriends(user.getUid()).size()); following.setFirst(uriComponentsBuilder.path(String.format("/u/%s/followers", userName)).toUriString()); - return following; + return (OrderedCollection) ActivityObject.build(following); } throw new HttpNotFoundException(); } @@ -210,7 +210,7 @@ public class Profile { if (hasNext) { result.setNext(uriComponentsBuilder.queryParam("page", page + 1).toUriString()); } - return result; + return (OrderedCollectionPage) ActivityObject.build(result); } throw new HttpNotFoundException(); } diff --git a/juick-server/src/main/java/com/juick/server/api/activity/model/ActivityObject.java b/juick-server/src/main/java/com/juick/server/api/activity/model/ActivityObject.java index 84a3e018..fceb3612 100644 --- a/juick-server/src/main/java/com/juick/server/api/activity/model/ActivityObject.java +++ b/juick-server/src/main/java/com/juick/server/api/activity/model/ActivityObject.java @@ -9,6 +9,8 @@ import java.util.List; public abstract class ActivityObject { + private List<String> context; + private String id; private Instant published; @@ -27,7 +29,7 @@ public abstract class ActivityObject { @JsonProperty("@context") public List<String> getContext() { - return Arrays.asList(ACTIVITY_STREAMS_URI, SECURITY_URI); + return context; } public final static String ACTIVITY_STREAMS_URI = "https://www.w3.org/ns/activitystreams"; @@ -42,4 +44,9 @@ public abstract class ActivityObject { public void setPublished(Instant published) { this.published = published; } + + public static ActivityObject build(ActivityObject response) { + response.context = Arrays.asList(ACTIVITY_STREAMS_URI, SECURITY_URI); + return response; + } } |