fetch2gmail 1.1.0__tar.gz → 1.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fetch2gmail-1.1.0/src/fetch2gmail.egg-info → fetch2gmail-1.1.1}/PKG-INFO +1 -1
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/pyproject.toml +1 -1
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1/src/fetch2gmail.egg-info}/PKG-INFO +1 -1
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/gmail_client.py +22 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/LICENSE +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/README.md +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/setup.cfg +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetch2gmail.egg-info/SOURCES.txt +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetch2gmail.egg-info/dependency_links.txt +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetch2gmail.egg-info/entry_points.txt +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetch2gmail.egg-info/requires.txt +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetch2gmail.egg-info/top_level.txt +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/__init__.py +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/auth_server.py +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/auth_ui.py +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/cli.py +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/config.py +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/env_file.py +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/imap_client.py +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/log_buffer.py +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/run.py +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/state.py +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/ui_auth.py +0 -0
- {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/web_ui.py +0 -0
|
@@ -50,6 +50,27 @@ def get_gmail_service(credentials_path: str | Path, token_path: str | Path):
|
|
|
50
50
|
return build("gmail", "v1", credentials=creds, cache_discovery=False)
|
|
51
51
|
|
|
52
52
|
|
|
53
|
+
def _normalize_from_header(raw: bytes) -> bytes:
|
|
54
|
+
"""
|
|
55
|
+
Ensure the message has exactly one From header. Gmail import requires it.
|
|
56
|
+
Some ISP messages have none or multiple From headers and would otherwise get 400.
|
|
57
|
+
"""
|
|
58
|
+
try:
|
|
59
|
+
msg = BytesParser(policy=policy.default).parsebytes(raw)
|
|
60
|
+
from_vals = msg.get_all("From") or []
|
|
61
|
+
if len(from_vals) == 0:
|
|
62
|
+
msg["From"] = "unknown@unknown.local"
|
|
63
|
+
logger.debug("Message had no From header; added placeholder")
|
|
64
|
+
elif len(from_vals) > 1:
|
|
65
|
+
msg["From"] = from_vals[0]
|
|
66
|
+
logger.debug("Message had %s From headers; kept first", len(from_vals))
|
|
67
|
+
else:
|
|
68
|
+
return raw
|
|
69
|
+
return msg.as_bytes()
|
|
70
|
+
except Exception: # noqa: BLE001
|
|
71
|
+
return raw
|
|
72
|
+
|
|
73
|
+
|
|
53
74
|
def _parse_date_from_raw(raw: bytes) -> str | None:
|
|
54
75
|
"""Extract Date header from raw message for Gmail internalDate."""
|
|
55
76
|
try:
|
|
@@ -102,6 +123,7 @@ def import_message(
|
|
|
102
123
|
If mark_unread is False (message was read on ISP), the message is imported as read.
|
|
103
124
|
Returns Gmail message ID.
|
|
104
125
|
"""
|
|
126
|
+
raw = _normalize_from_header(raw)
|
|
105
127
|
body = {"raw": base64.urlsafe_b64encode(raw).decode("ascii")}
|
|
106
128
|
internal_date = _parse_date_from_raw(raw)
|
|
107
129
|
if internal_date:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|