From ae3da8bbc97ad839505dc14e3f524249b5802940 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 19 Feb 2019 19:11:25 +0300 Subject: Return legacy avatar url from legacy avatar endpoint --- src/main/java/com/juick/server/api/Users.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/com/juick/server/api/Users.java b/src/main/java/com/juick/server/api/Users.java index 03e916d1..216cd68d 100644 --- a/src/main/java/com/juick/server/api/Users.java +++ b/src/main/java/com/juick/server/api/Users.java @@ -174,7 +174,8 @@ public class Users { @Deprecated @GetMapping("/api/avatar") public ResponseEntity getAvatarUrl(@RequestParam(required = false) String uname, - @RequestParam(required = false) String jid) { + @RequestParam(required = false) String jid, + @RequestParam(required = false, defaultValue = "48") Integer size) { User user = AnonymousUser.INSTANCE; if (StringUtils.isNotEmpty(uname)) { user = userService.getUserByName(uname); @@ -183,8 +184,9 @@ public class Users { user = userService.getUserByJID(jid); } if (!user.isAnonymous()) { + String imagePrefix = size == 32 ? "as" : "a"; HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.setLocation(URI.create(webApp.getAvatarUrl(user))); + httpHeaders.setLocation(URI.create(String.format("http://i.juick.com/%s/%d.png", imagePrefix, user.getUid()))); return new ResponseEntity<>(httpHeaders, HttpStatus.MOVED_PERMANENTLY); } return new ResponseEntity<>(HttpStatus.NOT_FOUND); -- cgit v1.2.3