aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-02-19 16:03:55 +0300
committerGravatar Vitaly Takmazov2019-02-19 16:03:55 +0300
commitfc7ad5f5849e28c0f0d4d5eed695236d0576b4b3 (patch)
treebf5e9401e9ad0153b9ca3ef4d708aecde0aae8c0 /src/main/java
parent1eed5a8f1053f87b10cb3410e477792075d7f3e4 (diff)
legacy avatar api
Diffstat (limited to 'src/main/java')
-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();