Stop processing filters if one match
This commit is contained in:
parent
a2890e0264
commit
de444649a7
1 changed files with 5 additions and 3 deletions
|
@ -92,7 +92,8 @@ class ImapFilter:
|
|||
return False
|
||||
for mfilter in mailbox['filters']:
|
||||
self._log.debug("Processing filter '%s'...", mfilter['name'])
|
||||
self._process_message(message_id, data[0], mfilter)
|
||||
if self._process_message(message_id, data[0], mfilter)['match']:
|
||||
break
|
||||
except imaplib.IMAP4.error as error:
|
||||
self._log.error(
|
||||
"Error fetching message. %s",
|
||||
|
@ -123,7 +124,7 @@ class ImapFilter:
|
|||
"Unexpected response fetching message: '%s'. Try again.",
|
||||
data
|
||||
)
|
||||
return False
|
||||
return {"match": False}
|
||||
part = data[1].decode('utf-8')
|
||||
message = email.message_from_string(part)
|
||||
decoded_field = email.header.decode_header(message.get(mfilter['field'], ""))
|
||||
|
@ -155,7 +156,8 @@ class ImapFilter:
|
|||
self._log.info('Doing nothing (dummy run)')
|
||||
else:
|
||||
self._do_filter(message_id, mfilter)
|
||||
return True
|
||||
return {"match": True}
|
||||
return {"match": False}
|
||||
|
||||
def _do_filter(self, message_id, mfilter):
|
||||
if f"_action_{mfilter['action']}" in dir(self):
|
||||
|
|
Loading…
Reference in a new issue