Skip to content

fix(download): only return a message from the requested chat - #290

Open
ApexAiOfficial wants to merge 2 commits into
gotd:mainfrom
ApexAiOfficial:up/get-message-chat-scope
Open

ApexAiOfficial wants to merge 2 commits into
gotd:mainfrom
ApexAiOfficial:up/get-message-chat-scope

Conversation

@ApexAiOfficial

@ApexAiOfficial ApexAiOfficial commented Oct 18, 2026 •

Copy link
Copy Markdown

For users and basic groups getMessage calls messages.getMessages, which looks an id up across all of the account's private chats and basic groups: it isn't scoped to the peer. So tg download @alice 123, tg download me 123 and tg reactions could act on message 123 of a different chat.

The returned message must now belong to the requested chat:

  • Users and basic groups: the message's peer id must match.
  • Saved Messages (me): the response must mark the message's user as the current user (Self), so no extra RPC is needed.
  • Channels: channels.getMessages was already scoped.

Tests cover another chat, the same chat, and Saved Messages versus another private chat. go test -race and golangci-lint v2.12.1 (Go 1.25) pass.

🤖 Generated with Claude Code

ApexAiOfficial and others added 2 commits October 18, 2026 08:52
For users and basic groups getMessage calls messages.getMessages, which looks
an id up across all of the account's private chats and basic groups: it is
not scoped to the peer. `tg download @alice 123` (and `tg reactions`) could
therefore act on message 123 of a different chat. Check that the returned
message belongs to the requested peer; channel lookups were already scoped,
and Saved Messages (self) is left unchecked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The chat check skipped "me", so `tg download me 123` still returned
message 123 of whichever private chat or basic group held that id. A Saved
Messages hit is accepted only when the response marks the message's user as
the current user, without an extra RPC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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