mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Updated permanentDelete to receive user context as the first argument (#26884)
Co-authored-by: Ezekiel <ezekielchow94@gmail.com>
This commit is contained in:
parent
a6aa92d149
commit
5746bb8df3
@ -2744,7 +2744,7 @@ func TestGetUsersWithoutTeam(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
th.LinkUserToTeam(user, th.BasicTeam)
|
||||
defer th.App.Srv().Store().User().PermanentDelete(user.Id)
|
||||
defer th.App.Srv().Store().User().PermanentDelete(th.Context, user.Id)
|
||||
|
||||
user2, _, err := th.Client.CreateUser(context.Background(), &model.User{
|
||||
Username: "a000000001" + model.NewId(),
|
||||
@ -2752,7 +2752,7 @@ func TestGetUsersWithoutTeam(t *testing.T) {
|
||||
Password: "Password1",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
defer th.App.Srv().Store().User().PermanentDelete(user2.Id)
|
||||
defer th.App.Srv().Store().User().PermanentDelete(th.Context, user2.Id)
|
||||
|
||||
rusers, _, err := th.SystemAdminClient.GetUsersWithoutTeam(context.Background(), 0, 100, "")
|
||||
require.NoError(t, err)
|
||||
|
@ -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,
|
||||
|
@ -12252,7 +12252,7 @@ func (s *OpenTracingLayerUserStore) IsEmpty(excludeBots bool) (bool, error) {
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerUserStore) PermanentDelete(userID string) error {
|
||||
func (s *OpenTracingLayerUserStore) PermanentDelete(rctx request.CTX, userID string) error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "UserStore.PermanentDelete")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@ -12261,7 +12261,7 @@ func (s *OpenTracingLayerUserStore) PermanentDelete(userID string) error {
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
err := s.UserStore.PermanentDelete(userID)
|
||||
err := s.UserStore.PermanentDelete(rctx, userID)
|
||||
if err != nil {
|
||||
span.LogFields(spanlog.Error(err))
|
||||
ext.Error.Set(span, true)
|
||||
|
@ -13977,11 +13977,11 @@ func (s *RetryLayerUserStore) IsEmpty(excludeBots bool) (bool, error) {
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerUserStore) PermanentDelete(userID string) error {
|
||||
func (s *RetryLayerUserStore) PermanentDelete(rctx request.CTX, userID string) error {
|
||||
|
||||
tries := 0
|
||||
for {
|
||||
err := s.UserStore.PermanentDelete(userID)
|
||||
err := s.UserStore.PermanentDelete(rctx, userID)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -90,15 +90,12 @@ func (s *SearchUserStore) Save(rctx request.CTX, user *model.User) (*model.User,
|
||||
return nuser, err
|
||||
}
|
||||
|
||||
func (s *SearchUserStore) PermanentDelete(userId string) error {
|
||||
// TODO: Use the actuall request context from the App layer
|
||||
// https://mattermost.atlassian.net/browse/MM-55738
|
||||
rctx := request.EmptyContext(s.rootStore.Logger())
|
||||
func (s *SearchUserStore) PermanentDelete(rctx request.CTX, userId string) error {
|
||||
user, userErr := s.UserStore.Get(context.Background(), userId)
|
||||
if userErr != nil {
|
||||
rctx.Logger().Warn("Encountered error deleting user", mlog.String("user_id", userId), mlog.Err(userErr))
|
||||
}
|
||||
err := s.UserStore.PermanentDelete(userId)
|
||||
err := s.UserStore.PermanentDelete(rctx, userId)
|
||||
if err == nil && userErr == nil {
|
||||
s.deleteUserIndex(rctx, user)
|
||||
}
|
||||
|
@ -192,14 +192,14 @@ func (th *SearchTestHelper) createGuest(username, nickname, firstName, lastName
|
||||
}
|
||||
|
||||
func (th *SearchTestHelper) deleteUser(user *model.User) error {
|
||||
return th.Store.User().PermanentDelete(user.Id)
|
||||
return th.Store.User().PermanentDelete(th.Context, user.Id)
|
||||
}
|
||||
|
||||
func (th *SearchTestHelper) deleteBotUser(botID string) error {
|
||||
if err := th.deleteBot(botID); err != nil {
|
||||
return err
|
||||
}
|
||||
return th.Store.User().PermanentDelete(botID)
|
||||
return th.Store.User().PermanentDelete(th.Context, botID)
|
||||
}
|
||||
|
||||
func (th *SearchTestHelper) cleanAllUsers() error {
|
||||
@ -233,7 +233,7 @@ func (th *SearchTestHelper) createBot(username, displayName, ownerID string) (*m
|
||||
botModel.UserId = user.Id
|
||||
bot, err := th.Store.Bot().Save(botModel)
|
||||
if err != nil {
|
||||
th.Store.User().PermanentDelete(bot.UserId)
|
||||
th.Store.User().PermanentDelete(th.Context, bot.UserId)
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
|
@ -1337,7 +1337,7 @@ func (us SqlUserStore) VerifyEmail(userId, email string) (string, error) {
|
||||
return userId, nil
|
||||
}
|
||||
|
||||
func (us SqlUserStore) PermanentDelete(userId string) error {
|
||||
func (us SqlUserStore) PermanentDelete(rctx request.CTX, userId string) error {
|
||||
if _, err := us.GetMasterX().Exec("DELETE FROM Users WHERE Id = ?", userId); err != nil {
|
||||
return errors.Wrapf(err, "failed to delete User with userId=%s", userId)
|
||||
}
|
||||
|
@ -444,7 +444,7 @@ type UserStore interface {
|
||||
GetEtagForProfiles(teamID string) string
|
||||
UpdateFailedPasswordAttempts(userID string, attempts int) error
|
||||
GetSystemAdminProfiles() (map[string]*model.User, error)
|
||||
PermanentDelete(userID string) error
|
||||
PermanentDelete(rctx request.CTX, userID string) error
|
||||
AnalyticsActiveCount(timestamp int64, options model.UserCountOptions) (int64, error)
|
||||
AnalyticsActiveCountForPeriod(startTime int64, endTime int64, options model.UserCountOptions) (int64, error)
|
||||
GetUnreadCount(userID string, isCRTEnabled bool) (int64, error)
|
||||
|
@ -44,7 +44,7 @@ func testBotStoreGet(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore)
|
||||
deletedBot, err := ss.Bot().Update(deletedBot)
|
||||
require.NoError(t, err)
|
||||
defer func() { require.NoError(t, ss.Bot().PermanentDelete(deletedBot.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(deletedBot.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, deletedBot.UserId)) }()
|
||||
|
||||
permanentlyDeletedBot, _ := makeBotWithUser(t, rctx, ss, &model.Bot{
|
||||
Username: "permanently_deleted_bot",
|
||||
@ -54,7 +54,7 @@ func testBotStoreGet(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore)
|
||||
DeleteAt: 0,
|
||||
})
|
||||
require.NoError(t, ss.Bot().PermanentDelete(permanentlyDeletedBot.UserId))
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(permanentlyDeletedBot.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, permanentlyDeletedBot.UserId)) }()
|
||||
|
||||
b1, _ := makeBotWithUser(t, rctx, ss, &model.Bot{
|
||||
Username: "b1",
|
||||
@ -63,7 +63,7 @@ func testBotStoreGet(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore)
|
||||
LastIconUpdate: model.GetMillis(),
|
||||
})
|
||||
defer func() { require.NoError(t, ss.Bot().PermanentDelete(b1.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(b1.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, b1.UserId)) }()
|
||||
|
||||
b2, _ := makeBotWithUser(t, rctx, ss, &model.Bot{
|
||||
Username: "b2",
|
||||
@ -72,7 +72,7 @@ func testBotStoreGet(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore)
|
||||
LastIconUpdate: 0,
|
||||
})
|
||||
defer func() { require.NoError(t, ss.Bot().PermanentDelete(b2.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(b2.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, b2.UserId)) }()
|
||||
|
||||
// Artificially set b2.LastIconUpdate to NULL to verify handling of same.
|
||||
_, sqlErr := s.GetMasterX().Exec("UPDATE Bots SET LastIconUpdate = NULL WHERE UserId = '" + b2.UserId + "'")
|
||||
@ -132,7 +132,7 @@ func testBotStoreGetAll(t *testing.T, rctx request.CTX, ss store.Store, s SqlSto
|
||||
deletedBot, err := ss.Bot().Update(deletedBot)
|
||||
require.NoError(t, err)
|
||||
defer func() { require.NoError(t, ss.Bot().PermanentDelete(deletedBot.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(deletedBot.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, deletedBot.UserId)) }()
|
||||
|
||||
permanentlyDeletedBot, _ := makeBotWithUser(t, rctx, ss, &model.Bot{
|
||||
Username: "permanently_deleted_bot",
|
||||
@ -142,7 +142,7 @@ func testBotStoreGetAll(t *testing.T, rctx request.CTX, ss store.Store, s SqlSto
|
||||
DeleteAt: 0,
|
||||
})
|
||||
require.NoError(t, ss.Bot().PermanentDelete(permanentlyDeletedBot.UserId))
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(permanentlyDeletedBot.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, permanentlyDeletedBot.UserId)) }()
|
||||
|
||||
b1, _ := makeBotWithUser(t, rctx, ss, &model.Bot{
|
||||
Username: "b1",
|
||||
@ -151,7 +151,7 @@ func testBotStoreGetAll(t *testing.T, rctx request.CTX, ss store.Store, s SqlSto
|
||||
LastIconUpdate: model.GetMillis(),
|
||||
})
|
||||
defer func() { require.NoError(t, ss.Bot().PermanentDelete(b1.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(b1.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, b1.UserId)) }()
|
||||
|
||||
b2, _ := makeBotWithUser(t, rctx, ss, &model.Bot{
|
||||
Username: "b2",
|
||||
@ -160,7 +160,7 @@ func testBotStoreGetAll(t *testing.T, rctx request.CTX, ss store.Store, s SqlSto
|
||||
LastIconUpdate: 0,
|
||||
})
|
||||
defer func() { require.NoError(t, ss.Bot().PermanentDelete(b2.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(b2.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, b2.UserId)) }()
|
||||
|
||||
// Artificially set b2.LastIconUpdate to NULL to verify handling of same.
|
||||
_, sqlErr := s.GetMasterX().Exec("UPDATE Bots SET LastIconUpdate = NULL WHERE UserId = '" + b2.UserId + "'")
|
||||
@ -181,7 +181,7 @@ func testBotStoreGetAll(t *testing.T, rctx request.CTX, ss store.Store, s SqlSto
|
||||
OwnerId: OwnerId1,
|
||||
})
|
||||
defer func() { require.NoError(t, ss.Bot().PermanentDelete(b3.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(b3.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, b3.UserId)) }()
|
||||
|
||||
b4, _ := makeBotWithUser(t, rctx, ss, &model.Bot{
|
||||
Username: "b4",
|
||||
@ -189,7 +189,7 @@ func testBotStoreGetAll(t *testing.T, rctx request.CTX, ss store.Store, s SqlSto
|
||||
OwnerId: OwnerId2,
|
||||
})
|
||||
defer func() { require.NoError(t, ss.Bot().PermanentDelete(b4.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(b4.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, b4.UserId)) }()
|
||||
|
||||
deletedUser := model.User{
|
||||
Email: MakeEmail(),
|
||||
@ -202,14 +202,14 @@ func testBotStoreGetAll(t *testing.T, rctx request.CTX, ss store.Store, s SqlSto
|
||||
_, err2 := ss.User().Update(rctx, &deletedUser, true)
|
||||
require.NoError(t, err2, "couldn't delete user")
|
||||
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(deletedUser.Id)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, deletedUser.Id)) }()
|
||||
ob5, _ := makeBotWithUser(t, rctx, ss, &model.Bot{
|
||||
Username: "ob5",
|
||||
Description: "Orphaned bot 5",
|
||||
OwnerId: deletedUser.Id,
|
||||
})
|
||||
defer func() { require.NoError(t, ss.Bot().PermanentDelete(b4.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(b4.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, b4.UserId)) }()
|
||||
|
||||
t.Run("get newly created bot stoo", func(t *testing.T) {
|
||||
bots, err := ss.Bot().GetAll(&model.BotGetOptions{Page: 0, PerPage: 10})
|
||||
@ -335,7 +335,7 @@ func testBotStoreSave(t *testing.T, rctx request.CTX, ss store.Store) {
|
||||
|
||||
user, err := ss.User().Save(rctx, model.UserFromBot(bot))
|
||||
require.NoError(t, err)
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(user.Id)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, user.Id)) }()
|
||||
bot.UserId = user.Id
|
||||
|
||||
returnedNewBot, nErr := ss.Bot().Save(bot)
|
||||
@ -366,7 +366,7 @@ func testBotStoreUpdate(t *testing.T, rctx request.CTX, ss store.Store) {
|
||||
OwnerId: model.NewId(),
|
||||
})
|
||||
defer func() { require.NoError(t, ss.Bot().PermanentDelete(existingBot.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(existingBot.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, existingBot.UserId)) }()
|
||||
|
||||
bot := existingBot.Clone()
|
||||
bot.Username = "invalid username"
|
||||
@ -383,7 +383,7 @@ func testBotStoreUpdate(t *testing.T, rctx request.CTX, ss store.Store) {
|
||||
OwnerId: model.NewId(),
|
||||
})
|
||||
defer func() { require.NoError(t, ss.Bot().PermanentDelete(existingBot.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(existingBot.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, existingBot.UserId)) }()
|
||||
|
||||
bot := existingBot.Clone()
|
||||
bot.OwnerId = model.NewId()
|
||||
@ -418,7 +418,7 @@ func testBotStoreUpdate(t *testing.T, rctx request.CTX, ss store.Store) {
|
||||
OwnerId: model.NewId(),
|
||||
})
|
||||
defer func() { require.NoError(t, ss.Bot().PermanentDelete(existingBot.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(existingBot.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, existingBot.UserId)) }()
|
||||
|
||||
existingBot.DeleteAt = 100000
|
||||
existingBot, err := ss.Bot().Update(existingBot)
|
||||
@ -447,14 +447,14 @@ func testBotStorePermanentDelete(t *testing.T, rctx request.CTX, ss store.Store)
|
||||
OwnerId: model.NewId(),
|
||||
})
|
||||
defer func() { require.NoError(t, ss.Bot().PermanentDelete(b1.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(b1.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, b1.UserId)) }()
|
||||
|
||||
b2, _ := makeBotWithUser(t, rctx, ss, &model.Bot{
|
||||
Username: "b2",
|
||||
OwnerId: model.NewId(),
|
||||
})
|
||||
defer func() { require.NoError(t, ss.Bot().PermanentDelete(b2.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(b2.UserId)) }()
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, b2.UserId)) }()
|
||||
|
||||
t.Run("permanently delete a non-existent bot", func(t *testing.T) {
|
||||
err := ss.Bot().PermanentDelete("unknown")
|
||||
|
@ -2182,7 +2182,7 @@ func testClearSidebarOnTeamLeave(t *testing.T, rctx request.CTX, ss store.Store,
|
||||
func testDeleteSidebarCategory(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore) {
|
||||
t.Run("should correctly remove an empty category", func(t *testing.T) {
|
||||
userId, teamId := setupInitialSidebarCategories(t, rctx, ss)
|
||||
defer ss.User().PermanentDelete(userId)
|
||||
defer ss.User().PermanentDelete(rctx, userId)
|
||||
|
||||
newCategory, err := ss.Channel().CreateSidebarCategory(userId, teamId, &model.SidebarCategoryWithChannels{})
|
||||
require.NoError(t, err)
|
||||
@ -2204,7 +2204,7 @@ func testDeleteSidebarCategory(t *testing.T, rctx request.CTX, ss store.Store, s
|
||||
|
||||
t.Run("should correctly remove a category and its channels", func(t *testing.T) {
|
||||
userId, teamId := setupInitialSidebarCategories(t, rctx, ss)
|
||||
defer ss.User().PermanentDelete(userId)
|
||||
defer ss.User().PermanentDelete(rctx, userId)
|
||||
|
||||
user := &model.User{
|
||||
Id: userId,
|
||||
@ -2272,7 +2272,7 @@ func testDeleteSidebarCategory(t *testing.T, rctx request.CTX, ss store.Store, s
|
||||
|
||||
t.Run("should not allow you to remove non-custom categories", func(t *testing.T) {
|
||||
userId, teamId := setupInitialSidebarCategories(t, rctx, ss)
|
||||
defer ss.User().PermanentDelete(userId)
|
||||
defer ss.User().PermanentDelete(rctx, userId)
|
||||
res, err := ss.Channel().GetSidebarCategoriesForTeamForUser(userId, teamId)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, res.Categories, 3)
|
||||
|
@ -21,7 +21,7 @@ func cleanupStoreState(t *testing.T, rctx request.CTX, ss store.Store) {
|
||||
allUsers, err := ss.User().GetAll()
|
||||
require.NoError(t, err, "error cleaning all test users", err)
|
||||
for _, u := range allUsers {
|
||||
err = ss.User().PermanentDelete(u.Id)
|
||||
err = ss.User().PermanentDelete(rctx, u.Id)
|
||||
require.NoError(t, err, "failed cleaning up test user %s", u.Username)
|
||||
|
||||
//remove all posts by this user
|
||||
|
@ -5350,8 +5350,8 @@ func groupTestDistinctGroupMemberCountForSource(t *testing.T, rctx request.CTX,
|
||||
ss.Group().Delete(customGroup.Id)
|
||||
ss.Group().Delete(ldapGroup.Id)
|
||||
|
||||
ss.User().PermanentDelete(user1.Id)
|
||||
ss.User().PermanentDelete(user2.Id)
|
||||
ss.User().PermanentDelete(rctx, user1.Id)
|
||||
ss.User().PermanentDelete(rctx, user2.Id)
|
||||
}()
|
||||
|
||||
customGroupCount, err := ss.Group().DistinctGroupMemberCountForSource(model.GroupSourceCustom)
|
||||
|
@ -1544,17 +1544,17 @@ func (_m *UserStore) IsEmpty(excludeBots bool) (bool, error) {
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// PermanentDelete provides a mock function with given fields: userID
|
||||
func (_m *UserStore) PermanentDelete(userID string) error {
|
||||
ret := _m.Called(userID)
|
||||
// PermanentDelete provides a mock function with given fields: rctx, userID
|
||||
func (_m *UserStore) PermanentDelete(rctx request.CTX, userID string) error {
|
||||
ret := _m.Called(rctx, userID)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for PermanentDelete")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string) error); ok {
|
||||
r0 = rf(userID)
|
||||
if rf, ok := ret.Get(0).(func(request.CTX, string) error); ok {
|
||||
r0 = rf(rctx, userID)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
@ -2895,7 +2895,7 @@ func testSaveTeamMemberMaxMembers(t *testing.T, rctx request.CTX, ss store.Store
|
||||
userIds[i] = user.Id
|
||||
|
||||
defer func(userId string) {
|
||||
ss.User().PermanentDelete(userId)
|
||||
ss.User().PermanentDelete(rctx, userId)
|
||||
}(userIds[i])
|
||||
|
||||
_, nErr := ss.Team().SaveMember(rctx, &model.TeamMember{
|
||||
@ -2920,7 +2920,7 @@ func testSaveTeamMemberMaxMembers(t *testing.T, rctx request.CTX, ss store.Store
|
||||
require.NoError(t, nErr)
|
||||
newUserId := user.Id
|
||||
defer func() {
|
||||
ss.User().PermanentDelete(newUserId)
|
||||
ss.User().PermanentDelete(rctx, newUserId)
|
||||
}()
|
||||
|
||||
_, nErr = ss.Team().SaveMember(rctx, &model.TeamMember{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11036,10 +11036,10 @@ func (s *TimerLayerUserStore) IsEmpty(excludeBots bool) (bool, error) {
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerUserStore) PermanentDelete(userID string) error {
|
||||
func (s *TimerLayerUserStore) PermanentDelete(rctx request.CTX, userID string) error {
|
||||
start := time.Now()
|
||||
|
||||
err := s.UserStore.PermanentDelete(userID)
|
||||
err := s.UserStore.PermanentDelete(rctx, userID)
|
||||
|
||||
elapsed := float64(time.Since(start)) / float64(time.Second)
|
||||
if s.Root.Metrics != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user