Skip to content

feat: suggest who to follow from the API - #990

Open
Taldres wants to merge 2 commits into
dev-null-sh:productionfrom
Taldres:feat/who-to-follow-api
Open

Taldres wants to merge 2 commits into
dev-null-sh:productionfrom
Taldres:feat/who-to-follow-api

Conversation

@Taldres

@Taldres Taldres commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Lets the mobile app show who to follow as the web does. It follows #130 and is for the app's roadmap item, NativePHP/dev-null-app#72.

The web gets its suggestions as the suggestedUsers Inertia prop and dismisses them through POST /@{user}/dismiss, neither of which a signed request can reach. Both endpoints reuse what the web runs: SuggestedUsersQuery and CreateSuggestionDismissal.

Endpoints

GET /api/v1/me/suggested-users answers with the people the web would suggest, as UserResources: three to show and three spares to fill the place of one dismissed, as the web asks for them. Each one has followers_count, followed_by_following_count (new on UserResource, only set here) and follows_you for the reason line and the follow-back, and is_followed: false, as other lists of people say it. ?round=N is the next page of the day's picks, as the web's refresh button moves through them with its who_to_follow_round cookie. A missing or empty round is the first.

?username= or ?commit_id= asks for the suggestions as the web shows them beside that profile or commit since #1021: the people the profile follows, or the thread's other participants, come first, and the regular suggestions fill the rest. The commit has to be one the user can see, as its page requires, otherwise the answer is 422 with "That commit is no longer available." An unknown username is 422 too, and so is passing both. Across a block, a profile is ignored and the suggestions are the regular ones, as on the web. Without either, nothing changes.

{"data": [{"id": "…", "username": "octocat", "name": "The Octocat", "lane": 3, "followers_count": 12, "followed_by_following_count": 2, "follows_you": false, "is_followed": false, "…": "…"}]}

POST /api/v1/users/{username}/dismiss marks someone Not interested and answers 204. As on the web, they are never suggested again, nothing else changes, and dismissing yourself is 403.

Muted people, anyone across a block, and dismissed people are left out, as the query already does for the web.

Testing

Pint, Rector, PHPStan, type coverage at 100%, and all 4,149 tests pass locally (without the coverage driver, so line coverage is CI's to confirm). The new tests cover both halves of the mix, rounds, dismissals, mutes and blocks, the profile and commit context, commits the user can't see, validation, and unsigned requests, and that the endpoint answers what the web does for the same profile or commit page.

The app side is NativePHP/dev-null-app#74. It ran against this branch on an iOS simulator: following, dismissing with the spares moving up, and the next round. The app only shows who to follow in the Log, as the web does on smaller screens, so it doesn't pass a context.

@Taldres
Taldres force-pushed the feat/who-to-follow-api branch from f06d54c to 6dd6f0c Compare October 22, 2026 20:26
Taldres added a commit to Taldres/dev-null-app that referenced this pull request Oct 23, 2026
Three people you might want to follow sit under the fifth commit, each
with why they're suggested, Follow and Not interested. Devnull sends
three spares, so one dismissed gives their place to the next, and the
round is asked again to top the spares up. The refresh moves to the next
page of the day's picks. Don't show again hides it with an Undo, and a
switch in settings brings it back.

Needs GET /api/v1/me/suggested-users and POST /api/v1/users/{username}/dismiss
from dev-null-sh/dev-null.sh#990.
@Taldres
Taldres force-pushed the feat/who-to-follow-api branch from 6dd6f0c to 7b64f62 Compare October 23, 2026 12:32
@simonhamp

Copy link
Copy Markdown
Contributor

@xHeaven @nunomaduro can we get this into the API so we can show "Who to follow?"

@xHeaven

xHeaven commented Oct 23, 2026

Copy link
Copy Markdown
Member

@xHeaven @nunomaduro can we get this into the API so we can show "Who to follow?"

The "Who to follow" algo changed a bit in #1021, can you guys check if this PR needs to be adjusted?

@Taldres

Taldres commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Yep. I'll check it later

The mobile app can show who to follow as the web does: the same three
people and three spares, a new page of the day's picks each round, with
why each one is suggested and whether they follow you. Not interested
keeps someone out of the suggestions for good, as on the web.
@Taldres
Taldres force-pushed the feat/who-to-follow-api branch from 7b64f62 to 43fee92 Compare October 24, 2026 05:24
Taldres added a commit to Taldres/dev-null-app that referenced this pull request Oct 24, 2026
Three people you might want to follow sit under the fifth commit, each
with why they're suggested, Follow and Not interested. Devnull sends
three spares, so one dismissed gives their place to the next, and the
round is asked again to top the spares up. The refresh moves to the next
page of the day's picks. Don't show again hides it with an Undo, and a
switch in settings brings it back.

Needs GET /api/v1/me/suggested-users and POST /api/v1/users/{username}/dismiss
from dev-null-sh/dev-null.sh#990.
Takes the context the web passes since dev-null-sh#1021: `username` for a profile, `commit_id` for a commit the user can see, as its page requires. Without either, the suggestions stay as they were.
@Taldres

Taldres commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

@xHeaven @nunomaduro can we get this into the API so we can show "Who to follow?"

The "Who to follow" algo changed a bit in #1021, can you guys check if this PR needs to be adjusted?

@xHeaven Thanks for the hint! I updated the branch for #1021.

GET /api/v1/me/suggested-users now accepts the same context as the web:

  • ?username= for a profile page
  • ?commit_id= for a commit page (only commits the user is allowed to see)

Without these parameters, nothing changes. A test checks that the API returns the same suggestions as the web for the same page.

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.

3 participants