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 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'juick-server/src/main/java/com/juick/server/api/activity/Profile.java') 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; -- cgit v1.2.3