Skip to content

Commit

Permalink
implemented followers and following lists (#147)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
harsita-keerthi and github-actions[bot] authored Oct 1, 2024
1 parent 0bebb29 commit 7bc2627
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,17 @@ public Mono<ArrayList<Account>> 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<ArrayList<Account>> 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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,20 @@ public Mono<String> followerHandler(String id, JsonNode inboxNode, String reques
return Mono.empty();
}

public Mono<ArrayList<Account>> usersFollow(String id, String max_id, String since_id, String min_id,
Integer limit) {
public Mono<ArrayList<Account>> 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<ArrayList<Account>> 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<InboxController.UsersFollowResponse> usersFollow(String id, Integer page, Integer limit,
String followType) {
var items = followType.equals("following") ?
Expand Down

0 comments on commit 7bc2627

Please sign in to comment.