PLT-4457 Added API to get multiple users by their usernames (#6218)

* Allow getting profiles by username without a team

* Changed UserStore.GetProfilesByUsernames to return an array

* PLT-4457 Added API to get multiple users by their usernames

* Changed users/names route to users/usernames
This commit is contained in:
Harrison Healey
2017-04-25 11:00:41 -04:00
committed by Corey Hulen
parent cb668b9283
commit db68e598a1
7 changed files with 146 additions and 56 deletions

View File

@@ -95,7 +95,7 @@ func SendNotifications(post *model.Post, team *model.Team, channel *model.Channe
if len(potentialOtherMentions) > 0 {
if result := <-Srv.Store.User().GetProfilesByUsernames(potentialOtherMentions, team.Id); result.Err == nil {
outOfChannelMentions := result.Data.(map[string]*model.User)
outOfChannelMentions := result.Data.([]*model.User)
go sendOutOfChannelMentions(sender, post, team.Id, outOfChannelMentions)
}
}
@@ -592,13 +592,13 @@ func getMobileAppSessions(userId string) ([]*model.Session, *model.AppError) {
}
}
func sendOutOfChannelMentions(sender *model.User, post *model.Post, teamId string, profiles map[string]*model.User) *model.AppError {
if len(profiles) == 0 {
func sendOutOfChannelMentions(sender *model.User, post *model.Post, teamId string, users []*model.User) *model.AppError {
if len(users) == 0 {
return nil
}
var usernames []string
for _, user := range profiles {
for _, user := range users {
usernames = append(usernames, user.Username)
}
sort.Strings(usernames)