Repository navigation
Fix webhook filters: evaluate on a built Telethon event and resolve filters.chats - #44
Merged
Merged
Conversation
…ents.py No behaviour change. The webhook pusher needs the same translation for its filters, so the builder tables and build_event() move out of the Gateway class into a module both can use. The table also gains the v2 bus types, which is what the webhook is keyed by.
…rs.chats Both halves of [webhook.filters] were dead: - filters.chats was compared against _resolved_chat_ids, which nothing ever filled (set_resolved_chats had no caller), so configuring it dropped every event that had a chat. Numeric refs are now read at start, and '@name' refs are resolved through the event's account, retried once a minute on failure. - The other keys were evaluated against the raw TL update the bus carries, while every filter reads a high-level Telethon event, so they raised (the bus logged 'event handler failed') or never matched. The pusher now builds the event with gateway/tlevents.py, keyed by bus type, in both directions. A type Telethon does not model is held back while filters are set, logged once per type. The daemon hands the pusher its get_client lookup for both. A self-origin event still skips the filter keys, as before: it has no raw update.
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.
Stacked on #43 (
fix/daemon-jobs). Merge that one first; GitHub then retargets this PR tomain.Both halves of
[webhook.filters]were dead.What was wrong
filters.chatsdropped everything.should_pushcompared each event'schat_idagainst_resolved_chat_ids, butset_resolved_chatshad no caller, so the set was always empty. Configuring anychatslist dropped every event that had a chat.[webhook.filters]keys such aschat_typeandcontainswere evaluated against the raw TL update the bus carries. Every filter reads a high-level Telethon event (event.chat_id,is_private,message.sender_id), so they raised (the bus logged "event handler failed") or never matched. This is the same shape bug Fix gateway jobs: deliver incoming updates, build Telethon events, resolve @chat refs, start jobs at boot #43 fixed for gateway jobs.Changes
gateway/tlevents.py(new, no behaviour change): the builder tables andbuild_event()move out of theGatewayclass so both consumers share them. The module adds a table keyed by bus event type:message_new,message_edited,message_deleted,message_service,member_*,read_inbox/read_outbox(with the matchinginbox=) anduser_status.daemon/webhook.py:chatsare read at start.@nameentries are resolved through the event's account and retried at most once a minute if that fails, logged once.is_incomingnarrows that if needed.daemon/app.py: the pusher getsDaemon.get_clientto look up an account's client and resolver.webhook.example.tomland the CHANGELOG note the filter keys.Tests
tests/test_webhook_filters.py:chat_type,contains, both directions andis_incoming, a type with no builder (logged once), self-origin, an offline account,@nameresolution (resolved once), numeric chats without an account, and retry after a failed resolve. All use real TL updates.tests/test_webhook.py: an end-to-end test from a Telethon update fed through the account's client, via the bus and filters, to a POST to a local receiver. It fails on the old code.make lint typecheck test docs parity: all pass, 13335 tests.