Browse Source

[IMP] - convert mailadresses to lowercase to increase change for match

- handle situation that optional mail address componenents not present in mail
      - slight reorganisation of code to aid debugging and made pep8 compliant as well.
pull/78/head
Ronald Portier 12 years ago
parent
commit
85ff68da13
  1. 18
      fetchmail_attach_from_folder/match_algorithm/email_exact.py

18
fetchmail_attach_from_folder/match_algorithm/email_exact.py

@ -34,21 +34,23 @@ class email_exact(base):
mailaddresses = []
fields = conf.mail_field.split(',')
for field in fields:
mailaddresses+=to_email(mail_message[field])
return mailaddresses
if field in mail_message:
mailaddresses += to_email(mail_message[field])
return [ addr.lower() for addr in mailaddresses ]
def _get_mailaddress_search_domain(
self, conf, mail_message, operator='=', values=None):
mailaddresses = values or self._get_mailaddresses(
conf, mail_message)
if not mailaddresses:
return [(0,'=',1)]
return ((['|'] * (len(mailaddresses) - 1)) + [
return [(0, '=', 1)]
search_domain = ((['|'] * (len(mailaddresses) - 1)) + [
(conf.model_field, operator, addr) for addr in mailaddresses] +
safe_eval(conf.domain or '[]'))
return search_domain
def search_matches(self, cr, uid, conf, mail_message, mail_message_org):
return conf.pool.get(conf.model_id.model).search(
cr, uid,
self._get_mailaddress_search_domain(conf, mail_message),
order=conf.model_order)
conf_model = conf.pool.get(conf.model_id.model)
search_domain = self._get_mailaddress_search_domain(conf, mail_message)
return conf_model.search(
cr, uid, search_domain, order=conf.model_order)
Loading…
Cancel
Save