UpdateQuestionInviteUser

This commit is contained in:
aichy126 2023-06-01 12:15:46 +08:00
parent 40f66f505c
commit 27aa4aa8cd
2 changed files with 27 additions and 1 deletions

View File

@ -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 *sc
if 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
}

15
pkg/converter/array.go Normal file
View File

@ -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
}