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.
Files changed (24) hide show
  1. {fetch2gmail-1.1.0/src/fetch2gmail.egg-info → fetch2gmail-1.1.1}/PKG-INFO +1 -1
  2. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/pyproject.toml +1 -1
  3. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1/src/fetch2gmail.egg-info}/PKG-INFO +1 -1
  4. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/gmail_client.py +22 -0
  5. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/LICENSE +0 -0
  6. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/README.md +0 -0
  7. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/setup.cfg +0 -0
  8. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetch2gmail.egg-info/SOURCES.txt +0 -0
  9. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetch2gmail.egg-info/dependency_links.txt +0 -0
  10. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetch2gmail.egg-info/entry_points.txt +0 -0
  11. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetch2gmail.egg-info/requires.txt +0 -0
  12. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetch2gmail.egg-info/top_level.txt +0 -0
  13. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/__init__.py +0 -0
  14. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/auth_server.py +0 -0
  15. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/auth_ui.py +0 -0
  16. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/cli.py +0 -0
  17. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/config.py +0 -0
  18. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/env_file.py +0 -0
  19. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/imap_client.py +0 -0
  20. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/log_buffer.py +0 -0
  21. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/run.py +0 -0
  22. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/state.py +0 -0
  23. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/ui_auth.py +0 -0
  24. {fetch2gmail-1.1.0 → fetch2gmail-1.1.1}/src/fetcher/web_ui.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fetch2gmail
3
- Version: 1.1.0
3
+ Version: 1.1.1
4
4
  Summary: Self-hosted email fetcher: IMAP to Gmail API import with idempotent state tracking
5
5
  Author: Fetch2Gmail Contributors
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fetch2gmail"
7
- version = "1.1.0"
7
+ version = "1.1.1"
8
8
  description = "Self-hosted email fetcher: IMAP to Gmail API import with idempotent state tracking"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fetch2gmail
3
- Version: 1.1.0
3
+ Version: 1.1.1
4
4
  Summary: Self-hosted email fetcher: IMAP to Gmail API import with idempotent state tracking
5
5
  Author: Fetch2Gmail Contributors
6
6
  License-Expression: MIT
@@ -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