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.
import requests
import json
+import textwrap
from pgcommitfest.auth import user_search
from .models import CommitFest, Patch, MailThread, MailThreadAttachment
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()