Skip to content

feat: list and open conversations in Remotes from the API - #654

Merged
xHeaven merged 7 commits into
dev-null-sh:productionfrom
simonhamp:feat/api-remotes-conversations
Oct 22, 2026
Merged

xHeaven merged 7 commits into
dev-null-sh:productionfrom
simonhamp:feat/api-remotes-conversations

Conversation

@simonhamp

Copy link
Copy Markdown
Contributor

Lets the mobile app read Remotes: the inbox, a thread with a person or an org, and marking a thread pulled. It's one of a few small PRs that bring Remotes to the app (NativePHP/dev-null-app) on top of the signed API from #130. Sending messages, reactions, stashing, requests, typing and the settings each have their own PR.

The endpoints use the web's queries (ConversationsQuery, ConversationThreadQuery) and actions, and copy the web's form requests, so the rules are the same: 404 while the user has Remotes off, for someone across a block, for themselves, and for an org they aren't in. They also go through the web's conversations limiter (300 a minute) on top of the API's 120.

Endpoints

All signed, except the image URL, which is signed in its own way (see below).

Request Answer
GET /api/v1/remotes?tab=&q=&before= One page of the inbox (30), newest first, plus has_more, unread_count and requests_count
GET /api/v1/remotes/@{username}/messages?after=&before=&reactions_after= The thread with that person, in data
GET /api/v1/remotes/orgs/{id}/messages?after=&before=&reactions_after= The org's thread, in data
PUT /api/v1/remotes/@{username}/read with through 204
PUT /api/v1/remotes/orgs/{id}/read with through 204
GET /api/v1/remotes/messages/{id}/link-preview {"link_preview": …}, for a card that was still pending
GET /api/v1/remotes/images/{id}?expires=&user=&signature= The image, with the web's headers

tab is open (the default), stashed, or fetched while remotes.requests is on. q matches a name or handle, and before is a conversation id.

A conversation in the inbox has id, kind, name, partner (a user, or null for an org), members (for an org), last_message, last_message_at, ahead, partner_read_through_id, partner_read_at and is_archived, the same fields the web gets.

A thread has the same fields as the web's poll: messages, has_older, reactions_version, reaction_changes, read_through_id and access. A one-to-one thread adds partner, partner_read_through_id, partner_read_at and partner_typing. An org adds org (id, name), members (with role and read_through_id), typing (usernames) and role. Someone the user hasn't talked to yet gets an empty thread whose access says whether a first message can go to them.

A message has id, user_id, client_id, body, body_segments, mentions, reply_to_id, reply_to (id, user_id, body, images_count), link_preview, images, reactions, event, subject_id and created_at, plus user and subject in orgs. Users are UserResources, so they come with lane like everywhere else in the API.

Things to look at

  • Image URLs. The web's /remotes/images/{id} needs a session, and the app's image views can't sign a request. So each image in a thread comes with a URL signed for the user. It expires at midnight UTC the day after tomorrow, which keeps it the same all day and lets the app cache the image. The endpoint checks that the user in the URL can still see the message, so someone removed from an org loses the image straight away. The signature is relative (signed:relative), so a proxy that changes the scheme or host doesn't break it. The route skips the API's per-IP guest limit, because a thread full of images would hit it. The web's route has no limit either.
  • Mentions. On the web a message's mentions is a map of username to id. Here it's the same {username, offset, length} positions that commits use, filtered to the people the message actually links, so the app can reuse its commit renderer.
  • Reading has no side effects. The web's /remotes/@x page marks the thread read when it renders. Here the app calls PUT …/read itself, the way the web's JSON poll works.
  • Timestamps. last_message_at and partner_read_at come straight from the queries, in their toJSON() format. Messages use toIso8601ZuluString() like the rest of the API. Happy to normalise them if you'd rather.
  • The arrays from the queries are typed with an inline @var in the resources, since a JsonResource can't type its resource.

Testing

Everything CI runs passes on this branch locally: Pint, Rector, the JS lint, PHPStan, tsc, type coverage, the JS unit tests, and all 3,279 PHP tests at 100% coverage.

@simonhamp
simonhamp marked this pull request as ready for review October 19, 2026 23:44
@xHeaven
xHeaven merged commit b15531b into dev-null-sh:production Oct 22, 2026
5 checks passed
@simonhamp
simonhamp deleted the feat/api-remotes-conversations branch October 22, 2026 04:43
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.

2 participants