feat(notification): add notification for invited to answer

This commit is contained in:
LinkinStars 2023-05-23 16:32:10 +08:00
parent f5bb3ff6e5
commit 15438f0403
2 changed files with 18 additions and 0 deletions

View File

@ -35,4 +35,6 @@ const (
NotificationYourAnswerWasDeleted = "notification.action.your_answer_was_deleted"
// NotificationYourCommentWasDeleted your comment was deleted
NotificationYourCommentWasDeleted = "notification.action.your_comment_was_deleted"
// NotificationInvitedYouToAnswer invited you to answer
NotificationInvitedYouToAnswer = "notification.action.invited_you_to_answer"
)

View File

@ -579,9 +579,25 @@ func (qs *QuestionService) UpdateQuestionInviteUser(ctx context.Context, req *sc
if saveerr != nil {
return saveerr
}
qs.notificationInviteUser(ctx, inviteUser, req.ID, req.UserID)
return nil
}
func (qs *QuestionService) notificationInviteUser(
ctx context.Context, invitedUserIDs []string, questionID, questionUserID string) {
for _, userID := range invitedUserIDs {
msg := &schema.NotificationMsg{
ReceiverUserID: userID,
TriggerUserID: questionUserID,
Type: schema.NotificationTypeInbox,
ObjectID: questionID,
}
msg.ObjectType = constant.QuestionObjectType
msg.NotificationAction = constant.NotificationInvitedYouToAnswer
notice_queue.AddNotification(msg)
}
}
// UpdateQuestion update question
func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.QuestionUpdate) (questionInfo any, err error) {
var canUpdate bool