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.
UpdateQuestionInviteUser
aichy12627aa4aa8cdf9
diff --git a/internal/service/question_service.go b/internal/service/question_service.goindex a12026d9..5e138428 100644--- a/internal/service/question_service.go+++ b/internal/service/question_service.go@@ -27,6 +27,7 @@ import ("github.com/answerdev/answer/internal/service/revision_common"tagcommon "github.com/answerdev/answer/internal/service/tag_common"usercommon "github.com/answerdev/answer/internal/service/user_common"+ "github.com/answerdev/answer/pkg/converter""github.com/answerdev/answer/pkg/encryption""github.com/answerdev/answer/pkg/htmltext""github.com/answerdev/answer/pkg/uid"@@ -588,7 +589,17 @@ func (qs *QuestionService) UpdateQuestionInviteUser(ctx context.Context, req *scif saveerr != nil {return saveerr}- go qs.notificationInviteUser(ctx, inviteUserIDs, originQuestion.ID, originQuestion.Title, req.UserID)+ //send notification+ oldInviteUserIDsStr := originQuestion.InviteUserID+ oldInviteUserIDs := make([]string, 0)+ if oldInviteUserIDsStr != "" {+ err = json.Unmarshal([]byte(oldInviteUserIDsStr), &oldInviteUserIDs)+ if err == nil {+ needSendNotificationUserIDs := converter.ArrayNotInArray(oldInviteUserIDs, inviteUserIDs)+ go qs.notificationInviteUser(ctx, needSendNotificationUserIDs, originQuestion.ID, originQuestion.Title, req.UserID)+ }+ }+return nil}diff --git a/pkg/converter/array.go b/pkg/converter/array.gonew file mode 100644index 00000000..31b03198--- /dev/null+++ b/pkg/converter/array.go@@ -0,0 +1,15 @@+package converter++func ArrayNotInArray(original []string, search []string) []string {+ var result []string+ originalMap := make(map[string]bool)+ for _, v := range original {+ originalMap[v] = true+ }+ for _, v := range search {+ if _, ok := originalMap[v]; !ok {+ result = append(result, v)+ }+ }+ return result+}