[MM-55737] Add Request Context to UserStore.Save (#26109)
Этот коммит содержится в:
@@ -95,7 +95,7 @@ func (a *App) CreateBot(c request.CTX, bot *model.Bot) (*model.Bot, *model.AppEr
|
||||
return nil, vErr
|
||||
}
|
||||
|
||||
user, nErr := a.Srv().Store().User().Save(model.UserFromBot(bot))
|
||||
user, nErr := a.Srv().Store().User().Save(c, model.UserFromBot(bot))
|
||||
if nErr != nil {
|
||||
var appErr *model.AppError
|
||||
var invErr *store.ErrInvalidInput
|
||||
@@ -160,7 +160,7 @@ func (a *App) CreateBot(c request.CTX, bot *model.Bot) (*model.Bot, *model.AppEr
|
||||
return savedBot, nil
|
||||
}
|
||||
|
||||
func (a *App) GetWarnMetricsBot() (*model.Bot, *model.AppError) {
|
||||
func (a *App) GetWarnMetricsBot(rctx request.CTX) (*model.Bot, *model.AppError) {
|
||||
perPage := 1
|
||||
userOptions := &model.UserGetOptions{
|
||||
Page: 0,
|
||||
@@ -186,10 +186,10 @@ func (a *App) GetWarnMetricsBot() (*model.Bot, *model.AppError) {
|
||||
OwnerId: sysAdminList[0].Id,
|
||||
}
|
||||
|
||||
return a.getOrCreateBot(warnMetricsBot)
|
||||
return a.getOrCreateBot(rctx, warnMetricsBot)
|
||||
}
|
||||
|
||||
func (a *App) GetSystemBot() (*model.Bot, *model.AppError) {
|
||||
func (a *App) GetSystemBot(rctx request.CTX) (*model.Bot, *model.AppError) {
|
||||
perPage := 1
|
||||
userOptions := &model.UserGetOptions{
|
||||
Page: 0,
|
||||
@@ -215,10 +215,10 @@ func (a *App) GetSystemBot() (*model.Bot, *model.AppError) {
|
||||
OwnerId: sysAdminList[0].Id,
|
||||
}
|
||||
|
||||
return a.getOrCreateBot(systemBot)
|
||||
return a.getOrCreateBot(rctx, systemBot)
|
||||
}
|
||||
|
||||
func (a *App) getOrCreateBot(botDef *model.Bot) (*model.Bot, *model.AppError) {
|
||||
func (a *App) getOrCreateBot(rctx request.CTX, botDef *model.Bot) (*model.Bot, *model.AppError) {
|
||||
botUser, appErr := a.GetUserByUsername(botDef.Username)
|
||||
if appErr != nil {
|
||||
if appErr.StatusCode != http.StatusNotFound {
|
||||
@@ -226,7 +226,7 @@ func (a *App) getOrCreateBot(botDef *model.Bot) (*model.Bot, *model.AppError) {
|
||||
}
|
||||
|
||||
// cannot find this bot user, save the user
|
||||
user, nErr := a.Srv().Store().User().Save(model.UserFromBot(botDef))
|
||||
user, nErr := a.Srv().Store().User().Save(rctx, model.UserFromBot(botDef))
|
||||
if nErr != nil {
|
||||
var appError *model.AppError
|
||||
var invErr *store.ErrInvalidInput
|
||||
|
||||
Ссылка в новой задаче
Block a user