Skip to content

telegramMessages: add Chat, Chat ID, and Thread ID columns#1623

Merged
abrignoni merged 3 commits into
mainfrom
telegram-chat-thread-id
Jun 26, 2026
Merged

telegramMessages: add Chat, Chat ID, and Thread ID columns#1623
abrignoni merged 3 commits into
mainfrom
telegram-chat-thread-id

Conversation

@abrignoni

Copy link
Copy Markdown
Owner

What

Adds three columns to the Telegram Messages report:

Column Source Notes
Chat peer_str(idx.peerId) Resolved conversation name → Name (@handle id), same resolver used for Author ID / Forward From
Chat ID raw idx.peerId Numeric peer/chat id, for sorting, grouping, and correlating across artifacts
Thread ID MessageDataFlags.ThreadId field Forum-topic / discussion-thread id; blank when the message isn't threaded

Why

The message key in the t7 table already decodes to a MessageIndex whose peerId is the chat the message belongs to — which is distinct from the sender shown in the existing Author ID column (in a group they differ). That value was decoded but never surfaced. Likewise, the intermediate-message parser already read the ThreadId field off the wire and discarded it:

if MessageDataFlags.ThreadId in dataFlags:
    buf.read_int64()   # before: read but thrown away

Capturing threadId only stores the int64 that was already being consumed, so no parse offsets change — decode behavior is identical, the value is just no longer dropped.

Lint

CI's lint-changed-files runs pylint with --disable=C,R and no --exit-zero/--fail-under, so any W/E fails the job, and this file carried pre-existing debt (9.24/10). Cleared it as part of the change (unused import/vars/args, generic raise ExceptionValueError in decoder internals, dynamic-setattr attribute declarations for no-member, two bad-indentation lines). Now 10.00/10; header/row width verified 11/11.

The message key (t7) already decodes to a MessageIndex whose peerId is the
chat/conversation the message belongs to (distinct from the sender shown in
'Author ID'), and the intermediate-message parser already reads the ThreadId
field off the wire but discarded it. Surface both:

- Chat      : resolved peer name via peer_str(idx.peerId) -> 'Name (@handle id)'
- Chat ID   : raw numeric peerId, for sorting/pivoting/correlation
- Thread ID : forum-topic / discussion thread id (blank when not threaded)

Capturing threadId only stores the int64 that was already being consumed, so
no parse offsets change. Also cleared this file's pre-existing pylint debt
(unused import/vars/args, generic raise->ValueError, dynamic-attr declarations,
bad-indentation) so the CI lint-changed-files gate passes (10.00/10).
…ner id

- Reorder columns for readability: Timestamp, Chat, Chat ID, Thread ID,
  Direction, Author ID, Text, Action Data, Thumbnail, Forward From,
  Forward Timestamp. Groups conversation identity together and trails the
  usually-empty Forward columns so the dense columns stay left.
- peer_str: replace alarming 'WARN: UNK NAME' / 'unknown peer N' with a
  neutral 'Unknown (id)' for unresolved peers.
- Document in the description that an Outgoing message's Author ID is the
  account owner, so the device owner's Telegram id is recoverable from any
  Outgoing row.
Mirror the Chat / Chat ID treatment for the sender: keep the resolved
'Author' name column and add a numeric 'Author ID' = raw authorId (the
sender's Telegram user id; blank when absent). On Outgoing messages this is
the account owner's id. New order: ... Direction, Author, Author ID, Text ...
@abrignoni abrignoni merged commit 983802a into main Jun 26, 2026
1 check passed
@abrignoni abrignoni deleted the telegram-chat-thread-id branch June 26, 2026 17:43
@abrignoni abrignoni mentioned this pull request Jun 26, 2026
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