diff options
author | Vitaly Takmazov | 2018-10-05 16:39:40 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-10-05 16:39:40 +0300 |
commit | 279b60a55a9f9929d75f41fc0e546c6ceed16eb6 (patch) | |
tree | 69b6b709cea39e65d9d21de3c4a07a7d85bb9552 /juick-server/src/main/java | |
parent | 320e28e55006c317e166d3c1e7b093fafba22462 (diff) |
fetch anonymous user info
Diffstat (limited to 'juick-server/src/main/java')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/api/activity/Profile.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/juick-server/src/main/java/com/juick/server/api/activity/Profile.java b/juick-server/src/main/java/com/juick/server/api/activity/Profile.java index f2beaa53..80a2851c 100644 --- a/juick-server/src/main/java/com/juick/server/api/activity/Profile.java +++ b/juick-server/src/main/java/com/juick/server/api/activity/Profile.java @@ -11,6 +11,7 @@ import com.juick.server.api.activity.model.activities.Create; import com.juick.server.api.activity.model.activities.Delete; import com.juick.server.api.activity.model.activities.Follow; import com.juick.server.api.activity.model.activities.Undo; +import com.juick.server.util.HttpBadRequestException; import com.juick.server.util.HttpNotFoundException; import com.juick.server.util.UserUtils; import com.juick.service.MessagesService; @@ -23,6 +24,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationEventPublisher; 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.servlet.support.ServletUriComponentsBuilder; @@ -274,4 +276,15 @@ public class Profile { } return new ResponseEntity<>(HttpStatus.UNAUTHORIZED); } + @PostMapping(value = "/u/", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + public User fetchUser(@RequestParam URI uri) { + Person person = (Person) signatureManager.getContext(uri).orElseThrow(HttpBadRequestException::new); + User user = new User(); + user.setUri(URI.create(person.getUrl())); + user.setName(person.getPreferredUsername()); + if (person.getIcon() != null) { + user.setAvatar(person.getIcon().getUrl()); + } + return user; + } } |