aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick/server')
-rw-r--r--juick-server/src/main/java/com/juick/server/api/activity/Profile.java13
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 f2beaa53a..80a2851c6 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;
+ }
}