Skip to content

Delete events without chat context can skip valid deletions #7

Closed

Description

@neoromantic

Telegram sends some delete updates (private chats and basic groups) with message IDs only, no chat ID. When the same message ID exists in more than one cached chat, the daemon can't tell which message was deleted and may skip a valid deletion. Find a safe way to resolve these (for example, by tracking the per-account message ID space) and add tests.

Activity

  1. neoromantic commented on Oct 21, 2026

    @neoromantic
    OwnerAuthor

    Checked on 2026-10-21: onDeleteMessage in src/daemon/daemon-accounts.ts looks the ID up across every cached chat, channels included, and silently skips the delete when more than one chat has it (src/db/messages-cache.ts).

    Private chats and basic groups share one message-ID sequence per account. Once the cache is per account (#17), excluding channel IDs makes the match unique. The lookup also needs an index on message_id: today it scans the whole table.

  2. added
    bug
    on Oct 21, 2026
  3. neoromantic commented on Oct 21, 2026

    @neoromantic
    OwnerAuthor

    With #59 (#17) each account has its own cache, and a delete update lands only in the cache of the account that received it. So a delete without chat context no longer touches another account's message with the same ID; that part is covered by a test in daemon-accounts.connect.test.ts.

    What remains inside one account: the lookup in src/db/messages-cache.ts still matches the ID across every cached chat of that account, channels included, skips the delete when more than one chat has it, and scans the table without an index on message_id. Private chats and basic groups share one message-ID sequence per account, so excluding channel chat IDs (-100…) from the match should make it unique; that and the index are still to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions