You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by li...@apache.org on 2024/03/21 09:10:54 UTC

(incubator-answer) branch feat/1.3.0/notifiaction updated: feat(notification): send format content summary

This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch feat/1.3.0/notifiaction
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git


The following commit(s) were added to refs/heads/feat/1.3.0/notifiaction by this push:
     new c01dd12a feat(notification): send format content summary
c01dd12a is described below

commit c01dd12a8f407bbb1a242ae25b5b5ed4378fd8c5
Author: LinkinStars <li...@foxmail.com>
AuthorDate: Thu Mar 21 17:10:45 2024 +0800

    feat(notification): send format content summary
---
 internal/service/answer_service.go          | 3 ++-
 internal/service/comment/comment_service.go | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/internal/service/answer_service.go b/internal/service/answer_service.go
index db605a1d..ae59b224 100644
--- a/internal/service/answer_service.go
+++ b/internal/service/answer_service.go
@@ -41,6 +41,7 @@ import (
 	"github.com/apache/incubator-answer/internal/service/role"
 	usercommon "github.com/apache/incubator-answer/internal/service/user_common"
 	"github.com/apache/incubator-answer/pkg/converter"
+	"github.com/apache/incubator-answer/pkg/htmltext"
 	"github.com/apache/incubator-answer/pkg/token"
 	"github.com/apache/incubator-answer/pkg/uid"
 	"github.com/segmentfault/pacman/errors"
@@ -269,7 +270,7 @@ func (as *AnswerService) Insert(ctx context.Context, req *schema.AnswerAddReq) (
 		return insertData.ID, err
 	}
 	as.notificationAnswerTheQuestion(ctx, questionInfo.UserID, questionInfo.ID, insertData.ID, req.UserID, questionInfo.Title,
-		insertData.ParsedText)
+		htmltext.FetchExcerpt(insertData.ParsedText, "...", 240))
 
 	as.activityQueueService.Send(ctx, &schema.ActivityMsg{
 		UserID:           insertData.UserID,
diff --git a/internal/service/comment/comment_service.go b/internal/service/comment/comment_service.go
index 4517d6b0..a689a95d 100644
--- a/internal/service/comment/comment_service.go
+++ b/internal/service/comment/comment_service.go
@@ -213,7 +213,7 @@ func (cs *CommentService) addCommentNotification(
 			resp.ReplyUserStatus = replyUser.Status
 		}
 		cs.notificationCommentReply(ctx, replyUser.ID, comment.ID, req.UserID,
-			objInfo.QuestionID, objInfo.Title, comment.ParsedText)
+			objInfo.QuestionID, objInfo.Title, htmltext.FetchExcerpt(comment.ParsedText, "...", 240))
 		alreadyNotifiedUserID[replyUser.ID] = true
 		return nil, nil
 	}
@@ -229,10 +229,10 @@ func (cs *CommentService) addCommentNotification(
 
 	if objInfo.ObjectType == constant.QuestionObjectType && !alreadyNotifiedUserID[objInfo.ObjectCreatorUserID] {
 		cs.notificationQuestionComment(ctx, objInfo.ObjectCreatorUserID,
-			objInfo.QuestionID, objInfo.Title, comment.ID, req.UserID, comment.ParsedText)
+			objInfo.QuestionID, objInfo.Title, comment.ID, req.UserID, htmltext.FetchExcerpt(comment.ParsedText, "...", 240))
 	} else if objInfo.ObjectType == constant.AnswerObjectType && !alreadyNotifiedUserID[objInfo.ObjectCreatorUserID] {
 		cs.notificationAnswerComment(ctx, objInfo.QuestionID, objInfo.Title, objInfo.AnswerID,
-			objInfo.ObjectCreatorUserID, comment.ID, req.UserID, comment.ParsedText)
+			objInfo.ObjectCreatorUserID, comment.ID, req.UserID, htmltext.FetchExcerpt(comment.ParsedText, "...", 240))
 	}
 	return nil, nil
 }