diff options
author | 2018-11-20 16:37:42 +0300 | |
---|---|---|
committer | 2018-11-20 16:37:42 +0300 | |
commit | a3ec3587e1fa33e4e08da9783d9d66c55ac84550 (patch) | |
tree | 9311de2f6511421eefed3e2e10bc821d2179dbd4 /src/main/java/com/juick/server/api/Users.java | |
parent | d2b04d9b719b79a35e90b1c5569722ba5cbf794b (diff) |
avatar public url
Diffstat (limited to 'src/main/java/com/juick/server/api/Users.java')
-rw-r--r-- | src/main/java/com/juick/server/api/Users.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main/java/com/juick/server/api/Users.java b/src/main/java/com/juick/server/api/Users.java index 7686d722..791071a5 100644 --- a/src/main/java/com/juick/server/api/Users.java +++ b/src/main/java/com/juick/server/api/Users.java @@ -22,6 +22,7 @@ import com.juick.model.ApplicationStatus; import com.juick.model.UserInfo; import com.juick.server.util.HttpForbiddenException; import com.juick.server.util.HttpNotFoundException; +import com.juick.server.www.WebApp; import com.juick.service.CrosspostService; import com.juick.service.EmailService; import com.juick.service.MessagesService; @@ -49,6 +50,8 @@ public class Users { private CrosspostService crosspostService; @Inject private EmailService emailService; + @Inject + private WebApp webApp; @RequestMapping(value = "/api/auth", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public String getAuthToken() { @@ -66,11 +69,13 @@ public class Users { if (!unames.isEmpty() && unames.size() < 20) users.addAll(userService.getUsersByName(unames)); } - + users.forEach(u -> u.setAvatar(webApp.getAvatarPublicUrl(u))); if (!users.isEmpty()) return users; if (!UserUtils.getCurrentUser().isAnonymous()) { - return Collections.singletonList(UserUtils.getCurrentUser()); + User visitor = UserUtils.getCurrentUser(); + visitor.setAvatar(webApp.getAvatarPublicUrl(visitor)); + return Collections.singletonList(visitor); } throw new HttpNotFoundException(); @@ -88,6 +93,7 @@ public class Users { me.setUnreadCount(unread.size()); me.setRead(userService.getUserFriends(visitor.getUid())); me.setReaders(userService.getUserReaders(visitor.getUid())); + me.setAvatar(webApp.getAvatarPublicUrl(visitor)); return me; } @@ -111,7 +117,9 @@ public class Users { } if (uid > 0) { - return userService.getUserFriends(uid); + List<User> friends = userService.getUserFriends(uid); + friends.forEach(f -> f.setAvatar(webApp.getAvatarPublicUrl(f))); + return friends; } throw new HttpNotFoundException(); } @@ -136,7 +144,9 @@ public class Users { } if (uid > 0) { - return userService.getUserReaders(uid); + List<User> readers = userService.getUserReaders(uid); + readers.forEach(r -> r.setAvatar(webApp.getAvatarPublicUrl(r))); + return readers; } throw new HttpNotFoundException(); } @@ -145,6 +155,7 @@ public class Users { public UserInfo getUserInfo(@PathVariable String uname) { User user = userService.getUserByName(uname); if (!user.isBanned()) { + user.setAvatar(webApp.getAvatarPublicUrl(user)); return userService.getUserInfo(user); } throw new HttpNotFoundException(); |