Skip to content

Bridge message pins in both directions - #1101

Open
VeRychard wants to merge 1 commit into
mautrix:mainfrom
VeRychard:pins-bridge
Open

VeRychard wants to merge 1 commit into
mautrix:mainfrom
VeRychard:pins-bridge

Conversation

@VeRychard

Copy link
Copy Markdown

Implements pin bridging on top of the new bridgev2 pin infrastructure (mautrix/go#573 — depends on that merging + a mautrix-go release, CI will be red until then; the last commit of this branch was NOT pushed intentionally, it only redirects the local build to a go checkout).

Outbound (Matrix → Telegram): HandleMatrixPinnedEvents converts the diff into per-message messages.updatePinnedMessage calls:

  • unpins first, then pins — so a replacement pin never transiently exceeds Telegram's pin limit
  • new pins are sent in reverse order so Telegram's newest-on-top matches Matrix's newest-first m.room.pinned_events ordering
  • space portals are rejected

Inbound (Telegram → Matrix): onPinnedMessages handles both UpdatePinnedMessages and UpdatePinnedChannelMessages and queues them as deltas against the current pinned list. Telegram expresses "unpinned all messages" as an unpin with an empty message list: that event carries no delta fields, so bridgev2 treats it as a full-list replacement with an empty list and clears the Matrix pins.

Capabilities: PinnedMessages: true + m.room.pinned_events at CapLevelFullySupported, baseID bumped to fi.mau.telegram.capabilities.2026_09_20.

Live-verified 2026-09-20 on a self-hosted homeserver: Matrix→Telegram pin, Telegram→Matrix pin, and Telegram's "unpin all" all bridge correctly (previously inbound pins log Unhandled update type *_tg.UpdatePinnedMessages_ and are dropped).

Matrix -> Telegram: implement PinHandlingNetworkAPI and call
messages.updatePinnedMessage for each added and removed message. Unpins are
sent first, and new pins are sent oldest first so the resulting order in
Telegram matches the Matrix pinned list.

Telegram -> Matrix: handle updatePinnedMessages and updatePinnedChannelMessages
(previously logged as "Unhandled update type") and queue them as a pin delta.
updatePinnedDialogs stays as it was; that is chat list pinning, not message
pinning.

Also advertise the capability in GetCapabilities.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant