Repository navigation
feat(channels): gateway pairing password, history on demand, pictures, and fixes - #530
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Work that a second gateway channel needed, plus bugs it exposed in shared code.
Gateway protocol and pairing
password,POST .../pairings/:id/input). The value is forwarded once and never logged, stored or echoed.POST /conversations/:id/history), with channel-neutral wording.history_syncprovider status).Fixes in shared code
Migration
119_add_conversation_avatars: two nullable columns on each tenant'sconversations. 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 suiteschannel-gateway.integration.test.ts: 21 tests against a real database and a fake gateway