aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/juick/server/api/Users.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/java/com/juick/server/api/Users.java b/src/main/java/com/juick/server/api/Users.java
index 5c6efe0c..03e916d1 100644
--- a/src/main/java/com/juick/server/api/Users.java
+++ b/src/main/java/com/juick/server/api/Users.java
@@ -18,18 +18,23 @@
package com.juick.server.api;
import com.juick.User;
+import com.juick.model.AnonymousUser;
import com.juick.model.ApplicationStatus;
import com.juick.server.util.*;
import com.juick.server.www.WebApp;
import com.juick.service.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.inject.Inject;
import java.io.IOException;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -166,6 +171,24 @@ public class Users {
throw new HttpNotFoundException();
}
+ @Deprecated
+ @GetMapping("/api/avatar")
+ public ResponseEntity<Void> getAvatarUrl(@RequestParam(required = false) String uname,
+ @RequestParam(required = false) String jid) {
+ User user = AnonymousUser.INSTANCE;
+ if (StringUtils.isNotEmpty(uname)) {
+ user = userService.getUserByName(uname);
+ }
+ if (user.isAnonymous() && StringUtils.isNotEmpty(jid)) {
+ user = userService.getUserByJID(jid);
+ }
+ if (!user.isAnonymous()) {
+ HttpHeaders httpHeaders = new HttpHeaders();
+ httpHeaders.setLocation(URI.create(webApp.getAvatarUrl(user)));
+ return new ResponseEntity<>(httpHeaders, HttpStatus.MOVED_PERMANENTLY);
+ }
+ return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+ }
class SecureUser extends User {
public String getHash() {
return getAuthHash();