fetch2gmail 1.0.3__tar.gz → 1.0.4__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.0.3/src/fetch2gmail.egg-info → fetch2gmail-1.0.4}/PKG-INFO +1 -1
  2. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/pyproject.toml +1 -1
  3. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4/src/fetch2gmail.egg-info}/PKG-INFO +1 -1
  4. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetcher/web_ui.py +50 -4
  5. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/LICENSE +0 -0
  6. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/README.md +0 -0
  7. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/setup.cfg +0 -0
  8. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetch2gmail.egg-info/SOURCES.txt +0 -0
  9. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetch2gmail.egg-info/dependency_links.txt +0 -0
  10. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetch2gmail.egg-info/entry_points.txt +0 -0
  11. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetch2gmail.egg-info/requires.txt +0 -0
  12. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetch2gmail.egg-info/top_level.txt +0 -0
  13. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetcher/__init__.py +0 -0
  14. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetcher/auth_server.py +0 -0
  15. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetcher/auth_ui.py +0 -0
  16. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetcher/cli.py +0 -0
  17. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetcher/config.py +0 -0
  18. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetcher/env_file.py +0 -0
  19. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetcher/gmail_client.py +0 -0
  20. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetcher/imap_client.py +0 -0
  21. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetcher/log_buffer.py +0 -0
  22. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetcher/run.py +0 -0
  23. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetcher/state.py +0 -0
  24. {fetch2gmail-1.0.3 → fetch2gmail-1.0.4}/src/fetcher/ui_auth.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fetch2gmail
3
- Version: 1.0.3
3
+ Version: 1.0.4
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.0.3"
7
+ version = "1.0.4"
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.0.3
3
+ Version: 1.0.4
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
@@ -186,6 +186,7 @@ class ConfigResponse(BaseModel):
186
186
  state_db_path: str
187
187
  gmail_connected: bool
188
188
  imap_password_set: bool
189
+ config_exists: bool = True # False when config.json not created yet (show setup wizard)
189
190
 
190
191
 
191
192
  @app.get("/static/app.js", response_model=None)
@@ -236,7 +237,12 @@ def api_auth_session(request: Request) -> dict[str, bool]:
236
237
 
237
238
  @app.post("/api/logout")
238
239
  def api_logout():
239
- resp = RedirectResponse(url="/login", status_code=302)
240
+ """Clear session and redirect. With Basic Auth, browser may still re-send credentials; redirect to / with hint."""
241
+ cfg_dir = _config_dir_safe()
242
+ if load_ui_auth(cfg_dir):
243
+ resp = RedirectResponse(url="/?logged_out=1", status_code=302)
244
+ else:
245
+ resp = RedirectResponse(url="/login", status_code=302)
240
246
  clear_session_cookie(resp)
241
247
  return resp
242
248
 
@@ -305,15 +311,42 @@ def api_gmail_email(request: Request) -> dict[str, str | None]:
305
311
  return {"email": _gmail_email()}
306
312
 
307
313
 
314
+ def _default_config_response() -> ConfigResponse:
315
+ """Return empty config when config.json does not exist yet (avoids 404, show setup wizard)."""
316
+ return ConfigResponse(
317
+ imap=ImapConfigSafe(
318
+ host="",
319
+ port=993,
320
+ username="",
321
+ mailbox="INBOX",
322
+ use_ssl=True,
323
+ delete_after_import=True,
324
+ ),
325
+ gmail=GmailConfigSafe(
326
+ use_label=False,
327
+ label="ISP Mail",
328
+ credentials_path="credentials.json",
329
+ token_path="token.json",
330
+ ),
331
+ ui=UIConfigSafe(host="127.0.0.1", port=8765),
332
+ poll_interval_minutes=5,
333
+ state_db_path="state.db",
334
+ gmail_connected=_gmail_connected(),
335
+ imap_password_set=False,
336
+ config_exists=False,
337
+ )
338
+
339
+
308
340
  @app.get("/api/config", response_model=ConfigResponse)
309
341
  def api_config(request: Request) -> ConfigResponse:
310
342
  """Return non-sensitive config for display/editing (no password resolution)."""
311
343
  if not _require_auth(request):
312
344
  raise HTTPException(status_code=401, detail="Not authenticated")
345
+ path = _get_config_path()
346
+ if not path.exists():
347
+ return _default_config_response()
313
348
  try:
314
- cfg = load_config(_get_config_path(), resolve_password=False)
315
- except FileNotFoundError:
316
- raise HTTPException(status_code=404, detail="config.json not found")
349
+ cfg = load_config(path, resolve_password=False)
317
350
  except ValueError as e:
318
351
  raise HTTPException(status_code=400, detail=str(e))
319
352
  imap = cfg.get("imap") or {}
@@ -345,6 +378,7 @@ def api_config(request: Request) -> ConfigResponse:
345
378
  state_db_path=str(state.get("db_path", "state.db")),
346
379
  gmail_connected=_gmail_connected(),
347
380
  imap_password_set=_imap_password_set(),
381
+ config_exists=True,
348
382
  )
349
383
 
350
384
 
@@ -592,6 +626,7 @@ _HTML_PAGE = """
592
626
  <body>
593
627
  <h1>Fetch2Gmail <span class="logout" id="logoutSpan" style="display:none"><form method="post" action="/api/logout" style="display:inline"><button type="submit">Log out</button></form></span></h1>
594
628
  <p id="subtitle">IMAP to Gmail import. Configure below.</p>
629
+ <p id="loggedOutMsg" style="display:none" class="status"></p>
595
630
  <p id="loadingMsg">Loading...</p>
596
631
 
597
632
  <div id="credentialsFirst" style="display:none">
@@ -701,12 +736,23 @@ _APP_JS = r"""
701
736
  document.getElementById('subtitle').textContent = 'Gmail connected. You can run a fetch now.';
702
737
  history.replaceState({}, '', '/');
703
738
  }
739
+ if (params.get('logged_out') === '1') {
740
+ var el = document.getElementById('loggedOutMsg');
741
+ el.style.display = 'block';
742
+ el.textContent = 'You clicked Log out. When using password protection, the browser may still send your password. To fully log out, close this tab or use a private window.';
743
+ history.replaceState({}, '', '/');
744
+ }
704
745
  if (params.get('error') === 'no_credentials') document.getElementById('subtitle').innerHTML = '<span class="error">Put credentials.json in the app folder and try Connect Gmail again.</span>';
705
746
 
706
747
  function hideLoading() { var el = document.getElementById('loadingMsg'); if (el) el.style.display = 'none'; }
707
748
  function loadConfig() {
708
749
  return api('/api/config').then(function(c) {
709
750
  hideLoading();
751
+ if (!c.config_exists) {
752
+ document.getElementById('dashboard').style.display = 'none';
753
+ document.getElementById('setupWizard').style.display = 'block';
754
+ return null;
755
+ }
710
756
  document.getElementById('setupWizard').style.display = 'none';
711
757
  document.getElementById('dashboard').style.display = 'block';
712
758
  document.getElementById('imap_host').value = c.imap.host;
File without changes
File without changes
File without changes