Updated permanentDelete to receive user context as the first argument (#26884)

Co-authored-by: Ezekiel <ezekielchow94@gmail.com>
Этот коммит содержится в:
Ben Schumacher
2024-04-29 10:44:55 +02:00
коммит произвёл GitHub
родитель a6aa92d149
Коммит 5746bb8df3
21 изменённых файлов: 245 добавлений и 248 удалений

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

@@ -124,7 +124,7 @@ func (a *App) CreateBot(rctx request.CTX, bot *model.Bot) (*model.Bot, *model.Ap
savedBot, nErr := a.Srv().Store().Bot().Save(bot)
if nErr != nil {
a.Srv().Store().User().PermanentDelete(bot.UserId)
a.Srv().Store().User().PermanentDelete(rctx, bot.UserId)
var appErr *model.AppError
switch {
case errors.As(nErr, &appErr): // in case we haven't converted to plain error.
@@ -227,7 +227,7 @@ func (a *App) getOrCreateBot(rctx request.CTX, botDef *model.Bot) (*model.Bot, *
//save the bot
savedBot, nErr := a.Srv().Store().Bot().Save(botDef)
if nErr != nil {
a.Srv().Store().User().PermanentDelete(savedBot.UserId)
a.Srv().Store().User().PermanentDelete(rctx, savedBot.UserId)
var nAppErr *model.AppError
switch {
case errors.As(nErr, &nAppErr): // in case we haven't converted to plain error.
@@ -414,7 +414,7 @@ func (a *App) PermanentDeleteBot(rctx request.CTX, botUserId string) *model.AppE
}
}
if err := a.Srv().Store().User().PermanentDelete(botUserId); err != nil {
if err := a.Srv().Store().User().PermanentDelete(rctx, botUserId); err != nil {
return model.NewAppError("PermanentDeleteBot", "app.user.permanent_delete.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
}

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

@@ -169,7 +169,7 @@ func TestEnsureBot(t *testing.T) {
assert.Equal(t, "username", bot.Username)
assert.Equal(t, "a bot", bot.Description)
err = th.App.Srv().Store().User().PermanentDelete(initialBot.UserId)
err = th.App.Srv().Store().User().PermanentDelete(th.Context, initialBot.UserId)
require.NoError(t, err)
botID2, err := th.App.EnsureBot(th.Context, pluginId, &model.Bot{
Username: "another_username",

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

@@ -19,7 +19,7 @@ func TestSidebarCategory(t *testing.T) {
basicChannel2 := th.CreateChannel(th.Context, th.BasicTeam)
defer th.App.PermanentDeleteChannel(th.Context, basicChannel2)
user := th.CreateUser()
defer th.App.Srv().Store().User().PermanentDelete(user.Id)
defer th.App.Srv().Store().User().PermanentDelete(th.Context, user.Id)
th.LinkUserToTeam(user, th.BasicTeam)
th.AddUserToChannel(user, basicChannel2)

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

@@ -122,7 +122,7 @@ func (th *TestHelper) CreateUser(u *model.User) *model.User {
}
func (th *TestHelper) DeleteUser(u *model.User) {
err := th.dbStore.User().PermanentDelete(u.Id)
err := th.dbStore.User().PermanentDelete(th.Context, u.Id)
if err != nil {
panic(err)
}

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

@@ -1847,7 +1847,7 @@ func (a *App) PermanentDeleteUser(c request.CTX, user *model.User) *model.AppErr
return model.NewAppError("PermanentDeleteUser", "app.file_info.permanent_delete_by_user.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
}
if err := a.Srv().Store().User().PermanentDelete(user.Id); err != nil {
if err := a.Srv().Store().User().PermanentDelete(c, user.Id); err != nil {
return model.NewAppError("PermanentDeleteUser", "app.user.permanent_delete.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
}

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

@@ -56,7 +56,7 @@ func TestFirstUserPromoted(t *testing.T) {
require.Equal(t, model.SystemUserRoleId, user2.Roles)
th.dbStore.User().PermanentDelete(user.Id)
th.dbStore.User().PermanentDelete(th.Context, user.Id)
b := &model.Bot{
UserId: user2.Id,