FIX: convert emoji to unicode on event title (#530)

This commit is contained in:
Renato Atilio 2024-01-29 11:50:50 -03:00 committed by GitHub
parent b49e327f5c
commit dea70ab377
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -24,6 +24,10 @@ module DiscoursePostEvent
}, },
} }
if post_hash[:topic][:title].match?(/:[\w\-+]+:/)
post_hash[:topic][:title] = Emoji.gsub_emoji_to_unicode(post_hash[:topic][:title])
end
if JSON.parse(SiteSetting.map_events_to_color).size > 0 if JSON.parse(SiteSetting.map_events_to_color).size > 0
post_hash[:topic][:category_slug] = object.post.topic&.category&.slug post_hash[:topic][:category_slug] = object.post.topic&.category&.slug
post_hash[:topic][:tags] = object.post.topic.tags&.map(&:name) post_hash[:topic][:tags] = object.post.topic.tags&.map(&:name)

View File

@ -8,7 +8,7 @@ describe DiscoursePostEvent::EventSummarySerializer do
end end
fab!(:category) fab!(:category)
fab!(:topic) { Fabricate(:topic, category: category) } fab!(:topic) { Fabricate(:topic, category: category, title: "Topic title :tada:") }
fab!(:post) { Fabricate(:post, topic: topic) } fab!(:post) { Fabricate(:post, topic: topic) }
fab!(:event) { Fabricate(:event, post: post) } fab!(:event) { Fabricate(:event, post: post) }
@ -20,7 +20,7 @@ describe DiscoursePostEvent::EventSummarySerializer do
expect(summary[:timezone]).to eq(event.timezone) expect(summary[:timezone]).to eq(event.timezone)
expect(summary[:name]).to eq(event.name) expect(summary[:name]).to eq(event.name)
expect(summary[:post][:url]).to eq(post.url) expect(summary[:post][:url]).to eq(post.url)
expect(summary[:post][:topic][:title]).to eq(topic.title) expect(summary[:post][:topic][:title]).to eq("Topic title 🎉")
expect(summary[:category_id]).to eq(category.id) expect(summary[:category_id]).to eq(category.id)
end end