Fix Mattermost @mention detection in group channels#793
Open
anathn wants to merge 1 commit intoRightNow-AI:mainfrom
Open
Fix Mattermost @mention detection in group channels#793anathn wants to merge 1 commit intoRightNow-AI:mainfrom
anathn wants to merge 1 commit intoRightNow-AI:mainfrom
Conversation
Parse the mentions JSON array from Mattermost event data and set was_mentioned metadata when the bot user ID is present, enabling agents to distinguish direct mentions from background group traffic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Member
|
Reviewed and approved. Has merge conflicts with recent changes on main. Please rebase and we will merge. |
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.
Fix Mattermost @mention detection in group channels
Background
The Mattermost channel adapter was parsing incoming WebSocket events but always returned an empty
metadatamap — meaning there was no way to know if the bot had been directly @mentioned in a group channel.Mattermost includes a
mentionsJSON array in the event payload listing the user IDs of anyone mentioned in that message. The fix reads that array and setswas_mentioned: truein the message metadata when the bot's own user ID appears in it. This only applies to group channels since DMs are always directed at the bot.Summary
mentionsJSON array from Mattermost WebSocket event datawas_mentioned: truein message metadata when the bot's user ID appears in the mentions listChanges
mentionsJSON array from Mattermost WebSocket event datawas_mentioned: truein message metadata when the bot's user ID appears in the mentions listTest plan
test_parse_mattermost_event_mention_detected— verifieswas_mentionedis set when bot ID is in mentions arraytest_parse_mattermost_event_no_mention— verifies metadata is absent when bot is not mentionedcargo test --workspacepasses (1,744+ tests; one pre-existing flaky cron timing test unrelated to this change)cargo clippy --workspace --all-targets -- -D warningszero warningscargo fmt --all --checkno diffTesting
cargo clippy --workspace --all-targets -- -D warningspassescargo test --workspacepassesSecurity
serde_json::from_str(...).unwrap_or_default()handles malformed or missingmentionsdata by defaulting to an empty vec