send more informative auto reply
This commit is contained in:
parent
f7002c5548
commit
5a1cfedd56
2 changed files with 49 additions and 14 deletions
|
@ -174,7 +174,6 @@ def receive_email(envelope, log=None):
|
|||
|
||||
active_issue_thread, new = find_active_issue_thread(header_in_reply_to, subject)
|
||||
|
||||
|
||||
email = Email.objects.create(
|
||||
sender=sender, recipient=recipient, body=body, subject=subject, reference=header_message_id,
|
||||
in_reply_to=header_in_reply_to, raw=envelope.content.decode('utf-8'), event=target_event,
|
||||
|
@ -188,8 +187,19 @@ def receive_email(envelope, log=None):
|
|||
# auto reply if new issue
|
||||
references = collect_references(active_issue_thread)
|
||||
if not sender.startswith('noreply'):
|
||||
subject = f"Re: {subject} [#{active_issue_thread.short_uuid()}]"
|
||||
body = '''Your request (#{}) has been received and will be reviewed by our lost&found angels.
|
||||
|
||||
We are reviewing incoming requests during the event and teardown. Immediately after the event, expect a delay as the \
|
||||
workload is high. We will not forget about your request and get back in touch once we have updated information on your \
|
||||
request. Requests for devices, wallets, credit cards or similar items will be handled with priority.
|
||||
|
||||
If you happen to find your lost item or just want to add additional information, please reply to this email. Please \
|
||||
do not create a new request.
|
||||
|
||||
Your c3lf (Cloakroom + Lost&Found) Team'''.format(active_issue_thread.short_uuid())
|
||||
reply_email = Email.objects.create(
|
||||
sender=recipient, recipient=sender, body="Thank you for your message.", subject="Message received",
|
||||
sender=recipient, recipient=sender, body=body, subject=subject,
|
||||
in_reply_to=header_message_id, event=target_event, issue_thread=active_issue_thread)
|
||||
reply = make_reply(reply_email, references)
|
||||
else:
|
||||
|
|
|
@ -12,6 +12,19 @@ from mail.models import Email, EventAddress, EmailAttachment
|
|||
from mail.protocol import LMTPHandler
|
||||
from tickets.models import IssueThread, StateChange
|
||||
|
||||
expected_auto_reply_subject = 'Re: {} [#{}]'
|
||||
|
||||
expected_auto_reply = '''Your request (#{}) has been received and will be reviewed by our lost&found angels.
|
||||
|
||||
We are reviewing incoming requests during the event and teardown. Immediately after the event, expect a delay as the \
|
||||
workload is high. We will not forget about your request and get back in touch once we have updated information on your \
|
||||
request. Requests for devices, wallets, credit cards or similar items will be handled with priority.
|
||||
|
||||
If you happen to find your lost item or just want to add additional information, please reply to this email. Please \
|
||||
do not create a new request.
|
||||
|
||||
Your c3lf (Cloakroom + Lost&Found) Team'''
|
||||
|
||||
|
||||
def make_mocked_coro(return_value=mock.sentinel, raise_exception=mock.sentinel):
|
||||
async def mock_coro(*args, **kwargs):
|
||||
|
@ -93,10 +106,12 @@ class LMTPHandlerTestCase(TestCase): # TODO replace with less hacky test
|
|||
self.assertEqual(IssueThread.objects.all()[0], Email.objects.all()[0].issue_thread)
|
||||
self.assertEqual('<1@test>', Email.objects.all()[0].reference)
|
||||
self.assertEqual(None, Email.objects.all()[0].in_reply_to)
|
||||
self.assertEqual('Message received', Email.objects.all()[1].subject)
|
||||
self.assertEqual(expected_auto_reply_subject.format('test', IssueThread.objects.all()[0].short_uuid()),
|
||||
Email.objects.all()[1].subject)
|
||||
self.assertEqual('test2@test', Email.objects.all()[1].sender)
|
||||
self.assertEqual('test1@test', Email.objects.all()[1].recipient)
|
||||
self.assertEqual('Thank you for your message.', Email.objects.all()[1].body)
|
||||
self.assertEqual(expected_auto_reply.format(IssueThread.objects.all()[0].short_uuid()),
|
||||
Email.objects.all()[1].body)
|
||||
self.assertEqual(IssueThread.objects.all()[0], Email.objects.all()[1].issue_thread)
|
||||
self.assertTrue(Email.objects.all()[1].reference.startswith("<"))
|
||||
self.assertTrue(Email.objects.all()[1].reference.endswith("@localhost>"))
|
||||
|
@ -332,13 +347,15 @@ class LMTPHandlerTestCase(TestCase): # TODO replace with less hacky test
|
|||
self.assertEqual(event, Email.objects.all()[0].event)
|
||||
self.assertEqual(event, Email.objects.all()[1].event)
|
||||
self.assertEqual('test', Email.objects.all()[0].subject)
|
||||
self.assertEqual('Message received', Email.objects.all()[1].subject)
|
||||
self.assertEqual(expected_auto_reply_subject.format('test', IssueThread.objects.all()[0].short_uuid()),
|
||||
Email.objects.all()[1].subject)
|
||||
self.assertEqual('test1@test', Email.objects.all()[0].sender)
|
||||
self.assertEqual('test_event@localhost', Email.objects.all()[0].recipient)
|
||||
self.assertEqual('test_event@localhost', Email.objects.all()[1].sender)
|
||||
self.assertEqual('test1@test', Email.objects.all()[1].recipient)
|
||||
self.assertEqual('test', Email.objects.all()[0].body)
|
||||
self.assertEqual('Thank you for your message.', Email.objects.all()[1].body)
|
||||
self.assertEqual(expected_auto_reply.format(IssueThread.objects.all()[0].short_uuid()),
|
||||
Email.objects.all()[1].body)
|
||||
self.assertEqual(IssueThread.objects.all()[0], Email.objects.all()[0].issue_thread)
|
||||
self.assertEqual(IssueThread.objects.all()[0], Email.objects.all()[1].issue_thread)
|
||||
self.assertEqual('<1@test>', Email.objects.all()[0].reference)
|
||||
|
@ -404,10 +421,12 @@ test2
|
|||
self.assertEqual(IssueThread.objects.all()[0], Email.objects.all()[0].issue_thread)
|
||||
self.assertEqual('<1@test>', Email.objects.all()[0].reference)
|
||||
self.assertEqual(None, Email.objects.all()[0].in_reply_to)
|
||||
self.assertEqual('Message received', Email.objects.all()[1].subject)
|
||||
self.assertEqual(expected_auto_reply_subject.format('test', IssueThread.objects.all()[0].short_uuid()),
|
||||
Email.objects.all()[1].subject)
|
||||
self.assertEqual('test2@test', Email.objects.all()[1].sender)
|
||||
self.assertEqual('test1@test', Email.objects.all()[1].recipient)
|
||||
self.assertEqual('Thank you for your message.', Email.objects.all()[1].body)
|
||||
self.assertEqual(expected_auto_reply.format(IssueThread.objects.all()[0].short_uuid()),
|
||||
Email.objects.all()[1].body)
|
||||
self.assertEqual(IssueThread.objects.all()[0], Email.objects.all()[1].issue_thread)
|
||||
self.assertTrue(Email.objects.all()[1].reference.startswith("<"))
|
||||
self.assertTrue(Email.objects.all()[1].reference.endswith("@localhost>"))
|
||||
|
@ -470,10 +489,12 @@ dGVzdGltYWdl
|
|||
self.assertEqual(IssueThread.objects.all()[0], Email.objects.all()[0].issue_thread)
|
||||
self.assertEqual('<1@test>', Email.objects.all()[0].reference)
|
||||
self.assertEqual(None, Email.objects.all()[0].in_reply_to)
|
||||
self.assertEqual('Message received', Email.objects.all()[1].subject)
|
||||
self.assertEqual(expected_auto_reply_subject.format('test', IssueThread.objects.all()[0].short_uuid()),
|
||||
Email.objects.all()[1].subject)
|
||||
self.assertEqual('test2@test', Email.objects.all()[1].sender)
|
||||
self.assertEqual('test1@test', Email.objects.all()[1].recipient)
|
||||
self.assertEqual('Thank you for your message.', Email.objects.all()[1].body)
|
||||
self.assertEqual(expected_auto_reply.format(IssueThread.objects.all()[0].short_uuid()),
|
||||
Email.objects.all()[1].body)
|
||||
self.assertEqual(IssueThread.objects.all()[0], Email.objects.all()[1].issue_thread)
|
||||
self.assertTrue(Email.objects.all()[1].reference.startswith("<"))
|
||||
self.assertTrue(Email.objects.all()[1].reference.endswith("@localhost>"))
|
||||
|
@ -549,10 +570,12 @@ dGVzdGltYWdl
|
|||
self.assertEqual(IssueThread.objects.all()[0], Email.objects.all()[0].issue_thread)
|
||||
self.assertEqual('<1@test>', Email.objects.all()[0].reference)
|
||||
self.assertEqual(None, Email.objects.all()[0].in_reply_to)
|
||||
self.assertEqual('Message received', Email.objects.all()[1].subject)
|
||||
self.assertEqual(expected_auto_reply_subject.format('No subject', IssueThread.objects.all()[0].short_uuid()),
|
||||
Email.objects.all()[1].subject)
|
||||
self.assertEqual('test2@test', Email.objects.all()[1].sender)
|
||||
self.assertEqual('test1@test', Email.objects.all()[1].recipient)
|
||||
self.assertEqual('Thank you for your message.', Email.objects.all()[1].body)
|
||||
self.assertEqual(expected_auto_reply.format(IssueThread.objects.all()[0].short_uuid()),
|
||||
Email.objects.all()[1].body)
|
||||
self.assertEqual(IssueThread.objects.all()[0], Email.objects.all()[1].issue_thread)
|
||||
self.assertTrue(Email.objects.all()[1].reference.startswith("<"))
|
||||
self.assertTrue(Email.objects.all()[1].reference.endswith("@localhost>"))
|
||||
|
@ -591,10 +614,12 @@ dGVzdGltYWdl
|
|||
self.assertEqual(IssueThread.objects.all()[0], Email.objects.all()[0].issue_thread)
|
||||
self.assertEqual('<1@test>', Email.objects.all()[0].reference)
|
||||
self.assertEqual(None, Email.objects.all()[0].in_reply_to)
|
||||
self.assertEqual('Message received', Email.objects.all()[1].subject)
|
||||
self.assertEqual(expected_auto_reply_subject.format('test', IssueThread.objects.all()[0].short_uuid()),
|
||||
Email.objects.all()[1].subject)
|
||||
self.assertEqual('test2@test', Email.objects.all()[1].sender)
|
||||
self.assertEqual('<test1@test>', Email.objects.all()[1].recipient)
|
||||
self.assertEqual('Thank you for your message.', Email.objects.all()[1].body)
|
||||
self.assertEqual(expected_auto_reply.format(IssueThread.objects.all()[0].short_uuid()),
|
||||
Email.objects.all()[1].body)
|
||||
self.assertEqual(IssueThread.objects.all()[0], Email.objects.all()[1].issue_thread)
|
||||
self.assertTrue(Email.objects.all()[1].reference.startswith("<"))
|
||||
self.assertTrue(Email.objects.all()[1].reference.endswith("@localhost>"))
|
||||
|
|
Loading…
Reference in a new issue