diff --git a/internal/controller/user_controller.go b/internal/controller/user_controller.go index 5ca79133..70d997c8 100644 --- a/internal/controller/user_controller.go +++ b/internal/controller/user_controller.go @@ -75,7 +75,7 @@ func (uc *UserController) GetUserInfoByUserID(ctx *gin.Context) { } resp, err := uc.userService.GetUserInfoByUserID(ctx, token, userInfo.UserID) - uc.setVisitCookies(ctx, userInfo.VisitToken) + uc.setVisitCookies(ctx, userInfo.VisitToken, false) handler.HandleResponse(ctx, err, resp) } @@ -139,7 +139,7 @@ func (uc *UserController) UserEmailLogin(ctx *gin.Context) { if !isAdmin { uc.actionService.ActionRecordDel(ctx, entity.CaptchaActionPassword, ctx.ClientIP()) } - uc.setVisitCookies(ctx, resp.VisitToken) + uc.setVisitCookies(ctx, resp.VisitToken, true) handler.HandleResponse(ctx, nil, resp) } @@ -680,9 +680,9 @@ func (uc *UserController) SearchUserListByName(ctx *gin.Context) { handler.HandleResponse(ctx, err, resp) } -func (uc *UserController) setVisitCookies(ctx *gin.Context, visitToken string) { +func (uc *UserController) setVisitCookies(ctx *gin.Context, visitToken string, force bool) { cookie, err := ctx.Cookie(constant.UserVisitCookiesCacheKey) - if err == nil && len(cookie) > 0 { + if err == nil && len(cookie) > 0 && !force { return } general, err := uc.siteInfoCommonService.GetSiteGeneral(ctx) diff --git a/internal/service/answer_service.go b/internal/service/answer_service.go index 82b87eda..1c82790a 100644 --- a/internal/service/answer_service.go +++ b/internal/service/answer_service.go @@ -502,6 +502,7 @@ func (as *AnswerService) AdminSetAnswerStatus(ctx context.Context, req *schema.A //} as.activityQueueService.Send(ctx, &schema.ActivityMsg{ UserID: req.UserID, + TriggerUserID: converter.StringToInt64(req.UserID), ObjectID: answerInfo.ID, OriginalObjectID: answerInfo.ID, ActivityTypeKey: constant.ActAnswerDeleted, diff --git a/internal/service/question_service.go b/internal/service/question_service.go index 3f388229..f0625778 100644 --- a/internal/service/question_service.go +++ b/internal/service/question_service.go @@ -1281,6 +1281,7 @@ func (qs *QuestionService) AdminSetQuestionStatus(ctx context.Context, req *sche //} qs.activityQueueService.Send(ctx, &schema.ActivityMsg{ UserID: questionInfo.UserID, + TriggerUserID: converter.StringToInt64(req.UserID), ObjectID: questionInfo.ID, OriginalObjectID: questionInfo.ID, ActivityTypeKey: constant.ActQuestionDeleted, @@ -1290,6 +1291,7 @@ func (qs *QuestionService) AdminSetQuestionStatus(ctx context.Context, req *sche if setStatus == entity.QuestionStatusAvailable && questionInfo.Status == entity.QuestionStatusClosed { qs.activityQueueService.Send(ctx, &schema.ActivityMsg{ UserID: questionInfo.UserID, + TriggerUserID: converter.StringToInt64(req.UserID), ObjectID: questionInfo.ID, OriginalObjectID: questionInfo.ID, ActivityTypeKey: constant.ActQuestionReopened, @@ -1298,6 +1300,7 @@ func (qs *QuestionService) AdminSetQuestionStatus(ctx context.Context, req *sche if setStatus == entity.QuestionStatusClosed && questionInfo.Status != entity.QuestionStatusClosed { qs.activityQueueService.Send(ctx, &schema.ActivityMsg{ UserID: questionInfo.UserID, + TriggerUserID: converter.StringToInt64(req.UserID), ObjectID: questionInfo.ID, OriginalObjectID: questionInfo.ID, ActivityTypeKey: constant.ActQuestionClosed,