Skip to content

Commit

Permalink
[MM-55213] GenericStoreResult in channels (mattermost#25234) (matterm…
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Stern authored Nov 6, 2023
1 parent b3c183c commit 2a5e04d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions server/channels/app/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,24 +368,24 @@ func (a *App) tryExecuteCustomCommand(c request.CTX, args *model.CommandArgs, tr
return nil, nil, model.NewAppError("ExecuteCommand", "api.command.disabled.app_error", nil, "", http.StatusNotImplemented)
}

chanChan := make(chan store.StoreResult, 1)
chanChan := make(chan store.GenericStoreResult[*model.Channel], 1)
go func() {
channel, err := a.Srv().Store().Channel().Get(args.ChannelId, true)
chanChan <- store.StoreResult{Data: channel, NErr: err}
chanChan <- store.GenericStoreResult[*model.Channel]{Data: channel, NErr: err}
close(chanChan)
}()

teamChan := make(chan store.StoreResult, 1)
teamChan := make(chan store.GenericStoreResult[*model.Team], 1)
go func() {
team, err := a.Srv().Store().Team().Get(args.TeamId)
teamChan <- store.StoreResult{Data: team, NErr: err}
teamChan <- store.GenericStoreResult[*model.Team]{Data: team, NErr: err}
close(teamChan)
}()

userChan := make(chan store.StoreResult, 1)
userChan := make(chan store.GenericStoreResult[*model.User], 1)
go func() {
user, err := a.Srv().Store().User().Get(context.Background(), args.UserId)
userChan <- store.StoreResult{Data: user, NErr: err}
userChan <- store.GenericStoreResult[*model.User]{Data: user, NErr: err}
close(userChan)
}()

Expand All @@ -404,7 +404,7 @@ func (a *App) tryExecuteCustomCommand(c request.CTX, args *model.CommandArgs, tr
return nil, nil, model.NewAppError("tryExecuteCustomCommand", "app.team.get.finding.app_error", nil, "", http.StatusInternalServerError).Wrap(tr.NErr)
}
}
team := tr.Data.(*model.Team)
team := tr.Data

ur := <-userChan
if ur.NErr != nil {
Expand All @@ -416,7 +416,7 @@ func (a *App) tryExecuteCustomCommand(c request.CTX, args *model.CommandArgs, tr
return nil, nil, model.NewAppError("tryExecuteCustomCommand", "app.user.get.app_error", nil, "", http.StatusInternalServerError).Wrap(ur.NErr)
}
}
user := ur.Data.(*model.User)
user := ur.Data

cr := <-chanChan
if cr.NErr != nil {
Expand All @@ -428,7 +428,7 @@ func (a *App) tryExecuteCustomCommand(c request.CTX, args *model.CommandArgs, tr
return nil, nil, model.NewAppError("tryExecuteCustomCommand", "app.channel.get.find.app_error", nil, "", http.StatusInternalServerError).Wrap(cr.NErr)
}
}
channel := cr.Data.(*model.Channel)
channel := cr.Data

var cmd *model.Command

Expand Down

0 comments on commit 2a5e04d

Please sign in to comment.