From 5995326d51ab42014c6d77d3313233641c258318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=99=BA=E8=B6=85?= <1012112796@qq.com> Date: Fri, 18 Sep 2020 15:38:21 +0800 Subject: [PATCH] Add size limit for content of comment on action ui (#12881) Signed-off-by: a1012112796 <1012112796@qq.com> Co-authored-by: mrsdizzie Co-authored-by: Lunny Xiao --- modules/notification/action/action.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/notification/action/action.go b/modules/notification/action/action.go index 040cf3df10..4a257b3618 100644 --- a/modules/notification/action/action.go +++ b/modules/notification/action/action.go @@ -92,13 +92,22 @@ func (a *actionNotifier) NotifyCreateIssueComment(doer *models.User, repo *model act := &models.Action{ ActUserID: doer.ID, ActUser: doer, - Content: fmt.Sprintf("%d|%s", issue.Index, comment.Content), RepoID: issue.Repo.ID, Repo: issue.Repo, Comment: comment, CommentID: comment.ID, IsPrivate: issue.Repo.IsPrivate, } + + content := "" + + if len(comment.Content) > 200 { + content = content[:strings.LastIndex(comment.Content[0:200], " ")] + "…" + } else { + content = comment.Content + } + act.Content = fmt.Sprintf("%d|%s", issue.Index, content) + if issue.IsPull { act.OpType = models.ActionCommentPull } else {