diff options
Diffstat (limited to 'src/main/java/com/juick/server/api')
5 files changed, 15 insertions, 19 deletions
diff --git a/src/main/java/com/juick/server/api/Messages.java b/src/main/java/com/juick/server/api/Messages.java index 4ce1ea13..e105890f 100644 --- a/src/main/java/com/juick/server/api/Messages.java +++ b/src/main/java/com/juick/server/api/Messages.java @@ -78,7 +78,7 @@ public class Messages { int vuid = visitor.getUid(); List<Integer> mids = messagesService.getMyFeed(vuid, before_mid, true); List<Message> msgs = messagesService.getMessages(visitor, mids); - msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser()))); + msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); return ResponseEntity.ok(msgs); } return FORBIDDEN; @@ -141,7 +141,7 @@ public class Messages { } } List<Message> msgs = messagesService.getMessages(visitor, mids); - msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser()))); + msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); return ResponseEntity.ok(msgs); } @DeleteMapping("/api/messages") @@ -161,7 +161,7 @@ public class Messages { public List<Message> getDiscussions( @RequestParam(required = false, defaultValue = "0") Long to) { List<Message> msgs = messagesService.getMessages(UserUtils.getCurrentUser(), messagesService.getDiscussions(UserUtils.getCurrentUser().getUid(), to)); - msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser()))); + msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); return msgs; } @GetMapping("/api/thread") @@ -177,10 +177,10 @@ public class Messages { if (userService.getUserByName(msg.getUser().getName()).isBanned()) { throw new HttpNotFoundException(); } - msg.getUser().setAvatar(webApp.getAvatarWebPath(msg.getUser())); + msg.getUser().setAvatar(webApp.getAvatarUrl(msg.getUser())); msg.setRecommendations(new HashSet<>(messagesService.getMessageRecommendations(msg.getMid()))); List<com.juick.Message> replies = messagesService.getReplies(visitor, mid); - replies.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser()))); + replies.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); if (!visitor.isAnonymous()) { userService.updateLastSeen(visitor); applicationEventPublisher.publishEvent( diff --git a/src/main/java/com/juick/server/api/PM.java b/src/main/java/com/juick/server/api/PM.java index 05f46d8d..a80ad0dc 100644 --- a/src/main/java/com/juick/server/api/PM.java +++ b/src/main/java/com/juick/server/api/PM.java @@ -69,7 +69,7 @@ public class PM { } List<Message> msgs = pmQueriesService.getPMMessages(visitor.getUid(), uid); - msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser()))); + msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); return msgs; } @@ -115,7 +115,7 @@ public class PM { // TODO: ignore cnt param for now but make sure paging param will not be cnt List<Chat> lastconv = pmQueriesService.getLastChats(visitor); - lastconv.forEach(c -> c.setAvatar(webApp.getAvatarWebPath(c))); + lastconv.forEach(c -> c.setAvatar(webApp.getAvatarUrl(c))); PrivateChats pms = new PrivateChats(); pms.setUsers(lastconv); return pms; diff --git a/src/main/java/com/juick/server/api/Users.java b/src/main/java/com/juick/server/api/Users.java index c1cee8b5..6f9ab290 100644 --- a/src/main/java/com/juick/server/api/Users.java +++ b/src/main/java/com/juick/server/api/Users.java @@ -69,12 +69,12 @@ public class Users { if (!unames.isEmpty() && unames.size() < 20) users.addAll(userService.getUsersByName(unames)); } - users.forEach(u -> u.setAvatar(webApp.getAvatarWebPath(u))); + users.forEach(u -> u.setAvatar(webApp.getAvatarUrl(u))); if (!users.isEmpty()) return users; if (!UserUtils.getCurrentUser().isAnonymous()) { User visitor = UserUtils.getCurrentUser(); - visitor.setAvatar(webApp.getAvatarWebPath(visitor)); + visitor.setAvatar(webApp.getAvatarUrl(visitor)); return Collections.singletonList(visitor); } @@ -93,7 +93,7 @@ public class Users { me.setUnreadCount(unread.size()); me.setRead(userService.getUserFriends(visitor.getUid())); me.setReaders(userService.getUserReaders(visitor.getUid())); - me.setAvatar(webApp.getAvatarWebPath(visitor)); + me.setAvatar(webApp.getAvatarUrl(visitor)); return me; } @@ -118,7 +118,7 @@ public class Users { if (uid > 0) { List<User> friends = userService.getUserFriends(uid); - friends.forEach(f -> f.setAvatar(webApp.getAvatarWebPath(f))); + friends.forEach(f -> f.setAvatar(webApp.getAvatarUrl(f))); return friends; } throw new HttpNotFoundException(); @@ -145,7 +145,7 @@ public class Users { if (uid > 0) { List<User> readers = userService.getUserReaders(uid); - readers.forEach(r -> r.setAvatar(webApp.getAvatarWebPath(r))); + readers.forEach(r -> r.setAvatar(webApp.getAvatarUrl(r))); return readers; } throw new HttpNotFoundException(); @@ -155,7 +155,7 @@ public class Users { public UserInfo getUserInfo(@PathVariable String uname) { User user = userService.getUserByName(uname); if (!user.isBanned()) { - user.setAvatar(webApp.getAvatarWebPath(user)); + user.setAvatar(webApp.getAvatarUrl(user)); return userService.getUserInfo(user); } throw new HttpNotFoundException(); diff --git a/src/main/java/com/juick/server/api/activity/Profile.java b/src/main/java/com/juick/server/api/activity/Profile.java index 979f6265..d8a8fd90 100644 --- a/src/main/java/com/juick/server/api/activity/Profile.java +++ b/src/main/java/com/juick/server/api/activity/Profile.java @@ -78,8 +78,6 @@ public class Profile { private String domain; @Value("${ap_base_uri:http://localhost:8080/}") private String baseUri; - @Value("${img_url:http://localhost:8080/i/}") - private String baseImagesUri; @Inject private ObjectMapper jsonMapper; @Inject @@ -103,10 +101,8 @@ public class Profile { person.setOutbox(activityPubManager.outboxUri(user)); person.setFollowers(activityPubManager.followersUri(user)); person.setFollowing(activityPubManager.followingUri(user)); - UriComponentsBuilder image = UriComponentsBuilder.fromUriString(baseImagesUri); - image.path(webApp.getAvatarWebPath(user)); Image avatar = new Image(); - avatar.setUrl(image.toUriString()); + avatar.setUrl(webApp.getAvatarUrl(user)); avatar.setMediaType("image/png"); person.setIcon(avatar); return (Person) Context.build(person); diff --git a/src/main/java/com/juick/server/api/rss/MessagesView.java b/src/main/java/com/juick/server/api/rss/MessagesView.java index 2dd9f53b..05bc0bd6 100644 --- a/src/main/java/com/juick/server/api/rss/MessagesView.java +++ b/src/main/java/com/juick/server/api/rss/MessagesView.java @@ -87,7 +87,7 @@ public class MessagesView extends AbstractRssFeedView { String link = String.format("http://juick.com/%s/", user.getName()); feed.setLink(link); Image rssImage = new Image(); - rssImage.setUrl(webApp.getAvatarWebPath(user)); + rssImage.setUrl(webApp.getAvatarUrl(user)); rssImage.setTitle(title); rssImage.setLink(link); feed.setImage(rssImage); |