diff options
Diffstat (limited to 'juick-server/src/main/java/com/juick/server')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/api/activity/Profile.java | 25 |
1 files changed, 10 insertions, 15 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 0974444fa..c3f838ee5 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 @@ -37,24 +37,19 @@ public class Profile { public Person getUser(@PathVariable String userName) { User user = userService.getUserByName(userName); if (!user.isAnonymous()) { + UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri); Person person = new Person(); - UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(baseUri); - builder.path(String.format("/u/%s", userName)); - person.setId(builder.toUriString()); + uri.replacePath(String.format("/u/%s", userName)); + person.setId(uri.toUriString()); person.setName(userName); - UriComponentsBuilder inboxBuilder = UriComponentsBuilder.fromUriString(baseUri); - inboxBuilder.path("/post"); - person.setInbox(inboxBuilder.toUriString()); - UriComponentsBuilder outboxBuilder = UriComponentsBuilder.fromUriString(baseUri); - person.setOutbox(outboxBuilder.path(String.format("/u/%s/blog/toc", userName)).toUriString()); - UriComponentsBuilder followersBuilder = UriComponentsBuilder.fromUriString(baseUri); - person.setFollowers(followersBuilder.path(String.format("/u/%s/followers/toc", userName)).toUriString()); - UriComponentsBuilder followingBuilder = UriComponentsBuilder.fromUriString(baseUri); - person.setFollowing(followingBuilder.path(String.format("/u/%s/following/toc", userName)).toUriString()); - UriComponentsBuilder imgBuilder = UriComponentsBuilder.fromUriString(baseImagesUri); - imgBuilder.path(String.format("/a/%d.png", user.getUid())); + uri.replacePath("/post"); + person.setInbox(uri.toUriString()); + person.setOutbox(uri.replacePath(String.format("/u/%s/blog/toc", userName)).toUriString()); + person.setFollowers(uri.replacePath(String.format("/u/%s/followers/toc", userName)).toUriString()); + person.setFollowing(uri.replacePath(String.format("/u/%s/following/toc", userName)).toUriString()); + uri.replacePath(String.format("/a/%d.png", user.getUid())); Image avatar = new Image(); - avatar.setUrl(imgBuilder.toUriString()); + avatar.setUrl(uri.toUriString()); avatar.setMediaType("image/png"); person.setIcon(avatar); return person; |