Skip to content

feat: let API clients list mutuals and followers they know - #1542

Draft
WendellAdriel wants to merge 5 commits into
dev-null-sh:productionfrom
WendellAdriel:feat/api-mutuals-followers-you-know
Draft

WendellAdriel wants to merge 5 commits into
dev-null-sh:productionfrom
WendellAdriel:feat/api-mutuals-followers-you-know

Conversation

@WendellAdriel

@WendellAdriel WendellAdriel commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

The web profile has Mutuals and Followers you know lists, and the API's UserResource already returns followed_by_following_count. But there's no API route for either list, so a device client can show the count and not the people behind it.

This adds signed GET api/v1/users/{handle}/mutuals and GET api/v1/users/{handle}/followers-you-know, next to the followers and following routes. They return the same users in the same order as the web, 30 a page with a cursor, with is_followed, follows_you and bio_profiles like the followers list (#1538). Across a block they answer with the followers route's codes.

To share one builder with the web, the mutuals query moves from UserMutualsController into UserConnectionsQuery::mutuals(). FollowersYouKnowQuery::builder() stops sorting, because UserConnectionsQuery::builder() already sorts and adds the flags. Wrapping one in the other sorted twice, which added a duplicate cursor condition to every next page. The web followers-you-know page now uses UserConnectionsQuery::builder() too, so it no longer repeats the flag queries. Both web lists show the same users in the same order as before.

Summary by CodeRabbit

  • New Features
    • Added API access to a user’s mutual connections and followers also followed by the signed-in viewer.
    • Follower and following lists now include profiles linked in each person’s bio.

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds signed API lists for mutuals and followers known to the viewer. Connection-list responses include profiles mentioned in listed users’ bios. Web connection lists also use shared connection-query logic.

Changes: Connection lists and bio profiles

Layer / File(s) Summary
Shared connection and profile queries
app/Queries/UserConnectionsQuery.php, app/Queries/FollowersYouKnowQuery.php, app/Queries/BioProfilesQuery.php, tests/Unit/Queries/BioProfilesQueryTest.php
The query layer adds mutual connections, removes ordering from the followers-you-know query, and supports batched profile lookups for multiple users.
Shared queries in web and API lists
app/Http/Controllers/UserFollowersYouKnowController.php, app/Http/Controllers/UserMutualsController.php, app/Http/Resources/UserConnectionCollection.php, app/Http/Controllers/Api/UserFollowersController.php, app/Http/Controllers/Api/UserFollowingController.php, tests/Feature/Controllers/Api/UserFollowersControllerTest.php, tests/Feature/Controllers/Api/UserFollowingControllerTest.php
Web lists use the shared connection query. API follower and following responses use UserConnectionCollection and include bio profile mappings.
Signed mutuals and followers-you-know endpoints
routes/api.php, app/Http/Requests/ListApiUserMutualsRequest.php, app/Http/Requests/ListApiUserFollowersYouKnowRequest.php, app/Http/Controllers/Api/UserMutualsController.php, app/Http/Controllers/Api/UserFollowersYouKnowController.php, tests/Feature/Controllers/Api/UserMutualsControllerTest.php, tests/Feature/Controllers/Api/UserFollowersYouKnowControllerTest.php, KNOWLEDGE_BASE.md
Authenticated routes expose mutuals and followers-you-know lists. Request classes enforce across-block authorization, and feature tests cover response contents, pagination, query counts, blocking, and unknown handles.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  actor Client as Signed API client
  participant Routes as API routes
  participant Request as List API request
  participant Controller as API connection controller
  participant Queries as Connection queries
  participant BioProfilesQuery
  participant Collection as UserConnectionCollection

  Client->>Routes: Request mutuals or followers-you-know
  Routes->>Request: Authorize viewer and target user
  Routes->>Controller: Invoke index
  alt Followers the viewer knows
    Controller->>Queries: Build target followers followed by viewer
  else Mutuals
    Controller->>Queries: Get reciprocal connections
  end
  Controller->>BioProfilesQuery: Get profiles for page items
  Controller->>Collection: Create collection with page and profiles
  Collection-->>Client: Return connection data and pagination
Loading

Possibly related PRs

Suggested reviewers: mnapoli, xheaven, ashkesarmaa

Merge Risk: Minimal · up to addf8

This adds signed API lists for mutuals and followers you know, and adds bio profile data to the existing connection lists. No actionable merge-blocking risk was found in the supplied context.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: adding API access to mutuals and followers the requesting user knows.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9686373d-ae4b-47c2-b05d-dda40e32493f
Commits

Reviewing files that changed from the base of the PR and between f8b3dae and addf849.

Files selected for processing: 19

  • KNOWLEDGE_BASE.md
  • app/Http/Controllers/Api/UserFollowersController.php
  • app/Http/Controllers/Api/UserFollowersYouKnowController.php
  • app/Http/Controllers/Api/UserFollowingController.php
  • app/Http/Controllers/Api/UserMutualsController.php
  • app/Http/Controllers/UserFollowersYouKnowController.php
  • app/Http/Controllers/UserMutualsController.php
  • app/Http/Requests/ListApiUserFollowersYouKnowRequest.php
  • app/Http/Requests/ListApiUserMutualsRequest.php
  • app/Http/Resources/UserConnectionCollection.php
  • app/Queries/BioProfilesQuery.php
  • app/Queries/FollowersYouKnowQuery.php
  • app/Queries/UserConnectionsQuery.php
  • routes/api.php
  • tests/Feature/Controllers/Api/UserFollowersControllerTest.php
  • tests/Feature/Controllers/Api/UserFollowersYouKnowControllerTest.php
  • tests/Feature/Controllers/Api/UserFollowingControllerTest.php
  • tests/Feature/Controllers/Api/UserMutualsControllerTest.php
  • tests/Unit/Queries/BioProfilesQueryTest.php

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@WendellAdriel
WendellAdriel marked this pull request as ready for review November 11, 2026 21:00
@WendellAdriel
WendellAdriel marked this pull request as draft November 11, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant