Skip to content

Commit

Permalink
added /following and /follow_requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nishanth Uchil authored and Nishanth Uchil committed Jul 25, 2024
1 parent 3aec030 commit 6a8d9ce
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,29 @@ public Mono<ResponseEntity<Relationship>> followUser(@PathVariable("id") String
.map(ResponseEntity::ok);
}

// @GetMapping("/api/v1/accounts/{id}/following")
// public Mono<InboxController.UsersFollowResponse> userFollowing(
// @PathVariable String id,
// @RequestParam(required = false) Integer page,
// @RequestParam(required = false, defaultValue = "40") Integer limit) {
// return accountService.usersFollow(id, page, limit, "following");
// }

@GetMapping("/api/v1/accounts/{id}/following")
public Mono<InboxController.UsersFollowResponse> userFollowing(
@PathVariable String id,
@RequestParam(required = false) Integer page,
@RequestParam(required = false, defaultValue = "40") Integer limit) {
return accountService.usersFollow(id, page, limit, "following");
public Mono<ArrayList<Account>> userFollowing(@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.usersFollow(id, max_id, since_id, min_id, limit);
}

@GetMapping("/api/v1/follow_requests")
public Mono<ArrayList<Account>> followRequests(@RequestParam(required = false) String max_id,
@RequestParam(required = false, defaultValue = "0") String since_id,
@RequestParam(required = false, defaultValue = "20") int limit)
{
return Mono.just(new ArrayList<Account>());
}

@GetMapping("/api/v2/suggestions")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ 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){
return followRepository.findAllByFollowerId(id)
.flatMap(follow -> accountRepository.findById(follow.id.followed_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 6a8d9ce

Please sign in to comment.