MM-42282: handle teamId parameter correctly (#19685)

As per https://community-daily.mattermost.com/core/pl/ugs7ue6e4j8a7cgegk1bxje8to, `ThreadStore.GetThreadsForUser` accepts a `teamId` parameter, but incorrectly handles an empty value of `""` as looking only for channels with an empty `teamId` (aka DMs and GMs) instead of finding all channels and effectively ignoring the team property.

Fixes: https://mattermost.atlassian.net/browse/MM-42282
Этот коммит содержится в:
Jesse Hallam
2022-03-11 10:57:42 -04:00
коммит произвёл GitHub
родитель 72c6b8fe48
Коммит b5e78a0ce1
2 изменённых файлов: 163 добавлений и 1 удалений

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

@@ -67,7 +67,16 @@ func (s *SqlThreadStore) GetThreadsForUser(userId, teamId string, opts model.Get
fetchConditions := sq.And{
sq.Eq{"ThreadMemberships.UserId": userId},
sq.Eq{"ThreadMemberships.Following": true},
sq.Or{sq.Eq{"Channels.TeamId": teamId}, sq.Eq{"Channels.TeamId": ""}},
}
if teamId != "" {
fetchConditions = sq.And{
fetchConditions,
sq.Or{
sq.Eq{"Channels.TeamId": teamId},
sq.Eq{"Channels.TeamId": ""},
},
}
}
if !opts.Deleted {
fetchConditions = sq.And{