[FIX] mail: ensure case insensitive check when (de)activating blacklist 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 #25966 as well as task ID 1889703 (tests and fixes) and its PR #27330. Done with collaboration of @dbeguin.
This commit is contained in:
@@ -59,7 +59,8 @@ class MailBlackList(models.Model):
|
||||
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:
|
||||
@@ -67,7 +68,8 @@ class MailBlackList(models.Model):
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user