MM-39341: Sentry crash: nil dereference in *User.ClearNonProfileFields (#18966)

In some cases, an invalid participant id like an empty string
might creep into the database. It's not exactly clear
how can this happen, but if it does, then it breaks the logic
of assuming that the users slice will contain all users
in the participants slice.

To prevent this, we check if a match was found before
adding it in the slice.

https://community-daily.mattermost.com/boards/workspace/zyoahc9uapdn3xdptac6jb69ic/285b80a3-257d-41f6-8cf4-ed80ca9d92e5/495cdb4d-c13a-4992-8eb9-80cfee2819a4/7sixm4t7c6rsr3d8ydxbtfgy9gr

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2021-11-17 20:49:40 +05:30
коммит произвёл GitHub
родитель b7a7d8e7b6
Коммит 12dc171a60
2 изменённых файлов: 22 добавлений и 1 удалений

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

@@ -460,7 +460,9 @@ func (s *SqlThreadStore) GetThreadForUser(teamId string, threadMembership *model
break
}
}
participants = append(participants, participant)
if participant != nil {
participants = append(participants, participant)
}
}
result := &model.ThreadResponse{