diff --git a/server/src/main/java/edu/sjsu/moth/server/annotations/RequestObjectMethodArgumentResolver.java b/server/src/main/java/edu/sjsu/moth/server/annotations/RequestObjectMethodArgumentResolver.java index 7fc4cc42..7c7a935e 100644 --- a/server/src/main/java/edu/sjsu/moth/server/annotations/RequestObjectMethodArgumentResolver.java +++ b/server/src/main/java/edu/sjsu/moth/server/annotations/RequestObjectMethodArgumentResolver.java @@ -8,6 +8,7 @@ import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBufferUtils; +import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.stereotype.Component; @@ -69,6 +70,13 @@ public boolean supportsParameter(MethodParameter parameter) { } var root = new ObjectNode(JsonNodeFactory.instance); parseParams(exchange.getRequest().getQueryParams(), root); + if (exchange.getRequest().getMethod().equals(HttpMethod.GET)) { + try { + return Mono.just(reader.readValue(root)); + } catch (IOException e) { + return Mono.error(e); + } + } return DataBufferUtils.join(exchange.getRequest().getBody()).flatMap(db -> { var formdata = db.toString(UTF_8); var exps = StringUtils.delimitedListToStringArray(formdata, "&"); diff --git a/server/src/main/java/edu/sjsu/moth/server/controller/AccountController.java b/server/src/main/java/edu/sjsu/moth/server/controller/AccountController.java index 43ac6f65..496322ff 100644 --- a/server/src/main/java/edu/sjsu/moth/server/controller/AccountController.java +++ b/server/src/main/java/edu/sjsu/moth/server/controller/AccountController.java @@ -3,6 +3,7 @@ import edu.sjsu.moth.generated.CredentialAccount; import edu.sjsu.moth.generated.Relationship; import edu.sjsu.moth.generated.Source; +import edu.sjsu.moth.server.annotations.RequestObject; import edu.sjsu.moth.server.db.Account; import edu.sjsu.moth.server.db.AccountField; import edu.sjsu.moth.server.service.AccountService; @@ -25,6 +26,7 @@ import java.security.Principal; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.regex.Pattern; @@ -126,11 +128,10 @@ public Mono> verifyCredentials(Principal user, } @GetMapping("/api/v1/accounts/relationships") - public ResponseEntity> getApiV1AccountsRelationships(Principal user, String[] id, - @RequestParam(required = false, - defaultValue = "false") boolean with_suspended) { + public ResponseEntity> getApiV1AccountsRelationships(Principal user, + @RequestObject RelationshipRequest req) { var relationships = new ArrayList(); - for (var i : id) { + for (var i : req.id) { relationships.add( new Relationship(i, false, false, false, false, false, false, false, false, false, false, false, false, "")); @@ -160,4 +161,9 @@ public Mono> getBlocks(Integer max_id, Integer since_id, Inte return Mono.just(new ArrayList()); } + private static class RelationshipRequest { + public String[] id; + public Boolean with_suspended; + } + }