Merge pull request #963 from koriaf/dev-subject-length

fix(emails): Avoid 'value too long for type character varying(200) ' …
This commit is contained in:
Garret Wassermann 2021-08-05 13:19:03 -04:00 committed by GitHub
commit 9fd5d466e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -788,6 +788,9 @@ class Ticket(models.Model):
self.modified = timezone.now()
if len(self.title) > 200:
self.title = self.title[:197] + "..."
super(Ticket, self).save(*args, **kwargs)
@staticmethod

View File

@ -1,6 +1,6 @@
To: helpdesk@auto-mat.cz
From: Timothy Hobbs <timothy.hobbs@auto-mat.cz>
Subject: Attachment without body
Subject: Attachment without body - and a looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong subject
Openpgp: preference=signencrypt
Message-ID: <b05893cd-77b5-3450-4b84-9a1ad5119def@auto-mat.cz>
Date: Fri, 15 Feb 2019 13:58:05 +0100

View File

@ -53,7 +53,13 @@ class GetEmailCommonTests(TestCase):
with open(os.path.join(THIS_DIR, "test_files/blank-body-with-attachment.eml")) as fd:
test_email = fd.read()
ticket = helpdesk.email.object_from_message(test_email, self.queue_public, self.logger)
self.assertEqual(ticket.title, "Attachment without body")
# title got truncated because of max_lengh of the model.title field
assert ticket.title == (
"Attachment without body - and a loooooooooooooooooooooooooooooooooo"
"ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo"
"ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo..."
)
self.assertEqual(ticket.description, "")
def test_email_with_quoted_printable_body(self):