Skip to content

feat(channels): gateway pairing password, history on demand, pictures, and fixes - #530

Merged
setkyar merged 10 commits into
mainfrom
feat/gateway-pairing-input
Dec 3, 2026
Merged

setkyar merged 10 commits into
mainfrom
feat/gateway-pairing-input

Conversation

@setkyar

@setkyar setkyar commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What

Work that a second gateway channel needed, plus bugs it exposed in shared code.

Gateway protocol and pairing

  • Pairing can ask for a password (state password, POST .../pairings/:id/input). The value is forwarded once and never logged, stored or echoed.
  • A channel can have a gateway-only tile beside a built-in adapter (a "Telegram" account tile beside "Telegram Bot"). Without that gateway the tile does not exist.
  • "Load older messages" works for gateway threads (POST /conversations/:id/history), with channel-neutral wording.
  • Profile pictures for gateway contacts and for channel groups, fetched by the existing avatar worker and sniffed before storage.
  • An account importing history shows a notice (history_sync provider status).

Fixes in shared code

  • A re-reported message kept losing the operator who sent it.
  • A report without a name erased a stored group or person name.
  • Only a direct conversation has a counterpart; a group borrowed a member's handle and picture.
  • A customer row lost the picture the person has on a channel.
  • Replies on channel messages showed their quote as unavailable.
  • "Load older messages" failed when the last loaded page was empty.
  • The pairing dialog nested one notice inside another.

Migration

119_add_conversation_avatars: two nullable columns on each tenant's conversations. Additive, with a short lock timeout.

Testing

  • bun run lint, bun run typecheck, bun run check:unused, bun run build, API, web and database unit suites
  • channel-gateway.integration.test.ts: 21 tests against a real database and a fake gateway
  • Checked on screen against a mock gateway and a locally linked account

…nnel

A network may finish a sign-in only after the account's owner proves they
know a second secret (a two-step verification password). A gateway reports
that as pairing state `password`; the operator types it and the application
passes it on once with `POST .../pairings/:id/input`. It is not logged,
stored or echoed, and the client clears the field as it sends.

The catalog can now hold a gateway-only entry for a channel that already
has a built-in adapter, so a deployment that runs a Telegram gateway shows
a "Telegram" account tile beside "Telegram Bot". Without that gateway the
tile does not exist.

Also fixes the pairing dialog nesting one notice inside another, which hid
the history notice unless the single-session one was shown too.
An account whose provider status is history_sync shows a notice in the app
and a line on its connection card until the import ends. The accounts list
is re-read while one is importing, and shortly after a pairing completes,
because an import starts and ends on the channel's side.
When a provider reported a message the inbox already held (an echo, or
history imported again), the update cleared sent_by_user_id, and the
operator's reply was shown as sent from the phone.
The avatar worker now asks a channel gateway for a person's picture, the
way it asks the Bot API for a Telegram bot's contacts. The bytes are
sniffed and only JPEG, PNG or WebP are kept.

Also: only a direct conversation has a counterpart. A group took the
handle and picture of whichever member sorted first.
A channel thread shows its counterpart's picture until the person becomes
a customer row, which only ever carried a picture set by a WhatsApp
worker. The inbox list and the customer profile now fall back to the
picture on the person's direct channel conversation.
The existing "load older messages" control now works for a thread on a
channel gateway: the application asks the gateway for the page before the
oldest message it holds, and the gateway delivers it as history. The
control's wording no longer mentions a phone for these threads.
A thread whose length is an exact multiple of the page size ends with an
empty page, and the anchor for older history was read from that page, so
the request failed with "No local message is available as a history
anchor".
The quote lookup was scoped to a WhatsApp connection, which a channel
message does not have, so every reply showed its quote as unavailable. It
is now also looked up within the message's channel account.
A channel conversation can carry a picture of its own (migration 119), so a
group stops showing a generic icon. The avatar worker asks the gateway for
it the way it asks for a person's. A fetch that fails for a passing reason
is tried again in ten minutes instead of a day.
A provider report that named a group or a person only by ID erased the
name already stored, so a group fell back to a member's name and a sender
to their number. Absent names now leave what is known in place.

Sender pictures in a channel group come from the sender's endpoint.
@setkyar setkyar changed the title feat(channels): password step in gateway pairing, second tile per channel feat(channels): gateway pairing password, history on demand, pictures, and fixes Dec 3, 2026
@setkyar
setkyar merged commit e34ab31 into main Dec 3, 2026
9 checks passed
@setkyar
setkyar deleted the feat/gateway-pairing-input branch December 3, 2026 06:59
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