diff options
| author | David Beguin <dbe@odoo.com> | 2018-10-12 15:33:15 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2019-08-09 14:30:55 +0000 |
| commit | 92fe83ecf8b4e64a42185bc056ba3c865df753cb (patch) | |
| tree | 47c420b69bd62f8558a02082457de1bdc5d4e9ad /addons/mass_mailing/models | |
| parent | f4524f03c32a27b1899562a71cad6f491bfe44ce (diff) | |
[IMP] mail, mass_mailing : reset bounce on mail reception
PURPOSE
Add some improvements in mail gateway: remove private discussion, improve
bounce management, allow resetting bounce counters, improve automatic set or
reset of blacklists and ease mass mailing inheritance.
SPECIFICATIONS
The number of message bounce is incremented each time the email bounce
on a specific email address. To have a correct information, we should
reset to zero this counter if we receive a mail from this address.
Indeed, if we receive an email from an email address, this email is
active and the message bounce number (if > 0) is not relevant anymore.
Only models inheriting form blacklist are impacted by this improvement
in order to limit a bit side effect.
Also, add a check in autoblacklist rule. No need to check the stats
if message_bounce is < 5.
This commit introduces
* ``_routing_reset_bounce`` routing method managing the bounce reset;
* ``_message_reset_bounce`` model method that resets bounce counter
in blacklist enabled models;
LINKS
Related to task ID : 1893155
Linked to PR #33340
Diffstat (limited to 'addons/mass_mailing/models')
| -rw-r--r-- | addons/mass_mailing/models/mail_thread.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/addons/mass_mailing/models/mail_thread.py b/addons/mass_mailing/models/mail_thread.py index 09c6ba53626..93f657da3cf 100644 --- a/addons/mass_mailing/models/mail_thread.py +++ b/addons/mass_mailing/models/mail_thread.py @@ -50,13 +50,14 @@ class MailThread(models.AbstractModel): bounced_email = message_dict['bounced_email'] bounced_msg_id = message_dict['bounced_msg_id'] + bounced_partner = message_dict['bounced_partner'] if bounced_msg_id: self.env['mailing.trace'].set_bounced(mail_message_ids=[bounced_msg_id]) if bounced_email: three_months_ago = fields.Datetime.to_string(datetime.datetime.now() - datetime.timedelta(weeks=13)) stats = self.env['mailing.trace'].search(['&', ('bounced', '>', three_months_ago), ('email', '=ilike', bounced_email)]).mapped('bounced') - if len(stats) >= BLACKLIST_MAX_BOUNCED_LIMIT: + if len(stats) >= BLACKLIST_MAX_BOUNCED_LIMIT and (not bounced_partner or bounced_partner.message_bounce >= BLACKLIST_MAX_BOUNCED_LIMIT): if max(stats) > min(stats) + datetime.timedelta(weeks=1): blacklist_rec = self.env['mail.blacklist'].sudo()._add(bounced_email) blacklist_rec._message_log( |
