Skip to content

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.

feat(notification): add notification for invited to answer

LinkinStars15438f040310
diff --git a/internal/base/constant/notification.go b/internal/base/constant/notification.go
index 8f8568a8..165c4c01 100644
--- a/internal/base/constant/notification.go
+++ b/internal/base/constant/notification.go
@@ -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"
)
diff --git a/internal/service/question_service.go b/internal/service/question_service.go
index 32b24a5e..5ec5f99d 100644
--- a/internal/service/question_service.go
+++ b/internal/service/question_service.go
@@ -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