Fixing system messages about non-visible users (#14254)

* Fixing system messages about non-visible users

* Adding unit tests to verify the new behavior

* Regenerating app layers

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Jesús Espino
2020-04-28 12:58:34 +02:00
коммит произвёл GitHub
родитель 224b72c61e
Коммит 8781c36eb3
4 изменённых файлов: 63 добавлений и 1 удалений

Просмотреть файл

@@ -162,7 +162,16 @@ func TestFilterOutOfChannelMentions(t *testing.T) {
user1 := th.BasicUser
user2 := th.BasicUser2
user3 := th.CreateUser()
guest := th.CreateGuest()
user4 := th.CreateUser()
guestAndUser4Channel := th.CreateChannel(th.BasicTeam)
defer th.App.PermanentDeleteUser(guest)
th.LinkUserToTeam(user3, th.BasicTeam)
th.LinkUserToTeam(user4, th.BasicTeam)
th.LinkUserToTeam(guest, th.BasicTeam)
th.App.AddUserToChannel(guest, channel)
th.App.AddUserToChannel(user4, guestAndUser4Channel)
th.App.AddUserToChannel(guest, guestAndUser4Channel)
t.Run("should return users not in the channel", func(t *testing.T) {
post := &model.Post{}
@@ -177,6 +186,18 @@ func TestFilterOutOfChannelMentions(t *testing.T) {
assert.Nil(t, outOfGroupUsers)
})
t.Run("should return only visible users not in the channel (for guests)", func(t *testing.T) {
post := &model.Post{}
potentialMentions := []string{user2.Username, user3.Username, user4.Username}
outOfChannelUsers, outOfGroupUsers, err := th.App.filterOutOfChannelMentions(guest, post, channel, potentialMentions)
require.Nil(t, err)
require.Len(t, outOfChannelUsers, 1)
assert.Equal(t, user4.Id, outOfChannelUsers[0].Id)
assert.Nil(t, outOfGroupUsers)
})
t.Run("should not return results for a system message", func(t *testing.T) {
post := &model.Post{
Type: model.POST_ADD_REMOVE,