Repository navigation
Make keyword optional and resumable for Keyword Search + Forward - #4
Merged
Merged
Conversation
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
keywordis no longer required forKeyword Search + Forward(CLI dialog andPOST /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.0.Implementation
Extracted the progress-tracking logic already used by
Past Forward Messages/Forward Media Files(Forward.py) into a small, dependency-freesource/service/ForwardProgress.pymodule (just JSON read/write — no Telethon client/queue needed), soMessageService.forward_messages_by_keywordcan reuse the exact same resume/dedup mechanism instead of a third, divergent implementation.Forward.py's ownprogress_key/_load_progress/_save_progress/_mark_progress_completed/clear_progressare now thin delegating wrappers, so its existing public API (and the tests exercising it) are unchanged.Test plan
ruff check/ruff format --check— cleanmypy source/ web/app.py— cleanpytest tests/— 23/23 pass, including new regression tests: keyword-optional forwarding, resume-skips-already-forwarded-messages, and dry-run reporting the real remaining countrequired, andPOST /api/keyword-forwardacceptskeyword: nullwithout a validation error (reaches business logic, confirmed via a 503 "not initialized" response rather than a 422)