From 63faa7d73c53629aa6ae9cf3d497f37cec50cd9e Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Tue, 10 Dec 2024 13:09:10 +0100 Subject: DOn't crash on very long annotations When a very long annotation is posted, we would crash if it's shorter than 500 characters, but the length of the *log* message became longer than 500. To handle this, shorten the text in the log message if it's too long. --- pgcommitfest/commitfest/ajax.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'pgcommitfest/commitfest/ajax.py') diff --git a/pgcommitfest/commitfest/ajax.py b/pgcommitfest/commitfest/ajax.py index e2fcb55..eaf7cdc 100644 --- a/pgcommitfest/commitfest/ajax.py +++ b/pgcommitfest/commitfest/ajax.py @@ -8,6 +8,7 @@ from django.db import transaction import requests import json +import textwrap from pgcommitfest.auth import user_search from .models import CommitFest, Patch, MailThread, MailThreadAttachment @@ -114,7 +115,7 @@ def annotateMessage(request): annotation.save() for p in thread.patches.all(): - PatchHistory(patch=p, by=request.user, what='Added annotation "%s" to %s' % (msg, msgid)).save_and_notify() + PatchHistory(patch=p, by=request.user, what='Added annotation "%s" to %s' % (textwrap.shorten(msg, 100), msgid)).save_and_notify() p.set_modified() p.save() -- cgit v1.2.3