From 25e10eabde194dd75d3f91d2ed5683f1858cf7e1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 5 Oct 2018 12:57:43 +0300 Subject: ActivityPub: web urls for Note and Person --- .../java/com/juick/server/api/activity/Profile.java | 17 +++++------------ .../com/juick/server/api/activity/model/Context.java | 9 +++++++++ .../java/com/juick/server/api/activity/model/Image.java | 9 --------- .../com/juick/server/api/activity/model/Person.java | 9 --------- 4 files changed, 14 insertions(+), 30 deletions(-) (limited to 'juick-server/src/main/java/com/juick/server/api') 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 160270f4..98d2ba9d 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 @@ -68,7 +68,7 @@ public class Profile { if (!user.isAnonymous()) { Person person = new Person(); person.setId(activityPubManager.personUri(user)); - person.setUrl(activityPubManager.personUri(user)); + person.setUrl(activityPubManager.personWebUri(user)); person.setName(userName); person.setPreferredUsername(userName); Key publicKey = new Key(); @@ -113,11 +113,8 @@ public class Profile { if (!user.isAnonymous()) { UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri); String personUri = uri.path(String.format("/u/%s", userName)).toUriString(); - String followersUri = activityPubManager.followersUri(user); List mids = messagesService.getUserBlog(user.getUid(), 0, before); List notes = messagesService.getMessages(visitor, mids).stream().map(activityPubManager::makeNote).collect(Collectors.toList()); - Person person = new Person(); - person.setName(user.getName()); OrderedCollectionPage page = new OrderedCollectionPage(); page.setPartOf(uri.replacePath(String.format("/u/%s/blog/toc", userName)).toUriString()); page.setFirst(uri.replacePath(String.format("/u/%s/blog", userName)).toUriString()); @@ -165,15 +162,13 @@ public class Profile { List followers = userService.getUserReaders(user.getUid()); Stream followersPage = followers.stream().skip(20 * page).limit(20); - Person person = new Person(); - person.setName(user.getName()); OrderedCollectionPage result = new OrderedCollectionPage(); result.setId(ServletUriComponentsBuilder.fromCurrentRequestUri().toUriString()); result.setOrderedItems(followersPage.map(a -> { Person follower = new Person(); follower.setName(a.getName()); - person.setPreferredUsername(a.getName()); - follower.setUrl(uriComponentsBuilder.replacePath(String.format("/u/%s", a.getName())).toUriString()); + follower.setPreferredUsername(a.getName()); + follower.setUrl(activityPubManager.personWebUri(a)); return follower; }).collect(Collectors.toList())); boolean hasNext = followers.size() <= 20 * page; @@ -209,15 +204,13 @@ public class Profile { List following = userService.getUserFriends(user.getUid()); Stream followingPage = following.stream().skip(20 * page).limit(20); - Person person = new Person(); - person.setName(user.getName()); - person.setPreferredUsername(user.getName()); OrderedCollectionPage result = new OrderedCollectionPage(); result.setId(ServletUriComponentsBuilder.fromCurrentRequestUri().toUriString()); result.setOrderedItems(followingPage.map(a -> { Person follower = new Person(); follower.setName(a.getName()); - follower.setUrl(uriComponentsBuilder.replacePath(String.format("/u/%s", a.getName())).toUriString()); + follower.setPreferredUsername(a.getName()); + follower.setUrl(activityPubManager.personWebUri(a)); return follower; }).collect(Collectors.toList())); boolean hasNext = following.size() <= 20 * page; diff --git a/juick-server/src/main/java/com/juick/server/api/activity/model/Context.java b/juick-server/src/main/java/com/juick/server/api/activity/model/Context.java index 9eb03c6f..2bc499aa 100644 --- a/juick-server/src/main/java/com/juick/server/api/activity/model/Context.java +++ b/juick-server/src/main/java/com/juick/server/api/activity/model/Context.java @@ -36,6 +36,7 @@ public abstract class Context { private Instant published; + private String url; private List to; @@ -81,4 +82,12 @@ public abstract class Context { response.context = Arrays.asList(ACTIVITY_STREAMS_URI, SECURITY_URI); return response; } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } } diff --git a/juick-server/src/main/java/com/juick/server/api/activity/model/Image.java b/juick-server/src/main/java/com/juick/server/api/activity/model/Image.java index c8f869a5..07d6ff99 100644 --- a/juick-server/src/main/java/com/juick/server/api/activity/model/Image.java +++ b/juick-server/src/main/java/com/juick/server/api/activity/model/Image.java @@ -2,7 +2,6 @@ package com.juick.server.api.activity.model; public class Image extends Context { private String mediaType; - private String url; public String getMediaType() { return mediaType; @@ -11,12 +10,4 @@ public class Image extends Context { public void setMediaType(String mediaType) { this.mediaType = mediaType; } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } } diff --git a/juick-server/src/main/java/com/juick/server/api/activity/model/Person.java b/juick-server/src/main/java/com/juick/server/api/activity/model/Person.java index 8a817c18..00006d4f 100644 --- a/juick-server/src/main/java/com/juick/server/api/activity/model/Person.java +++ b/juick-server/src/main/java/com/juick/server/api/activity/model/Person.java @@ -11,7 +11,6 @@ public class Person extends Context { private String outbox; private String following; private String followers; - private String url; private Key publicKey; @Override @@ -68,14 +67,6 @@ public class Person extends Context { this.followers = followers; } - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - @JsonTypeInfo(use = JsonTypeInfo.Id.NONE) public Key getPublicKey() { return publicKey; -- cgit v1.2.3