summaryrefslogtreecommitdiffstats
path: root/modules/notification
diff options
context:
space:
mode:
author赵智超 <1012112796@qq.com>2020-09-18 15:38:21 +0800
committerGitHub <noreply@github.com>2020-09-18 10:38:21 +0300
commit5995326d51ab42014c6d77d3313233641c258318 (patch)
tree922d06ad9e5e9cb9e861f249158c4d7eed990722 /modules/notification
parent1fb5bbd0984553f514db77728e532840fc4b9a33 (diff)
downloadgitea-5995326d51ab42014c6d77d3313233641c258318.tar.gz
gitea-5995326d51ab42014c6d77d3313233641c258318.zip
Add size limit for content of comment on action ui (#12881)
Signed-off-by: a1012112796 <1012112796@qq.com> Co-authored-by: mrsdizzie <info@mrsdizzie.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'modules/notification')
-rw-r--r--modules/notification/action/action.go11
1 files changed, 10 insertions, 1 deletions
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 {