Skip to content

Commit

Permalink
[FIX] mail: ensure case insensitive check when (de)activating blackli…
Browse files Browse the repository at this point in the history
…st records

Now that blacklist records are set as lower case be sure all checks in
blacklist are done accordingly by using the sanitizer before comparing
email adresses.

This commit is related to task ID 33224 (original blacklist implementation
done for v12) and its PR odoo#25966 as well as task ID 1889703 (tests and fixes)
and its PR odoo#27330. Done with collaboration of @dbeguin.
  • Loading branch information
tde-banana-odoo committed Oct 2, 2018
1 parent 7b0c502 commit 5743122
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions addons/mail/models/mail_blacklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,17 @@ def write(self, values):
return super(MailBlackList, self).write(values)

def _add(self, email):
record = self.env["mail.blacklist"].with_context(active_test=False).search([('email', '=', email)])
sanitized = self._sanitize_email(email)
record = self.env["mail.blacklist"].with_context(active_test=False).search([('email', '=', sanitized)])
if len(record) > 0:
record.write({'active': True})
else:
record = self.create({'email': email})
return record

def _remove(self, email):
record = self.env["mail.blacklist"].with_context(active_test=False).search([('email', '=', email)])
sanitized = self._sanitize_email(email)
record = self.env["mail.blacklist"].with_context(active_test=False).search([('email', '=', sanitized)])
if len(record) > 0:
record.write({'active': False})
else:
Expand Down

0 comments on commit 5743122

Please sign in to comment.