IMAP idle and parser improvements
This commit is contained in:
parent
b133ac7a8a
commit
25343c9b7e
|
|
@ -104,6 +104,12 @@ class IdleHandler:
|
||||||
timeout=300 # 5 minute timeout
|
timeout=300 # 5 minute timeout
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Exit IDLE before processing (can't SEARCH while in IDLE)
|
||||||
|
try:
|
||||||
|
self._client.idle_done()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
# Process responses
|
# Process responses
|
||||||
for response in responses:
|
for response in responses:
|
||||||
if isinstance(response, tuple) and len(response) >= 2:
|
if isinstance(response, tuple) and len(response) >= 2:
|
||||||
|
|
@ -116,7 +122,7 @@ class IdleHandler:
|
||||||
)
|
)
|
||||||
last_count = count
|
last_count = count
|
||||||
finally:
|
finally:
|
||||||
# Always exit IDLE mode
|
# Ensure we exit IDLE mode (may already be done above)
|
||||||
try:
|
try:
|
||||||
self._client.idle_done()
|
self._client.idle_done()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ def parse_flags(flags: Any) -> MessageFlags:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def extract_text_body(msg: email.message.Message, max_length: int = 5000) -> tuple[str, str]:
|
def extract_text_body(msg: email.message.Message, max_length: int = 100000) -> tuple[str, str]:
|
||||||
"""Extract text and HTML bodies from an email message."""
|
"""Extract text and HTML bodies from an email message."""
|
||||||
text_body = ""
|
text_body = ""
|
||||||
html_body = ""
|
html_body = ""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue