@@ -15,6 +15,7 @@ import (
1515 "code.gitea.io/gitea/models/unit"
1616 user_model "code.gitea.io/gitea/models/user"
1717 "code.gitea.io/gitea/modules/cache"
18+ "code.gitea.io/gitea/modules/log"
1819 "code.gitea.io/gitea/modules/setting"
1920 "code.gitea.io/gitea/modules/util"
2021)
@@ -34,6 +35,8 @@ func GetFeeds(ctx context.Context, opts activities_model.GetFeedsOptions) (activ
3435 return activities_model .GetFeeds (ctx , opts )
3536}
3637
38+ const maxActionContentLength = 65535 // this is the max length of mysql text column, sqlite, postgres and mssql have a higher limit
39+
3740// notifyWatchers creates batch of actions for every watcher.
3841// It could insert duplicate actions for a repository action, like this:
3942// * Original action: UserID=1 (the real actor), ActUserID=1
@@ -42,6 +45,10 @@ func GetFeeds(ctx context.Context, opts activities_model.GetFeedsOptions) (activ
4245func notifyWatchers (ctx context.Context , act * activities_model.Action , watchers []* repo_model.Watch , permCode , permIssue , permPR []bool ) error {
4346 // Add feed for actioner.
4447 act .UserID = act .ActUserID
48+ if len (act .Content ) > maxActionContentLength {
49+ act .Content = util .EllipsisDisplayString (act .Content , maxActionContentLength )
50+ log .Warn ("Action [%d, %s]'s content is too long, truncated to %d bytes" , act .RepoID , act .OpType , maxActionContentLength )
51+ }
4552 if err := db .Insert (ctx , act ); err != nil {
4653 return fmt .Errorf ("insert new actioner: %w" , err )
4754 }
0 commit comments