From 2a8cd575c9256281b9a631bf38b65aed0f3337f6 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 2 Aug 2018 10:53:59 +0200 Subject: [PATCH] [FIX] mail_tracking_mailgun: alternative domain - In case the sending domain is different from the one configured in the mail.domain.catchall setting. --- mail_tracking_mailgun/README.rst | 2 ++ mail_tracking_mailgun/__manifest__.py | 2 +- mail_tracking_mailgun/models/mail_tracking_email.py | 3 ++- mail_tracking_mailgun/tests/test_mailgun.py | 12 +++++++++--- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mail_tracking_mailgun/README.rst b/mail_tracking_mailgun/README.rst index 3b835164..67eb4276 100644 --- a/mail_tracking_mailgun/README.rst +++ b/mail_tracking_mailgun/README.rst @@ -36,6 +36,8 @@ parameters: domain. - `mailgun.api_url`: It should be fine as it is, but it could change in the future. +- `mailgun.domain`: In case your sending domain is different from the one + configured in `mail.catchall.domain`. - `mailgun.validation_key`: If you want to be able to check mail address validity you must config this parameter with your account Public Validation Key. diff --git a/mail_tracking_mailgun/__manifest__.py b/mail_tracking_mailgun/__manifest__.py index 5fdc44b9..cbb346d4 100644 --- a/mail_tracking_mailgun/__manifest__.py +++ b/mail_tracking_mailgun/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Mail tracking for Mailgun", "summary": "Mail tracking and Mailgun webhooks integration", - "version": "11.0.1.0.3", + "version": "11.0.1.1.0", "category": "Social Network", "website": "https://github.com/OCA/social", "author": "Tecnativa, " diff --git a/mail_tracking_mailgun/models/mail_tracking_email.py b/mail_tracking_mailgun/models/mail_tracking_email.py index 64863966..64692833 100644 --- a/mail_tracking_mailgun/models/mail_tracking_email.py +++ b/mail_tracking_mailgun/models/mail_tracking_email.py @@ -70,7 +70,8 @@ class MailTrackingEmail(models.Model): raise ValidationError(_('There is no Mailgun API key!')) api_url = icp.get_param( 'mailgun.api_url', 'https://api.mailgun.net/v3') - domain = icp.get_param('mail.catchall.domain') + catchall_domain = icp.get_param('mail.catchall.domain') + domain = icp.get_param('mailgun.domain', catchall_domain) if not domain: raise ValidationError(_('A Mailgun domain value is needed!')) validation_key = icp.get_param('mailgun.validation_key') diff --git a/mail_tracking_mailgun/tests/test_mailgun.py b/mail_tracking_mailgun/tests/test_mailgun.py index db4a98ba..7230ce93 100644 --- a/mail_tracking_mailgun/tests/test_mailgun.py +++ b/mail_tracking_mailgun/tests/test_mailgun.py @@ -104,6 +104,11 @@ class TestMailgun(TransactionCase): self.test_event_delivered() with self.assertRaises(ValidationError): self.env['mail.tracking.email']._mailgun_values() + # now we set an specific domain for Mailgun: + # i.e: we configure new EU zone without loosing old domain statistics + self.env['ir.config_parameter'].set_param( + 'mailgun.domain', 'eu.example.com') + self.test_event_delivered() @mute_logger('odoo.addons.mail_tracking_mailgun.models' '.mail_tracking_email') @@ -169,9 +174,10 @@ class TestMailgun(TransactionCase): response = self.env['mail.tracking.email'].event_process( None, self.event, self.metadata) self.assertEqual('OK', response) - event = self.event_search('delivered') - self.assertEqual(event.timestamp, float(self.timestamp)) - self.assertEqual(event.recipient, self.recipient) + events = self.event_search('delivered') + for event in events: + self.assertEqual(event.timestamp, float(self.timestamp)) + self.assertEqual(event.recipient, self.recipient) # https://documentation.mailgun.com/user_manual.html#tracking-opens def test_event_opened(self):