fix: honor date range in chat/topic export, skip pre-from history#30612
Open
Tym-arch wants to merge 1 commit into
Open
fix: honor date range in chat/topic export, skip pre-from history#30612Tym-arch wants to merge 1 commit into
Tym-arch wants to merge 1 commit into
Conversation
Approach A (GetHistory-based): probe-then-paginate skip-ahead via offset_date, till-stop in slice handler, applied to chat + topic paths. Closes telegramdesktop#30412, telegramdesktop#25139.
Collaborator
|
Two issues I hit while testing:
|
23rd
reviewed
May 3, 2026
|
|
||
| 6.7.7 beta (20.04.26) | ||
|
|
||
| - Honor date range when exporting chat history (no full scan). |
Collaborator
There was a problem hiding this comment.
Suggested change
| - Honor date range when exporting chat history (no full scan). |
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.
Summary
Fixes the export-date-range bug reported in #30412 and #25139: selecting a date range in Export chat history causes the client to fetch the entire chat history from the oldest message before producing output. The date range is currently only applied at write time via
SkipMessageByDate, so on large channels (millions of msgs) the export appears stuck for hours and consumes massive bandwidth even when the user only wants a few days of msgs.This PR adds server-side skip-ahead so only msgs in the requested
[singlePeerFrom, singlePeerTill)range are ever transferred.Approach (canonical, GetHistory-based)
offsetDateparameter threaded throughrequestChatMessages→MTPmessages_GetHistory. All call sites updated. Default0preserves prior behavior.requestMessagesSlice: whenlargestIdPlusOne == 1andsinglePeerFrom > 0, fires a singlegetHistory(offset_id=0, offset_date=singlePeerFrom-1, add_offset=-1, limit=1)to find the first msg id at-or-aftersinglePeerFrom. SetslargestIdPlusOne = result.idand re-enters slice fetching from there. Mirrors the canonical pattern atapiwrap.cpp:3088(requestMessageAfterDate).slice.list.back().date >= singlePeerTill, setslastSlice = trueto terminate the split early instead of paginating to its end.SingleMessageAfter > date→>= dateinexport_data_types.cpp— splits whose latest msg date equalssinglePeerFromexactly were being skipped erroneously by the existing pre-iteration filter.requestTopicReplies/requestTopicMessagesSlice/finishTopicMessagesSlice(the date-range UI surfaces for topic exports too, perexport_view_settings.cpp:268-271).loadNextMessageFileSkipMessageByDate added so the file loader respects the date filter on topic msgs.onlyMyMessagesSearch fallback (kicked-from-channel mid-export) now passesmin_date = singlePeerFromandmax_date = (singlePeerTill > 0 ? singlePeerTill - 1 : 0)for correct inclusive-lower / exclusive-upper boundaries matchingSkipMessageByDate.Network savings
getHistoryper 100-msg batch across all msgs)~1000× reduction in request volume for the typical narrow-range case.
Backwards compatibility
offsetDateparameter defaults to0at every existing call site → unchanged behavior when no date range is set.onlyMyMessagesSearch, CHANNEL_PRIVATE fallback, migrated supergroup splits via negativesplitIndex) are preserved.Test plan
centos_envDocker image (CONFIG=Release, GCC 15) — clean build, 393 MB binary.Fixes #30412
Fixes #25139