Browse Source

[8.0][IMP][mail_tracking] Speed installation time and discard concurrent events (#82)

[IMP] mail_tracking: Speed installation time, discard concurrent events and other fixes
pull/89/head
Antonio Espinosa 8 years ago
committed by Pedro M. Baeza
parent
commit
d173916651
  1. 22
      mail_tracking_mailgun/models/mail_tracking_email.py

22
mail_tracking_mailgun/models/mail_tracking_email.py

@ -42,15 +42,11 @@ class MailTrackingEmail(models.Model):
'dropped': 'reject',
}
@property
def _mailgun_supported_event_types(self):
return self._mailgun_event_type_mapping.keys()
def _mailgun_event_type_verify(self, event):
event = event or {}
mailgun_event_type = event.get('event')
if mailgun_event_type not in self._mailgun_supported_event_types:
_logger.info("Mailgun: event type '%s' not supported",
if mailgun_event_type not in self._mailgun_event_type_mapping:
_logger.error("Mailgun: event type '%s' not supported",
mailgun_event_type)
return False
# OK, event type is valid
@ -66,12 +62,12 @@ class MailTrackingEmail(models.Model):
event = event or {}
api_key = self.env['ir.config_parameter'].get_param('mailgun.apikey')
if not api_key:
_logger.info("No Mailgun api key configured. "
_logger.warning("No Mailgun api key configured. "
"Please add 'mailgun.apikey' to System parameters "
"to enable Mailgun authentication webhoook requests. "
"More info at: "
"https://documentation.mailgun.com/user_manual.html"
"#webhooks")
"to enable Mailgun authentication webhoook "
"requests. More info at: "
"https://documentation.mailgun.com/"
"user_manual.html#webhooks")
else:
timestamp = event.get('timestamp')
token = event.get('token')
@ -89,7 +85,7 @@ class MailTrackingEmail(models.Model):
odoo_db = event.get('odoo_db')
current_db = self.env.cr.dbname
if odoo_db != current_db:
_logger.info("Mailgun: Database '%s' is not the current database",
_logger.error("Mailgun: Database '%s' is not the current database",
odoo_db)
return False
# OK, DB is current
@ -124,7 +120,7 @@ class MailTrackingEmail(models.Model):
metadata[k] = event[v]
# Special field mapping
metadata.update({
'mobile': event.get('device-type') in ('mobile', 'tablet'),
'mobile': event.get('device-type') in {'mobile', 'tablet'},
'user_country_id': self._country_search(
event.get('country', False)),
})

Loading…
Cancel
Save