mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-12-27 09:08:53 +01:00
Fix ironic ticket creation loop when submitter email == queue email
This commit is contained in:
parent
df94b56b07
commit
90621f575d
@ -613,6 +613,8 @@ class Ticket(models.Model):
|
|||||||
if dont_send_to is not None:
|
if dont_send_to is not None:
|
||||||
recipients.update(dont_send_to)
|
recipients.update(dont_send_to)
|
||||||
|
|
||||||
|
recipients.add(self.queue.email_address)
|
||||||
|
|
||||||
def should_receive(email):
|
def should_receive(email):
|
||||||
return email and email not in recipients
|
return email and email not in recipients
|
||||||
|
|
||||||
|
@ -140,6 +140,37 @@ class TicketBasicsTestCase(TestCase):
|
|||||||
# Ensure only two e-mails were sent - submitter & updated.
|
# Ensure only two e-mails were sent - submitter & updated.
|
||||||
self.assertEqual(email_count + 2, len(mail.outbox))
|
self.assertEqual(email_count + 2, len(mail.outbox))
|
||||||
|
|
||||||
|
def test_create_ticket_public_no_loopback(self):
|
||||||
|
"""
|
||||||
|
Don't send emails to the queue's own inbox. It'll create a loop.
|
||||||
|
"""
|
||||||
|
email_count = len(mail.outbox)
|
||||||
|
|
||||||
|
self.queue_public.email_address = "queue@example.com"
|
||||||
|
self.queue_public.save()
|
||||||
|
|
||||||
|
post_data = {
|
||||||
|
'title': 'Test ticket title',
|
||||||
|
'queue': self.queue_public.id,
|
||||||
|
'submitter_email': 'queue@example.com',
|
||||||
|
'body': 'Test ticket body',
|
||||||
|
'priority': 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
response = self.client.post(reverse('helpdesk:home'), post_data, follow=True)
|
||||||
|
last_redirect = response.redirect_chain[-1]
|
||||||
|
last_redirect_url = last_redirect[0]
|
||||||
|
# last_redirect_status = last_redirect[1]
|
||||||
|
|
||||||
|
# Ensure we landed on the "View" page.
|
||||||
|
# Django 1.9 compatible way of testing this
|
||||||
|
# https://docs.djangoproject.com/en/1.9/releases/1.9/#http-redirects-no-longer-forced-to-absolute-uris
|
||||||
|
urlparts = urlparse(last_redirect_url)
|
||||||
|
self.assertEqual(urlparts.path, reverse('helpdesk:public_view'))
|
||||||
|
|
||||||
|
# Ensure submitter, new-queue + update-queue were all emailed.
|
||||||
|
self.assertEqual(email_count + 2, len(mail.outbox))
|
||||||
|
|
||||||
|
|
||||||
class EmailInteractionsTestCase(TestCase):
|
class EmailInteractionsTestCase(TestCase):
|
||||||
fixtures = ['emailtemplate.json']
|
fixtures = ['emailtemplate.json']
|
||||||
|
Loading…
Reference in New Issue
Block a user