From 370321a82397c7253d72a3d4eb4f9b05e19fc0a8 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Mon, 2 Aug 2021 14:23:10 -0400 Subject: [PATCH] MM-36127 Check for emojis in message attachment titles (#17943) --- app/post_metadata.go | 4 ++++ app/post_metadata_test.go | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/post_metadata.go b/app/post_metadata.go index f2e8f215d7..44412919b7 100644 --- a/app/post_metadata.go +++ b/app/post_metadata.go @@ -270,6 +270,10 @@ func getEmojiNamesForPost(post *model.Post, reactions []*model.Reaction) []strin // Post attachments for _, attachment := range post.Attachments() { + if attachment.Title != "" { + names = append(names, getEmojiNamesForString(attachment.Title)...) + } + if attachment.Text != "" { names = append(names, getEmojiNamesForString(attachment.Text)...) } diff --git a/app/post_metadata_test.go b/app/post_metadata_test.go index f80faf9d00..8b78470593 100644 --- a/app/post_metadata_test.go +++ b/app/post_metadata_test.go @@ -1130,10 +1130,13 @@ func TestGetEmojiNamesForPost(t *testing.T) { }, }, }, + { + Title: "This is the title: :emoji5:", + }, }, }, }, - Expected: []string{"emoji1", "emoji2", "emoji3", "emoji4"}, + Expected: []string{"emoji1", "emoji2", "emoji3", "emoji4", "emoji5"}, }, { Description: "with duplicates",