MM-59854 Fully allow at mentions in message attachment field values and add E2E tests (#28018)
* Add descriptions to test cases for getNeededAtMentionedUsernames * MM-59854 Load users who are at-mentioned in message attachment fields * MM-59854 Add server support for at-mentioning users in message attachment fields * Migrate support/external_commands from JS to TS * MM-59584 Ensure that at-mentions never show in other message attachment fields * MM-59584 Add E2E tests for how we load users based on at mentions * Use new E2E test helpers in other places * Update snapshots
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3e84d20dbe
Коммит
46cad5c552
@@ -1410,6 +1410,12 @@ func getMentionsEnabledFields(post *model.Post) model.StringArray {
|
||||
if attachment.Text != "" {
|
||||
ret = append(ret, attachment.Text)
|
||||
}
|
||||
|
||||
for _, field := range attachment.Fields {
|
||||
if valueString, ok := field.Value.(string); ok && valueString != "" {
|
||||
ret = append(ret, valueString)
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -1337,6 +1337,25 @@ func TestGetExplicitMentions(t *testing.T) {
|
||||
HereMentioned: true,
|
||||
},
|
||||
},
|
||||
"should include the mentions from attachment field values (but not field titles)": {
|
||||
Message: "this is a message",
|
||||
Attachments: []*model.SlackAttachment{
|
||||
{
|
||||
Fields: []*model.SlackAttachmentField{
|
||||
{
|
||||
Title: "@user1",
|
||||
Value: "@user2",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Keywords: map[string][]string{"@user1": {id1}, "@user2": {id2}},
|
||||
Expected: &MentionResults{
|
||||
Mentions: map[string]MentionType{
|
||||
id2: KeywordMention,
|
||||
},
|
||||
},
|
||||
},
|
||||
"Name on keywords is a prefix of a mention": {
|
||||
Message: "@other @test-two",
|
||||
Keywords: map[string][]string{"@test": {model.NewId()}},
|
||||
@@ -2167,6 +2186,12 @@ func TestGetMentionsEnabledFields(t *testing.T) {
|
||||
|
||||
attachmentWithOutPreText := model.SlackAttachment{
|
||||
Text: "some text",
|
||||
Fields: []*model.SlackAttachmentField{
|
||||
{
|
||||
Title: "field title",
|
||||
Value: "field value",
|
||||
},
|
||||
},
|
||||
}
|
||||
attachments := []*model.SlackAttachment{
|
||||
&attachmentWithTextAndPreText,
|
||||
@@ -2183,11 +2208,12 @@ func TestGetMentionsEnabledFields(t *testing.T) {
|
||||
"This is the message",
|
||||
"@Channel some comment for the channel",
|
||||
"@here with mentions",
|
||||
"some text"}
|
||||
"some text",
|
||||
"field value",
|
||||
}
|
||||
|
||||
mentionEnabledFields := getMentionsEnabledFields(post)
|
||||
|
||||
assert.EqualValues(t, 4, len(mentionEnabledFields))
|
||||
assert.EqualValues(t, expectedFields, mentionEnabledFields)
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user