From 9263d9fbf279f977157258c9f1d295a83de2c4fa Mon Sep 17 00:00:00 2001 From: Rebecca Cremona Date: Tue, 10 Oct 2023 14:04:50 -0400 Subject: [PATCH 1/2] Append a UUID to our contact email's subject line, to help with threading. --- perma_web/perma/views/common.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/perma_web/perma/views/common.py b/perma_web/perma/views/common.py index f6050b093..41198b89c 100755 --- a/perma_web/perma/views/common.py +++ b/perma_web/perma/views/common.py @@ -4,6 +4,7 @@ from io import StringIO from link_header import Link as Rel, LinkHeader from urllib.parse import urlencode +import uuid from timegate.utils import closest from warcio.timeutils import datetime_to_http_date from werkzeug.http import parse_date @@ -393,7 +394,7 @@ def handle_registrar_fields(form): if form.is_valid(): # Assemble info for email from_address = form.cleaned_data['email'] - subject = "[perma-contact] " + form.cleaned_data['subject'] + subject = f"[perma-contact] {form.cleaned_data['subject']} ({str(uuid.uuid4())})" context = { "message": form.cleaned_data['box2'], "from_address": from_address, @@ -499,7 +500,7 @@ def affiliation_string(): if form.is_valid(): if form.cleaned_data['guid']: from_address = form.cleaned_data['email'] - subject = "[perma-contact] Reporting Inappropriate Content" + subject = f"[perma-contact] Reporting Inappropriate Content ({str(uuid.uuid4())})" context = { "reason": form.cleaned_data['reason'], "source": form.cleaned_data['source'], From de28c32765d02080d4675af69bf3b638c4b3b964 Mon Sep 17 00:00:00 2001 From: Rebecca Cremona Date: Tue, 10 Oct 2023 14:09:38 -0400 Subject: [PATCH 2/2] Update tests. --- perma_web/perma/tests/test_views_common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/perma_web/perma/tests/test_views_common.py b/perma_web/perma/tests/test_views_common.py index 35624f0eb..42a5c8216 100644 --- a/perma_web/perma/tests/test_views_common.py +++ b/perma_web/perma/tests/test_views_common.py @@ -480,7 +480,7 @@ def test_contact_standard_submit_required(self): self.assertIn("Referring Page: " + self.refering_page, message.body) self.assertIn("Affiliations: (none)", message.body) self.assertIn("Logged in: false", message.body) - self.assertEqual(message.subject, self.subject_prefix + self.custom_subject) + self.assertTrue(message.subject.startswith(self.subject_prefix + self.custom_subject)) self.assertEqual(message.from_email, self.our_address) self.assertEqual(message.recipients(), [self.our_address]) self.assertDictEqual(message.extra_headers, {'Reply-To': self.from_email}) @@ -515,7 +515,7 @@ def test_contact_standard_submit_no_optional(self): self.assertIn("Referring Page: ", message.body) self.assertIn("Affiliations: (none)", message.body) self.assertIn("Logged in: false", message.body) - self.assertEqual(message.subject, self.subject_prefix + 'New message from Perma contact form') + self.assertTrue(message.subject.startswith(self.subject_prefix + 'New message from Perma contact form')) self.assertEqual(message.from_email, self.our_address ) self.assertEqual(message.recipients(), [self.our_address]) self.assertDictEqual(message.extra_headers, {'Reply-To': self.from_email})