fix(channel): detect @all in rich-text post messages (fixes #138) - #152
Open
Xuxchloris wants to merge 1 commit into
Open
fix(channel): detect @all in rich-text post messages (fixes #138)#152Xuxchloris wants to merge 1 commit into
Xuxchloris wants to merge 1 commit into
Conversation
|
|
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.
Fixes #138
Problem
For post (rich-text) messages that mention everyone,
InboundMessage.mentioned_allis alwaysFalse, soPolicyGatenever emitspolicy_mention_all_blockedand a bot configured withrespond_to_mention_all=Falsestill responds to broadcast@allposts. Plain-text@allmessages are handled correctly.Two compounding issues in the post inbound path:
mentions[]for post@all— the signal lives in the post AST as anatnode withuser_id == "all"._flatten_post_textrendered that node to the literal@<user_name>(@Everyone), which neithertext_has_mention_all(looks for the@_allplaceholder) norparse_at_tags(looks for<at>tags) can match._flatten_post_textonly handled locale-keyed post payloads ({"zh_cn": ...}); the classic single-locale shape{"content": ...}(the one used in the issue reproduction) returned an empty text, so the probe never even ran.Changes
lark_oapi/channel/normalize/registry.py_flatten_post_textnow accepts both wire shapes: locale-keyed posts and the direct{"content": ...}shape.atnode whoseuser_id == "all"(top-level or insideid) renders as the@_allplaceholder, so the pipeline'stext_has_mention_allprobe fires andresolve_mentionsrewrites it to the human-visible@all.lark_oapi/channel/tests/test_post_mention_all.py(new): pipeline-level tests for both post shapes (@all→mentioned_all=True, rendered@all; a regular@<user>mention →mentioned_all=False, name rendered).Verification
python -m pytest lark_oapi/channel/tests— 662 passed; the single failure (test_upload_error_propagation.py::test_gather_buffer_missing_local_file_raises_upload_failed) is a pre-existing Windows-only path-escaping assertion unrelated to this change (CI runs on Linux).