Skip to content

Make keyword optional and resumable for Keyword Search + Forward - #4

Merged
klept0 merged 1 commit into
mainfrom
feature/optional-keyword-forward-resume
Jul 1, 2026
Merged

klept0 merged 1 commit into
mainfrom
feature/optional-keyword-forward-resume

Conversation

@klept0

@klept0 klept0 commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • keyword is no longer required for Keyword Search + Forward (CLI dialog and POST /api/keyword-forward) — leaving it blank now forwards every message in the selected range instead of blocking with a "Keyword cannot be empty" validation error.
  • When a date range is selected, keyword forwarding is now resumable: re-running the exact same source/date-range/keyword combination checks what was already forwarded and only sends what hasn't been, whether the previous run finished or was interrupted.
  • Dry-run now reports how many messages remain to forward, instead of always returning 0.

Implementation

Extracted the progress-tracking logic already used by Past Forward Messages/Forward Media Files (Forward.py) into a small, dependency-free source/service/ForwardProgress.py module (just JSON read/write — no Telethon client/queue needed), so MessageService.forward_messages_by_keyword can reuse the exact same resume/dedup mechanism instead of a third, divergent implementation. Forward.py's own progress_key/_load_progress/_save_progress/_mark_progress_completed/clear_progress are now thin delegating wrappers, so its existing public API (and the tests exercising it) are unchanged.

Test plan

  • ruff check / ruff format --check — clean
  • mypy source/ web/app.py — clean
  • pytest tests/ — 23/23 pass, including new regression tests: keyword-optional forwarding, resume-skips-already-forwarded-messages, and dry-run reporting the real remaining count
  • Verified live via a preview server: the web form's keyword field no longer has required, and POST /api/keyword-forward accepts keyword: null without a validation error (reaches business logic, confirmed via a 503 "not initialized" response rather than a 422)

- keyword is no longer required in KeywordForwardDialog or
  POST /api/keyword-forward — leaving it blank now forwards every
  message in the selected range instead of blocking on a "Keyword
  cannot be empty" validation error.
- When a date range is selected, keyword forwarding is now resumable:
  re-running the same source/date-range/keyword combination checks
  what was already forwarded (via min_id on the Telethon search) and
  only sends what hasn't been sent, whether the prior run finished or
  was interrupted. Dry-run now reports how many messages remain to
  forward instead of always returning 0.

Extracted the progress-tracking logic that already existed in
Forward.py (used by "Past Forward Messages" and "Forward Media Files")
into source/service/ForwardProgress.py, a small dependency-free module
(just JSON read/write, no client/queue needed), so MessageService can
reuse the exact same resume/dedup mechanism instead of a third,
divergent implementation. Forward.py's own progress_key/_load_progress/
_save_progress/_mark_progress_completed/clear_progress are now thin
delegating wrappers, preserving its existing public API for tests.

Added regression tests: keyword-optional forwarding, resume-skips-
already-forwarded, and dry-run reporting the real remaining count.
Verified the web form's keyword field is no longer required and that
POST /api/keyword-forward accepts keyword: null via a live preview server.

Co-Authored-By: Claude <noreply@anthropic.com>
@klept0
klept0 merged commit f03d817 into main Jul 1, 2026
7 checks passed
@klept0
klept0 deleted the feature/optional-keyword-forward-resume branch July 1, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant