FIX: user got notified about a mention inside a chat message quote (#24229)

When quoting a chat message in a post, if that message contains a mention, 
that mention should be ignored. But we've been detecting them and sending 
notifications to users. This PR fixes the problem. Since this fix is for 
the chat plugin, I had to introduce a new API for plugins:

    # We strip posts before detecting mentions, oneboxes, attachments etc. 
    # We strip those elements that shouldn't be detected. For example, 
    # a mention inside a quote should be ignored, so we strip it off. 
    # Using this API plugins can register their own post strippers. 
    def register_post_stripper(&block) 
    end
This commit is contained in:
Andrei Prigorshnev
2023-11-08 23:13:25 +04:00
committed by GitHub
parent 179abfca1a
commit be2eb3df44
6 changed files with 99 additions and 5 deletions

View File

@ -493,6 +493,10 @@ after_initialize do
register_hashtag_type_priority_for_context("tag", "chat-composer", 50)
register_hashtag_type_priority_for_context("channel", "topic-composer", 10)
register_post_stripper do |nokogiri_fragment|
nokogiri_fragment.css(".chat-transcript .mention").remove
end
Site.markdown_additional_options["chat"] = {
limited_pretty_text_features: Chat::Message::MARKDOWN_FEATURES,
limited_pretty_text_markdown_rules: Chat::Message::MARKDOWN_IT_RULES,