Migrate "User.GetProfilesByUsernames" to Sync by default (#11523)

* changed GetProfilesByUsernames signature

* modified the UserStore interface to reflect changed made to the GetProfilesByUsernames function signature

* modify usages of GetProfilesByUsernames

* fix gofmt

* fixed failing userstore tests
Этот коммит содержится в:
Phillip Ahereza
2019-07-05 22:19:40 +03:00
коммит произвёл Elias Nahum
родитель aa14c9bbdb
Коммит c34942afec
6 изменённых файлов: 53 добавлений и 48 удалений

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

@@ -141,8 +141,8 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
}
if len(m.OtherPotentialMentions) > 0 && !post.IsSystemMessage() {
if profilesResult := <-a.Srv.Store.User().GetProfilesByUsernames(m.OtherPotentialMentions, &model.ViewUsersRestrictions{Teams: []string{team.Id}}); profilesResult.Err == nil {
channelMentions := model.UserSlice(profilesResult.Data.([]*model.User)).FilterByActive(true)
if users, err := a.Srv.Store.User().GetProfilesByUsernames(m.OtherPotentialMentions, &model.ViewUsersRestrictions{Teams: []string{team.Id}}); err == nil {
channelMentions := model.UserSlice(users).FilterByActive(true)
var outOfChannelMentions model.UserSlice
var outOfGroupsMentions model.UserSlice

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

@@ -625,11 +625,11 @@ func (a *App) GetUsersByGroupChannelIds(channelIds []string, asAdmin bool) (map[
}
func (a *App) GetUsersByUsernames(usernames []string, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
result := <-a.Srv.Store.User().GetProfilesByUsernames(usernames, viewRestrictions)
if result.Err != nil {
return nil, result.Err
users, err := a.Srv.Store.User().GetProfilesByUsernames(usernames, viewRestrictions)
if err != nil {
return nil, err
}
return a.sanitizeProfiles(result.Data.([]*model.User), asAdmin), nil
return a.sanitizeProfiles(users, asAdmin), nil
}
func (a *App) sanitizeProfiles(users []*model.User, asAdmin bool) []*model.User {