mirror of https://gitee.com/answerdev/answer.git
UpdateQuestionInviteUser
This commit is contained in:
parent
40f66f505c
commit
27aa4aa8cd
|
@ -27,6 +27,7 @@ import (
|
||||||
"github.com/answerdev/answer/internal/service/revision_common"
|
"github.com/answerdev/answer/internal/service/revision_common"
|
||||||
tagcommon "github.com/answerdev/answer/internal/service/tag_common"
|
tagcommon "github.com/answerdev/answer/internal/service/tag_common"
|
||||||
usercommon "github.com/answerdev/answer/internal/service/user_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/encryption"
|
||||||
"github.com/answerdev/answer/pkg/htmltext"
|
"github.com/answerdev/answer/pkg/htmltext"
|
||||||
"github.com/answerdev/answer/pkg/uid"
|
"github.com/answerdev/answer/pkg/uid"
|
||||||
|
@ -588,7 +589,17 @@ func (qs *QuestionService) UpdateQuestionInviteUser(ctx context.Context, req *sc
|
||||||
if saveerr != nil {
|
if saveerr != nil {
|
||||||
return saveerr
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
Loading…
Reference in New Issue