diff --git a/cmd/answer/wire_gen.go b/cmd/answer/wire_gen.go index fe01c2db..515efa46 100644 --- a/cmd/answer/wire_gen.go +++ b/cmd/answer/wire_gen.go @@ -181,7 +181,7 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database, reportAdminService := report_admin.NewReportAdminService(reportRepo, userCommon, commonRepo, answerRepo, questionRepo, commentCommonRepo, reportHandle, configRepo) controller_adminReportController := controller_admin.NewReportController(reportAdminService) userAdminRepo := user.NewUserAdminRepo(dataData, authRepo) - userAdminService := user_admin.NewUserAdminService(userAdminRepo, userRoleRelService, authService, userCommon) + userAdminService := user_admin.NewUserAdminService(userAdminRepo, userRoleRelService, authService, userCommon, userActiveActivityRepo) userAdminController := controller_admin.NewUserAdminController(userAdminService) reasonRepo := reason.NewReasonRepo(configRepo) reasonService := reason2.NewReasonService(reasonRepo) diff --git a/internal/service/user_admin/user_backyard.go b/internal/service/user_admin/user_backyard.go index 9641bdfe..ae09ce85 100644 --- a/internal/service/user_admin/user_backyard.go +++ b/internal/service/user_admin/user_backyard.go @@ -12,6 +12,7 @@ import ( "github.com/answerdev/answer/internal/base/reason" "github.com/answerdev/answer/internal/entity" "github.com/answerdev/answer/internal/schema" + "github.com/answerdev/answer/internal/service/activity" "github.com/answerdev/answer/internal/service/auth" "github.com/answerdev/answer/internal/service/role" usercommon "github.com/answerdev/answer/internal/service/user_common" @@ -38,6 +39,7 @@ type UserAdminService struct { userRoleRelService *role.UserRoleRelService authService *auth.AuthService userCommonService *usercommon.UserCommon + userActivity activity.UserActiveActivityRepo } // NewUserAdminService new user admin service @@ -46,12 +48,14 @@ func NewUserAdminService( userRoleRelService *role.UserRoleRelService, authService *auth.AuthService, userCommonService *usercommon.UserCommon, + userActivity activity.UserActiveActivityRepo, ) *UserAdminService { return &UserAdminService{ userRepo: userRepo, userRoleRelService: userRoleRelService, authService: authService, userCommonService: userCommonService, + userActivity: userActivity, } } @@ -83,7 +87,17 @@ func (us *UserAdminService) UpdateUserStatus(ctx context.Context, req *schema.Up userInfo.Status = entity.UserStatusAvailable userInfo.MailStatus = entity.EmailStatusAvailable } - return us.userRepo.UpdateUserStatus(ctx, userInfo.ID, userInfo.Status, userInfo.MailStatus, userInfo.EMail) + + err = us.userRepo.UpdateUserStatus(ctx, userInfo.ID, userInfo.Status, userInfo.MailStatus, userInfo.EMail) + if err != nil { + return err + } + + // if user reputation is zero means this user is inactive, so try to activate this user. + if req.IsNormal() && userInfo.Rank == 0 { + return us.userActivity.UserActive(ctx, userInfo.ID) + } + return nil } // UpdateUserRole update user role