A platform for community discussion. Free, open, simple.
FIX: correctly follow enable_emoji_shortcuts in chat (#33297)
Joffrey JAFFEUXe241de51cd3d
diff --git a/plugins/chat/app/models/chat/message.rb b/plugins/chat/app/models/chat/message.rbindex 3cfaf92586d..c64d86307c4 100644--- a/plugins/chat/app/models/chat/message.rb+++ b/plugins/chat/app/models/chat/message.rb@@ -214,7 +214,6 @@ module Chatchat-transcriptdiscourse-local-datesemoji- emojiShortcutsinlineEmojihtml-imghashtag-autocomplete@@ -253,6 +252,7 @@ module Chatfeatures = MARKDOWN_FEATURES.dupfeatures << "image-grid" if bot+ features << "emojiShortcuts" if SiteSetting.enable_emoji_shortcutsrules = MARKDOWN_IT_RULES.duprules << "heading" if botdiff --git a/plugins/chat/spec/models/chat/message_spec.rb b/plugins/chat/spec/models/chat/message_spec.rbindex c3d5ab7dbd1..319e7c5972d 100644--- a/plugins/chat/spec/models/chat/message_spec.rb+++ b/plugins/chat/spec/models/chat/message_spec.rb@@ -198,6 +198,34 @@ describe Chat::Message doenddescribe ".cook" do+ context "with enable_emoji_shortcuts site setting" do+ context "when enabled" do+ before { SiteSetting.enable_emoji_shortcuts = true }++ it "converts emoji shortcuts to emoji" do+ cooked = described_class.cook <<~MD+ emoji shortcut :)+ MD++ expected =+ "<p>emoji shortcut <img src=\"/images/emoji/twitter/slight_smile.png?v=#{Emoji::EMOJI_VERSION}\" title=\":slight_smile:\" class=\"emoji\" alt=\":slight_smile:\" loading=\"lazy\" width=\"20\" height=\"20\"></p>"+ expect(cooked).to match(expected)+ end+ end++ context "when disabled" do+ before { SiteSetting.enable_emoji_shortcuts = false }++ it "does not convert emoji shortcuts" do+ cooked = described_class.cook <<~MD+ emoji shortcut :)+ MD++ expect(cooked).to match("<p>emoji shortcut :)</p>")+ end+ end+ end+it "does not support HTML tags" docooked = described_class.cook("<h1>test</h1>")