]> source.dussan.org Git - gitea.git/commitdiff
Add size limit for content of comment on action ui (#12881)
author赵智超 <1012112796@qq.com>
Fri, 18 Sep 2020 07:38:21 +0000 (15:38 +0800)
committerGitHub <noreply@github.com>
Fri, 18 Sep 2020 07:38:21 +0000 (10:38 +0300)
Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: mrsdizzie <info@mrsdizzie.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
modules/notification/action/action.go

index 040cf3df1030dfb6d321c969c9853c8ab010e44c..4a257b3618792864e8ec57bdd0917ba20deb6174 100644 (file)
@@ -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 {