[MM-16170] Migrate Team.GetTeamsByUserId to Sync by default (#11100)

* [MM-16170] Migrate Team.GetTeamsByUserId to Sync by default

* Fixing comments
Этот коммит содержится в:
Mounica Paladugu
2019-07-09 09:21:18 -07:00
коммит произвёл Joram Wilander
родитель 0ec609d159
Коммит ff89b2c8e1
9 изменённых файлов: 36 добавлений и 38 удалений

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

@@ -192,13 +192,12 @@ func (a *App) FindTeamIdForFilename(post *model.Post, filename string) string {
name, _ := url.QueryUnescape(split[4])
// This post is in a direct channel so we need to figure out what team the files are stored under.
result := <-a.Srv.Store.Team().GetTeamsByUserId(post.UserId)
if result.Err != nil {
mlog.Error(fmt.Sprintf("Unable to get teams when migrating post to use FileInfo, err=%v", result.Err), mlog.String("post_id", post.Id))
teams, err := a.Srv.Store.Team().GetTeamsByUserId(post.UserId)
if err != nil {
mlog.Error(fmt.Sprintf("Unable to get teams when migrating post to use FileInfo, err=%v", err), mlog.String("post_id", post.Id))
return ""
}
teams := result.Data.([]*model.Team)
if len(teams) == 1 {
// The user has only one team so the post must've been sent from it
return teams[0].Id

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

@@ -22,13 +22,12 @@ func (a *App) sendNotificationEmail(notification *postNotification, user *model.
post := notification.post
if channel.IsGroupOrDirect() {
result := <-a.Srv.Store.Team().GetTeamsByUserId(user.Id)
if result.Err != nil {
return result.Err
teams, err := a.Srv.Store.Team().GetTeamsByUserId(user.Id)
if err != nil {
return err
}
// if the recipient isn't in the current user's team, just pick one
teams := result.Data.([]*model.Team)
found := false
for i := range teams {

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

@@ -654,11 +654,7 @@ func (a *App) SearchPrivateTeams(term string) ([]*model.Team, *model.AppError) {
}
func (a *App) GetTeamsForUser(userId string) ([]*model.Team, *model.AppError) {
result := <-a.Srv.Store.Team().GetTeamsByUserId(userId)
if result.Err != nil {
return nil, result.Err
}
return result.Data.([]*model.Team), nil
return a.Srv.Store.Team().GetTeamsByUserId(userId)
}
func (a *App) GetTeamMember(teamId, userId string) (*model.TeamMember, *model.AppError) {

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

@@ -189,13 +189,13 @@ func (a *App) IsFirstUserAccount() bool {
// indexUser fetches the required information to index a user from the database and
// calls the elasticsearch interface method
func (a *App) indexUser(user *model.User) *model.AppError {
userTeams := <-a.Srv.Store.Team().GetTeamsByUserId(user.Id)
if userTeams.Err != nil {
return userTeams.Err
userTeams, err := a.Srv.Store.Team().GetTeamsByUserId(user.Id)
if err != nil {
return err
}
userTeamsIds := []string{}
for _, team := range userTeams.Data.([]*model.Team) {
for _, team := range userTeams {
userTeamsIds = append(userTeamsIds, team.Id)
}