feat(query): add GetMessages by-id helper#1752
Merged
Merged
Conversation
Add messages.QueryBuilder.GetMessages to fetch messages by their IDs in a peer. It automatically routes to channels.getMessages for channel peers and messages.getMessages otherwise, sparing callers the common footgun of passing channel message IDs to messages.getMessages (which returns unrelated messages). Closes #217 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts: # ISSUES.md
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1752 +/- ##
==========================================
- Coverage 71.10% 71.10% -0.01%
==========================================
Files 470 471 +1
Lines 20736 20746 +10
==========================================
+ Hits 14745 14751 +6
- Misses 4913 4917 +4
Partials 1078 1078 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What
Adds
messages.QueryBuilder.GetMessages(ctx, peer, ids...)— a helper to fetch messages by their IDs, addressing the get-by-id helpers request in #217.It automatically routes to
channels.getMessagesfor channel peers andmessages.getMessagesotherwise. This spares callers a well-known footgun: passing channel message IDs tomessages.getMessagessilently returns unrelated messages instead of the requested ones. The returned[]tg.MessageClasspreserves the raw server response, includingtg.MessageEmptyfor IDs that don't exist or are inaccessible.The helper reuses the existing channel-aware private
getMessages(added alongsideGetMediaGroup), so routing logic stays in one place.Scope
#217 also mentions optional ETag/hash-based caching as a "nice to have" — that is intentionally left out here, and user/channel get-by-id is already served by
telegram/peers. This PR fills the missing messages-by-id helper.Tests
TestGetMessages(tgmock): user path assertsmessages.getMessageswith the expectedInputMessageIDlist; channel path assertschannels.getMessageswith the resolvedInputChannelaccess hash; empty-ids returns an error.Closes #217
🤖 Generated with Claude Code