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 51813a2..5dc1b8e 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 @@ -187,7 +187,17 @@ public Mono> userFollowing( @RequestParam(required = false, defaultValue = "0") String since_id, @RequestParam(required = false) String min_id, @RequestParam(required = false, defaultValue = "20") int limit) { - return accountService.usersFollow(id, max_id, since_id, min_id, limit); + return accountService.userFollowInfo(id, max_id, since_id, min_id, limit); + } + + @GetMapping("/api/v1/accounts/{id}/followers") + public Mono> userFollowers( + @PathVariable("id") String id, + @RequestParam(required = false) String max_id, + @RequestParam(required = false, defaultValue = "0") String since_id, + @RequestParam(required = false) String min_id, + @RequestParam(required = false, defaultValue = "20") int limit) { + return accountService.userFollowingInfo(id, max_id, since_id, min_id, limit); } @GetMapping("/api/v1/follow_requests") diff --git a/server/src/main/java/edu/sjsu/moth/server/service/AccountService.java b/server/src/main/java/edu/sjsu/moth/server/service/AccountService.java index 4a9605f..96a835d 100644 --- a/server/src/main/java/edu/sjsu/moth/server/service/AccountService.java +++ b/server/src/main/java/edu/sjsu/moth/server/service/AccountService.java @@ -100,13 +100,20 @@ public Mono followerHandler(String id, JsonNode inboxNode, String reques return Mono.empty(); } - public Mono> usersFollow(String id, String max_id, String since_id, String min_id, - Integer limit) { + public Mono> userFollowInfo(String id, String max_id, String since_id, String min_id, + Integer limit) { return followRepository.findAllByFollowerId(id) .flatMap(follow -> accountRepository.findById(follow.id.followed_id)) .collect(ArrayList::new, ArrayList::add); } + public Mono> userFollowingInfo(String id, String max_id, String since_id, String min_id, + Integer limit) { + return followRepository.findAllByFollowedId(id) + .flatMap(follow -> accountRepository.findById(follow.id.follower_id)) + .collect(ArrayList::new, ArrayList::add); + } + public Mono usersFollow(String id, Integer page, Integer limit, String followType) { var items = followType.equals("following") ?