Repository navigation
fix: archive chat actions with real IDs and capture own-account reactions (#221, #222) - #223
Conversation
… classification (#222) The chat-action classifier's photo-is-None branch swallowed every non-photo action as photo_removed, and rows were written with wall-clock-derived synthetic ids (~2 phantom rows per join/leave). Service rows are now written only when the event carries a real MessageService (real id/date), tagged with the shared sweep vocabulary via service_action_type, with human-readable text generated by a new shared service_message_text helper used by both the listener and the backfill sweep. Participant-only syncs write no message row.
Parse-free LIKE cleanup of the 7 legacy listener action_type names on the TEXT raw_data column (spaced + compact JSON forms, escaped underscores, no id or service_type condition per production forensics). Dependent reactions/media/message_versions rows are deleted explicitly first since the reactions FK has no cascade and SQLite may run without foreign_keys. Invalidates cached_stats AND stats_calculated_at so the viewer recomputes correct counts on next start. Data-only migration: intentionally absent from the entrypoint stamp ladders (documented in both), so alembic upgrade head always runs it.
…ounded resweep (#221) Telegram does not reliably push UpdateMessageReactions for the archive account's own reactions (made from another device) to the archive's session. Close the gap three ways: harvest reaction snapshots carried on edit events and on newly-arriving messages into the shared debounce buffer (min payloads skipped - they omit the current user's own reactions); piggyback reaction reconciliation onto the existing SYNC_DELETIONS_EDITS full-message fetch at zero extra API cost; and add an opt-in bounded re-sweep (REACTION_RESWEEP_DAYS, default off, capped by REACTION_RESWEEP_MAX_PER_CHAT) that re-checks recent messages per chat each scheduled sweep via batched GetMessagesReactionsRequest with a get_messages fallback. Documents the limitation in the README.
|
Warning Review limit reached
Next review available in: 23 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds bounded reaction resweeping and real-time buffering, refactors Telegram service-action persistence and text rendering, validates migration 019 cleanup, and hides database query parameters in engine logs. ChangesReaction recovery
Service-message handling
Migration and database safety
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🐳 Dev images published!
The dev/test instance will pick up these changes automatically (Portainer GitOps). To test locally: docker pull drumsergio/telegram-archive:dev
docker pull drumsergio/telegram-archive-viewer:dev |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #223 +/- ##
==========================================
- Coverage 93.58% 93.50% -0.08%
==========================================
Files 27 27
Lines 7873 8007 +134
==========================================
+ Hits 7368 7487 +119
- Misses 505 520 +15
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tests/test_listener_chat_actions.py (1)
377-409: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAssertions are correct; same
TestCaseinconsistency as above.Logic and assertions for
service_message_textall check out against the implementation. These are sync tests so they run fine under plain pytest, but for consistency apply the sameunittest.TestCaseconversion suggested forTestChatActionHandlerabove.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_listener_chat_actions.py` around lines 377 - 409, Convert TestServiceMessageText to inherit from unittest.TestCase, matching the existing TestChatActionHandler test style. Preserve all current test methods, inputs, and assertions for service_message_text unchanged.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.env.example:
- Around line 195-197: Update the REACTION_RESWEEP_DAYS comment in the
environment example to describe Telegram self-reactions as “not reliably pushed”
rather than “never pushes,” matching the wording used in README.md and runtime
documentation.
In `@docker-compose.yml`:
- Around line 84-85: Uncomment the REACTION_RESWEEP_DAYS and
REACTION_RESWEEP_MAX_PER_CHAT environment entries in the Docker Compose
environment configuration so Compose injects the .env values while retaining
defaults of 0 and 500.
---
Nitpick comments:
In `@tests/test_listener_chat_actions.py`:
- Around line 377-409: Convert TestServiceMessageText to inherit from
unittest.TestCase, matching the existing TestChatActionHandler test style.
Preserve all current test methods, inputs, and assertions for
service_message_text unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2222ba85-b9b7-4b5b-9058-c3ebe4b1dd79
⛔ Files ignored due to path filters (1)
alembic/versions/20260719_019_delete_phantom_chat_action_rows.pyis excluded by!alembic/versions/**
📒 Files selected for processing (16)
.env.exampleREADME.mddocker-compose.ymlscripts/entrypoint.shsrc/config.pysrc/db/adapter.pysrc/listener.pysrc/message_utils.pysrc/telegram_backup.pytests/test_listener_chat_actions.pytests/test_listener_extended.pytests/test_listener_reactions.pytests/test_migration_019.pytests/test_reaction_resweep.pytests/test_telegram_backup.pytests/test_telegram_backup_extended.py
💤 Files with no reviewable changes (1)
- tests/test_listener_extended.py
| # REACTION_RESWEEP_DAYS: ${REACTION_RESWEEP_DAYS:-0} | ||
| # REACTION_RESWEEP_MAX_PER_CHAT: ${REACTION_RESWEEP_MAX_PER_CHAT:-500} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Pass the resweep variables into the container.
These entries are commented out, so Docker Compose will not inject REACTION_RESWEEP_DAYS or REACTION_RESWEEP_MAX_PER_CHAT from .env. src/config.py will silently use 0 and 500, leaving resweeping disabled for .env-based deployments.
- # REACTION_RESWEEP_DAYS: ${REACTION_RESWEEP_DAYS:-0}
- # REACTION_RESWEEP_MAX_PER_CHAT: ${REACTION_RESWEEP_MAX_PER_CHAT:-500}
+ REACTION_RESWEEP_DAYS: ${REACTION_RESWEEP_DAYS:-0}
+ REACTION_RESWEEP_MAX_PER_CHAT: ${REACTION_RESWEEP_MAX_PER_CHAT:-500}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # REACTION_RESWEEP_DAYS: ${REACTION_RESWEEP_DAYS:-0} | |
| # REACTION_RESWEEP_MAX_PER_CHAT: ${REACTION_RESWEEP_MAX_PER_CHAT:-500} | |
| REACTION_RESWEEP_DAYS: ${REACTION_RESWEEP_DAYS:-0} | |
| REACTION_RESWEEP_MAX_PER_CHAT: ${REACTION_RESWEEP_MAX_PER_CHAT:-500} |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docker-compose.yml` around lines 84 - 85, Uncomment the REACTION_RESWEEP_DAYS
and REACTION_RESWEEP_MAX_PER_CHAT environment entries in the Docker Compose
environment configuration so Compose injects the .env values while retaining
defaults of 0 and 500.
…eaction buffer Review-panel fixes: the sweep's synthesized add/kick service texts named the acting admin instead of the affected user — the subject is now resolved from the local users table (API fallback) and degrades to 'Someone', never the wrong name; self-adds read 'joined the group'. Reaction snapshots are buffered through a shared helper that treats a missing reactions object as no-information (never an authoritative empty snapshot) and uses setdefault semantics in the new-message handler, whose awaits opened a window where a fresher live-reaction snapshot could be clobbered (reproduced). DB engines now set hide_parameters so error logs never embed bound values (PII). Stale vocabulary comments updated; regression tests added for all of it.
|
Ran an 8-perspective review panel (logic, architecture, security/PII, simplicity, tests, concurrency, data-integrity, error-handling) over the full diff, with adversarial verification of every critical/high finding. Results, addressed in d06ddc0: Fixed
Declined (with evidence)
Full suite: 2253 passed; ruff clean. Migration re-validated unchanged against the production copy (predicate untouched by this round). |
|
CodeRabbit round addressed:
|
|
🐳 Dev images published!
The dev/test instance will pick up these changes automatically (Portainer GitOps). To test locally: docker pull drumsergio/telegram-archive:dev
docker pull drumsergio/telegram-archive-viewer:dev |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/test_telegram_backup_extended.py (1)
3600-3605: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAdd type hints and reset
reply_toon mocked message.As per path instructions for tests, you must set
msg.reply_to = Nonewhen using mock objects for Telegram messages to prevent false-positive topic filtering. Furthermore, as per coding guidelines, function signatures require type hints.💻 Proposed fix
- def _service_message(self, msg_id, action, *, sender_first, sender_id, text=""): + def _service_message(self, msg_id: int, action: object, *, sender_first: str, sender_id: int, text: str = "") -> object: msg = _make_message(msg_id, text=text) + msg.reply_to = None msg.sender = SimpleNamespace(first_name=sender_first, last_name=None, title=None) msg.sender_id = sender_id msg.action = action return msg🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_telegram_backup_extended.py` around lines 3600 - 3605, Update the test helper _service_message with type hints for its parameters and return value, using the file’s established annotation conventions. Before returning the mocked message, explicitly set msg.reply_to to None so topic filtering cannot produce false positives.Sources: Coding guidelines, Path instructions
🧹 Nitpick comments (1)
tests/test_telegram_backup_extended.py (1)
3607-3608: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd return type hints to test methods.
As per coding guidelines, use type hints for function signatures. Please apply a
-> Nonereturn type hint to this test method and all other test methods in this class.💻 Proposed fix
- def test_empty_service_text_is_generated(self): + def test_empty_service_text_is_generated(self) -> None: msg = self._service_message(700, MessageActionChatJoinedByLink(inviter_id=0), sender_first="Dana", sender_id=55)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_telegram_backup_extended.py` around lines 3607 - 3608, Add the -> None return annotation to test_empty_service_text_is_generated and every other test method in the same test class, leaving their parameters and implementations unchanged.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/test_telegram_backup_extended.py`:
- Around line 3594-3598: Update setUp to configure the mock backup config’s
should_skip_topic attribute as MagicMock(return_value=False), preventing truthy
mock behavior in tests. Add an explicit return type annotation to the setUp
method signature, preserving its existing setup logic.
---
Outside diff comments:
In `@tests/test_telegram_backup_extended.py`:
- Around line 3600-3605: Update the test helper _service_message with type hints
for its parameters and return value, using the file’s established annotation
conventions. Before returning the mocked message, explicitly set msg.reply_to to
None so topic filtering cannot produce false positives.
---
Nitpick comments:
In `@tests/test_telegram_backup_extended.py`:
- Around line 3607-3608: Add the -> None return annotation to
test_empty_service_text_is_generated and every other test method in the same
test class, leaving their parameters and implementations unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8c907233-fea3-4bc2-8935-c38d7e4b460b
⛔ Files ignored due to path filters (1)
alembic/versions/20260719_019_delete_phantom_chat_action_rows.pyis excluded by!alembic/versions/**
📒 Files selected for processing (8)
src/db/base.pysrc/listener.pysrc/message_utils.pysrc/telegram_backup.pytests/test_listener_chat_actions.pytests/test_listener_reactions.pytests/test_reaction_resweep.pytests/test_telegram_backup_extended.py
🚧 Files skipped from review as they are similar to previous changes (6)
- src/message_utils.py
- tests/test_listener_reactions.py
- src/listener.py
- src/telegram_backup.py
- tests/test_reaction_resweep.py
- tests/test_listener_chat_actions.py
| def setUp(self): | ||
| self.backup = _make_backup() | ||
| # Subject resolution defaults: unknown everywhere -> "Someone ..." texts. | ||
| self.backup.db.get_user_by_id = AsyncMock(return_value=None) | ||
| self.backup.client.get_entity = AsyncMock(side_effect=RuntimeError("unavailable")) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Mock should_skip_topic and add a return type hint.
As per path instructions for tests, you must set config.should_skip_topic = MagicMock(return_value=False) on mock configs to prevent false truthiness. Additionally, as per coding guidelines, use type hints for function signatures.
💻 Proposed fix
- def setUp(self):
+ def setUp(self) -> None:
self.backup = _make_backup()
+ self.backup.config.should_skip_topic = MagicMock(return_value=False)
# Subject resolution defaults: unknown everywhere -> "Someone ..." texts.
self.backup.db.get_user_by_id = AsyncMock(return_value=None)
self.backup.client.get_entity = AsyncMock(side_effect=RuntimeError("unavailable"))📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| def setUp(self): | |
| self.backup = _make_backup() | |
| # Subject resolution defaults: unknown everywhere -> "Someone ..." texts. | |
| self.backup.db.get_user_by_id = AsyncMock(return_value=None) | |
| self.backup.client.get_entity = AsyncMock(side_effect=RuntimeError("unavailable")) | |
| def setUp(self) -> None: | |
| self.backup = _make_backup() | |
| self.backup.config.should_skip_topic = MagicMock(return_value=False) | |
| # Subject resolution defaults: unknown everywhere -> "Someone ..." texts. | |
| self.backup.db.get_user_by_id = AsyncMock(return_value=None) | |
| self.backup.client.get_entity = AsyncMock(side_effect=RuntimeError("unavailable")) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tests/test_telegram_backup_extended.py` around lines 3594 - 3598, Update
setUp to configure the mock backup config’s should_skip_topic attribute as
MagicMock(return_value=False), preventing truthy mock behavior in tests. Add an
explicit return type annotation to the setUp method signature, preserving its
existing setup logic.
Sources: Coding guidelines, Path instructions
|
🐳 Dev images published!
The dev/test instance will pick up these changes automatically (Portainer GitOps). To test locally: docker pull drumsergio/telegram-archive:dev
docker pull drumsergio/telegram-archive-viewer:dev |
1 similar comment
|
🐳 Dev images published!
The dev/test instance will pick up these changes automatically (Portainer GitOps). To test locally: docker pull drumsergio/telegram-archive:dev
docker pull drumsergio/telegram-archive-viewer:dev |
…ions (#221, #222) (#223) * fix(listener): archive chat actions with real message ids and correct classification (#222) The chat-action classifier's photo-is-None branch swallowed every non-photo action as photo_removed, and rows were written with wall-clock-derived synthetic ids (~2 phantom rows per join/leave). Service rows are now written only when the event carries a real MessageService (real id/date), tagged with the shared sweep vocabulary via service_action_type, with human-readable text generated by a new shared service_message_text helper used by both the listener and the backfill sweep. Participant-only syncs write no message row. * fix(db): migration 019 purges phantom chat-action rows (#222) Parse-free LIKE cleanup of the 7 legacy listener action_type names on the TEXT raw_data column (spaced + compact JSON forms, escaped underscores, no id or service_type condition per production forensics). Dependent reactions/media/message_versions rows are deleted explicitly first since the reactions FK has no cascade and SQLite may run without foreign_keys. Invalidates cached_stats AND stats_calculated_at so the viewer recomputes correct counts on next start. Data-only migration: intentionally absent from the entrypoint stamp ladders (documented in both), so alembic upgrade head always runs it. * feat(reactions): capture own-account reactions via edit harvest and bounded resweep (#221) Telegram does not reliably push UpdateMessageReactions for the archive account's own reactions (made from another device) to the archive's session. Close the gap three ways: harvest reaction snapshots carried on edit events and on newly-arriving messages into the shared debounce buffer (min payloads skipped - they omit the current user's own reactions); piggyback reaction reconciliation onto the existing SYNC_DELETIONS_EDITS full-message fetch at zero extra API cost; and add an opt-in bounded re-sweep (REACTION_RESWEEP_DAYS, default off, capped by REACTION_RESWEEP_MAX_PER_CHAT) that re-checks recent messages per chat each scheduled sweep via batched GetMessagesReactionsRequest with a get_messages fallback. Documents the limitation in the README. * fix(review): name the affected user in service texts and harden the reaction buffer Review-panel fixes: the sweep's synthesized add/kick service texts named the acting admin instead of the affected user — the subject is now resolved from the local users table (API fallback) and degrades to 'Someone', never the wrong name; self-adds read 'joined the group'. Reaction snapshots are buffered through a shared helper that treats a missing reactions object as no-information (never an authoritative empty snapshot) and uses setdefault semantics in the new-message handler, whose awaits opened a window where a fresher live-reaction snapshot could be clobbered (reproduced). DB engines now set hide_parameters so error logs never embed bound values (PII). Stale vocabulary comments updated; regression tests added for all of it. * docs(env): soften self-reaction wording per review * chore: bump version to 7.24.0
…ions (#221, #222) (#223) * fix(listener): archive chat actions with real message ids and correct classification (#222) The chat-action classifier's photo-is-None branch swallowed every non-photo action as photo_removed, and rows were written with wall-clock-derived synthetic ids (~2 phantom rows per join/leave). Service rows are now written only when the event carries a real MessageService (real id/date), tagged with the shared sweep vocabulary via service_action_type, with human-readable text generated by a new shared service_message_text helper used by both the listener and the backfill sweep. Participant-only syncs write no message row. * fix(db): migration 019 purges phantom chat-action rows (#222) Parse-free LIKE cleanup of the 7 legacy listener action_type names on the TEXT raw_data column (spaced + compact JSON forms, escaped underscores, no id or service_type condition per production forensics). Dependent reactions/media/message_versions rows are deleted explicitly first since the reactions FK has no cascade and SQLite may run without foreign_keys. Invalidates cached_stats AND stats_calculated_at so the viewer recomputes correct counts on next start. Data-only migration: intentionally absent from the entrypoint stamp ladders (documented in both), so alembic upgrade head always runs it. * feat(reactions): capture own-account reactions via edit harvest and bounded resweep (#221) Telegram does not reliably push UpdateMessageReactions for the archive account's own reactions (made from another device) to the archive's session. Close the gap three ways: harvest reaction snapshots carried on edit events and on newly-arriving messages into the shared debounce buffer (min payloads skipped - they omit the current user's own reactions); piggyback reaction reconciliation onto the existing SYNC_DELETIONS_EDITS full-message fetch at zero extra API cost; and add an opt-in bounded re-sweep (REACTION_RESWEEP_DAYS, default off, capped by REACTION_RESWEEP_MAX_PER_CHAT) that re-checks recent messages per chat each scheduled sweep via batched GetMessagesReactionsRequest with a get_messages fallback. Documents the limitation in the README. * fix(review): name the affected user in service texts and harden the reaction buffer Review-panel fixes: the sweep's synthesized add/kick service texts named the acting admin instead of the affected user — the subject is now resolved from the local users table (API fallback) and degrades to 'Someone', never the wrong name; self-adds read 'joined the group'. Reaction snapshots are buffered through a shared helper that treats a missing reactions object as no-information (never an authoritative empty snapshot) and uses setdefault semantics in the new-message handler, whose awaits opened a window where a fresher live-reaction snapshot could be clobbered (reproduced). DB engines now set hide_parameters so error logs never embed bound values (PII). Stale vocabulary comments updated; regression tests added for all of it. * docs(env): soften self-reaction wording per review * chore: bump version to 7.24.0
Fixes #221 and #222.
#222 — phantom chat-action rows with fabricated IDs
Root cause (present in every release v5.3.1 → v7.23.0):
on_chat_actionclassifier's second branch (photo is None and not new_photo) was a catch-all that labeled every non-photo chat action (joins, leaves, title changes) asphoto_removed— theuser_joined/user_left/user_added/user_kicked/title_changedbranches were dead code (0 rows with those labels exist across 2.95M messages in two production DBs). Genuine photo removals were misclassified asphoto_changed.-int(time.time() * 1000) % 2147483647— a positive 31-bit value that decrements 1/ms and wraps every ~24.8 days, interleaving real message IDs (production forensics found fabricated IDs as low as 22M in chats whose real IDs are in the hundreds). One join produces ~2 ChatAction events (Telethon builds one fromUpdateChatParticipantAddand one from theMessageService, dispatched as parallel tasks), hence ~2 phantom rows per join.The fix:
MessageService(event.action_message), using its realid/date/sender, classified via the sharedservice_action_type()sweep vocabulary. Participant-only sync updates (no service message) write no row — matching Telegram's own UI.events.NewMessageskipsMessageService, so this handler remains the only real-time source of service rows.new_photo=True, photo=None→ removed;photo=Photo→ changed.service_message_text()helper generates the human-readable text for both the listener and the scheduled sweep (sweep-archived service rows previously stored empty text and rendered as blank pills).LIKEmatching of the 7 legacyaction_typenames on the TEXTraw_datacolumn (both JSON serialization eras, escaped underscores, no id/service_type conditions — forensics found real phantoms with low IDs and without theservice_typekey). Dependentreactions/media/message_versionsrows are deleted explicitly first (the reactions FK has no cascade). Invalidatescached_stats+stats_calculated_atso the viewer recomputes correct counts immediately on next start. Data-only migration: intentionally absent from the entrypoint stamp ladders (documented there) soalembic upgrade headalways runs it; naturally idempotent. Validated against a full copy of a production DB: deletes exactly the 422 forensically-confirmed phantoms out of 1.78M rows.#221 — reactions by the archive's own account never captured live
Telegram does not reliably push
UpdateMessageReactionsto the archive's session for reactions made by the same account from another device. Mitigations, all preserving the #220 aggregate-only model:edit_date(the [Bug]: **Title:** Reactions are only captured by the scheduled backup, never by the real-time listener #219 phantom-edit guard is untouched).minpayloads are skipped (documented to omit the current user's own reactions — reconciling one could falsely tombstone a just-added self-reaction). New messages arriving with reactions attached are harvested the same way.REACTION_RESWEEP_DAYS=Nre-checks the last N days of messages per chat on every scheduled sweep via batchedmessages.getMessagesReactions(100 ids/request,get_messagesfallback for rejected chunks), capped byREACTION_RESWEEP_MAX_PER_CHAT(default 500 ≈ 5 requests/chat/sweep). Default0(disabled). Only ids echoed back are reconciled — absence is never treated as "zero reactions".SYNC_DELETIONS_EDITS=truealready fetches full messages and discarded their reactions; they are now reconciled at zero extra API cost.Testing
ruff check+ruff format --checkclean.Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests
Chores