diff options
author | 赵智超 <1012112796@qq.com> | 2020-09-18 19:58:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-18 19:58:49 +0800 |
commit | 65aef7b35f5b4c83c122dfce5d0c3b8ee2a60bd1 (patch) | |
tree | 15d653d9610739b9da0f8f8c1a93fb3e46762399 | |
parent | 65ef634d5cd88b0a96ae82e5eee335ec10956f6f (diff) | |
download | gitea-65aef7b35f5b4c83c122dfce5d0c3b8ee2a60bd1.tar.gz gitea-65aef7b35f5b4c83c122dfce5d0c3b8ee2a60bd1.zip |
Add size limit for content of comment on action ui (#12881) (#12890)
Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: mrsdizzie <info@mrsdizzie.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: mrsdizzie <info@mrsdizzie.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
-rw-r--r-- | modules/notification/action/action.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/notification/action/action.go b/modules/notification/action/action.go index 9956940f30..a62f1e13ad 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 { |