Skip to content

Commit 65aef7b

Browse files
a1012112796mrsdizzielunnytechknowlogick
authored
Add size limit for content of comment on action ui (#12881) (#12890)
Signed-off-by: a1012112796 <[email protected]> Co-authored-by: mrsdizzie <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: mrsdizzie <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 65ef634 commit 65aef7b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

modules/notification/action/action.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,22 @@ func (a *actionNotifier) NotifyCreateIssueComment(doer *models.User, repo *model
9292
act := &models.Action{
9393
ActUserID: doer.ID,
9494
ActUser: doer,
95-
Content: fmt.Sprintf("%d|%s", issue.Index, comment.Content),
9695
RepoID: issue.Repo.ID,
9796
Repo: issue.Repo,
9897
Comment: comment,
9998
CommentID: comment.ID,
10099
IsPrivate: issue.Repo.IsPrivate,
101100
}
101+
102+
content := ""
103+
104+
if len(comment.Content) > 200 {
105+
content = content[:strings.LastIndex(comment.Content[0:200], " ")] + "…"
106+
} else {
107+
content = comment.Content
108+
}
109+
act.Content = fmt.Sprintf("%d|%s", issue.Index, content)
110+
102111
if issue.IsPull {
103112
act.OpType = models.ActionCommentPull
104113
} else {

0 commit comments

Comments
 (0)