From d8cb85ce8ebc883f63fc659dfc3785bbf817c9bc Mon Sep 17 00:00:00 2001 From: seannian Date: Mon, 21 Oct 2024 08:51:18 -0700 Subject: [PATCH] small fix for public statuses --- .../server/controller/InboxController.java | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/edu/sjsu/moth/server/controller/InboxController.java b/server/src/main/java/edu/sjsu/moth/server/controller/InboxController.java index bd5746f..05a2205 100644 --- a/server/src/main/java/edu/sjsu/moth/server/controller/InboxController.java +++ b/server/src/main/java/edu/sjsu/moth/server/controller/InboxController.java @@ -14,6 +14,7 @@ import edu.sjsu.moth.server.service.AccountService; import edu.sjsu.moth.server.service.ActorService; import edu.sjsu.moth.server.service.StatusService; +import edu.sjsu.moth.server.util.MothConfiguration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; @@ -29,6 +30,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; +import java.util.Collections; import java.util.List; @RestController @@ -169,17 +171,37 @@ public Mono usersInbox(@PathVariable String id, @RequestBody JsonNode in @GetMapping("/users/{id}/following") public Mono usersFollowing( @PathVariable String id, - @RequestParam(required = false) Integer page, @RequestParam(required = false) Integer limit) { + @RequestParam(required = false, defaultValue = "1") Integer page, + @RequestParam(required = false, defaultValue = "10") Integer limit) { return accountService.usersFollow(id, page, limit, "following"); } @GetMapping("/users/{id}/followers") public Mono usersFollowers( @PathVariable String id, - @RequestParam(required = false) Integer page, @RequestParam(required = false) Integer limit) { + @RequestParam(required = false, defaultValue = "1") Integer page, + @RequestParam(required = false, defaultValue = "10") Integer limit) { return accountService.usersFollow(id, page, limit, "followers"); } + @GetMapping("/users/{id}/collections/featured") + public Mono> getFeaturedCollection(@PathVariable String id) { + String collectionId = + MothConfiguration.mothConfiguration.getServerName() + "/users/" + id + "/collections/featured"; + OrderedCollection featuredCollection = new OrderedCollection(collectionId, 0, Collections.emptyList()); + + return Mono.just(ResponseEntity.ok(featuredCollection)); + } + + @GetMapping("/users/{id}/collections/tags") + public Mono> getTagsCollection(@PathVariable String id) { + String collectionId = + MothConfiguration.mothConfiguration.getServerName() + "/users/" + id + "/collections/tags"; + OrderedCollection tagsCollection = new OrderedCollection(collectionId, 0, Collections.emptyList()); + + return Mono.just(ResponseEntity.ok(tagsCollection)); + } + @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "@context", "id", "type", "totalItems", "first", "next", "partOf", "orderedItems" }) public record UsersFollowResponse(String id, String type, int totalItems, String first, String next, String partOf, @@ -189,4 +211,13 @@ public String getContext() { return "https://www.w3.org/ns/activitystreams"; } } + + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonPropertyOrder({ "@context", "id", "type", "totalItems", "orderedItems" }) + public record OrderedCollection(@JsonProperty("@context") String context, String id, String type, int totalItems, + List orderedItems) { + public OrderedCollection(String id, int totalItems, List orderedItems) { + this("https://www.w3.org/ns/activitystreams", id, "OrderedCollection", totalItems, orderedItems); + } + } } \ No newline at end of file