Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented followers and following lists #147

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
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
Loading