A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
fix(notification): Remove the author from notification subscribers
LinkinStarsfce6e1d0750d
diff --git a/internal/schema/email_template.go b/internal/schema/email_template.goindex 2884eaa7..1d54d92f 100644--- a/internal/schema/email_template.go+++ b/internal/schema/email_template.go@@ -87,11 +87,12 @@ type NewCommentTemplateData struct {}type NewQuestionTemplateRawData struct {- QuestionTitle string- QuestionID string- UnsubscribeCode string- Tags []string- TagIDs []string+ QuestionAuthorUserID string+ QuestionTitle string+ QuestionID string+ UnsubscribeCode string+ Tags []string+ TagIDs []string}type NewQuestionTemplateData struct {diff --git a/internal/schema/new_question_queue_schema.go b/internal/schema/new_question_queue_schema.goindex 2bc05431..4410a050 100644--- a/internal/schema/new_question_queue_schema.go+++ b/internal/schema/new_question_queue_schema.go@@ -16,12 +16,14 @@ type ExternalNotificationMsg struct {NewQuestionTemplateRawData *NewQuestionTemplateRawData `json:"new_question_template_raw_data,omitempty"`}-func CreateNewQuestionNotificationMsg(questionID, questionTitle string, tags []*entity.Tag) *ExternalNotificationMsg {+func CreateNewQuestionNotificationMsg(+ questionID, questionTitle, questionAuthorUserID string, tags []*entity.Tag) *ExternalNotificationMsg {questionID = uid.DeShortID(questionID)msg := &ExternalNotificationMsg{NewQuestionTemplateRawData: &NewQuestionTemplateRawData{- QuestionID: questionID,- QuestionTitle: questionTitle,+ QuestionAuthorUserID: questionAuthorUserID,+ QuestionID: questionID,+ QuestionTitle: questionTitle,},}for _, tag := range tags {diff --git a/internal/service/notification/new_question_notification.go b/internal/service/notification/new_question_notification.goindex 3d41b443..8237e9e3 100644--- a/internal/service/notification/new_question_notification.go+++ b/internal/service/notification/new_question_notification.go@@ -78,7 +78,6 @@ func (ns *ExternalNotificationService) getNewQuestionSubscribers(ctx context.ConUserID: userNotificationConfig.UserID,Channels: schema.NewNotificationChannelsFormJson(userNotificationConfig.Channels),}- subscribers = append(subscribers, subscribersMapping[userNotificationConfig.UserID])}log.Debugf("get %d subscribers from tags", len(subscribersMapping))@@ -98,7 +97,12 @@ func (ns *ExternalNotificationService) getNewQuestionSubscribers(ctx context.ConUserID: notificationConfig.UserID,Channels: schema.NewNotificationChannelsFormJson(notificationConfig.Channels),}- subscribers = append(subscribers, subscribersMapping[notificationConfig.UserID])+ }++ // 3. remove question owner+ delete(subscribersMapping, msg.NewQuestionTemplateRawData.QuestionAuthorUserID)+ for _, subscriber := range subscribersMapping {+ subscribers = append(subscribers, subscriber)}log.Debugf("get %d subscribers from all new question config", len(subscribers))return subscribers, nildiff --git a/internal/service/question_service.go b/internal/service/question_service.goindex 866b2a47..48dbffcd 100644--- a/internal/service/question_service.go+++ b/internal/service/question_service.go@@ -333,7 +333,7 @@ func (qs *QuestionService) AddQuestion(ctx context.Context, req *schema.Question})qs.externalNotificationQueueService.Send(ctx,- schema.CreateNewQuestionNotificationMsg(question.ID, question.Title, tags))+ schema.CreateNewQuestionNotificationMsg(question.ID, question.Title, question.UserID, tags))questionInfo, err = qs.GetQuestion(ctx, question.ID, question.UserID, req.QuestionPermission)return