Skip to content

Commit

Permalink
Merge pull request #3404 from rebeccacremona/unique-subject-lines
Browse files Browse the repository at this point in the history
Append a UUID to our contact email's subject line
  • Loading branch information
rebeccacremona authored Oct 10, 2023
2 parents 01f50a0 + de28c32 commit 0b46a30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions perma_web/perma/tests/test_views_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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})
Expand Down
5 changes: 3 additions & 2 deletions perma_web/perma/views/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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'],
Expand Down

0 comments on commit 0b46a30

Please sign in to comment.