MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / requestChatMessages

Method requestChatMessages

Telegram/SourceFiles/export/export_api_wrap.cpp:1902–1977  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1900}
1901
1902void ApiWrap::requestChatMessages(
1903 int splitIndex,
1904 int offsetId,
1905 int addOffset,
1906 int limit,
1907 FnMut<void(MTPmessages_Messages&&)> done) {
1908 Expects(_chatProcess != nullptr);
1909
1910 _chatProcess->requestDone = std::move(done);
1911 const auto doneHandler = [=](MTPmessages_Messages &&result) {
1912 Expects(_chatProcess != nullptr);
1913
1914 base::take(_chatProcess->requestDone)(std::move(result));
1915 };
1916 const auto splitsCount = int(_splits.size());
1917 const auto realPeerInput = (splitIndex >= 0)
1918 ? _chatProcess->info.input
1919 : _chatProcess->info.migratedFromInput;
1920 const auto outgoingInput = _chatProcess->info.isMonoforum
1921 ? _chatProcess->info.monoforumBroadcastInput
1922 : MTP_inputPeerSelf();
1923 const auto realSplitIndex = (splitIndex >= 0)
1924 ? splitIndex
1925 : (splitsCount + splitIndex);
1926 if (_chatProcess->info.onlyMyMessages) {
1927 splitRequest(realSplitIndex, MTPmessages_Search(
1928 MTP_flags(MTPmessages_Search::Flag::f_from_id),
1929 realPeerInput,
1930 MTP_string(), // query
1931 outgoingInput,
1932 MTPInputPeer(), // saved_peer_id
1933 MTPVector<MTPReaction>(), // saved_reaction
1934 MTPint(), // top_msg_id
1935 MTP_inputMessagesFilterEmpty(),
1936 MTP_int(0), // min_date
1937 MTP_int(0), // max_date
1938 MTP_int(offsetId),
1939 MTP_int(addOffset),
1940 MTP_int(limit),
1941 MTP_int(0), // max_id
1942 MTP_int(0), // min_id
1943 MTP_long(0) // hash
1944 )).done(doneHandler).send();
1945 } else {
1946 splitRequest(realSplitIndex, MTPmessages_GetHistory(
1947 realPeerInput,
1948 MTP_int(offsetId),
1949 MTP_int(0), // offset_date
1950 MTP_int(addOffset),
1951 MTP_int(limit),
1952 MTP_int(0), // max_id
1953 MTP_int(0), // min_id
1954 MTP_long(0) // hash
1955 )).fail([=](const MTP::Error &error) {
1956 Expects(_chatProcess != nullptr);
1957
1958 if (error.type() == u"CHANNEL_PRIVATE"_q) {
1959 if (realPeerInput.type() == mtpc_inputPeerChannel

Callers

nothing calls this directly

Calls 9

MTP_flagsFunction · 0.85
MTP_stringFunction · 0.85
MTP_longFunction · 0.85
MTP_intFunction · 0.50
sizeMethod · 0.45
sendMethod · 0.45
doneMethod · 0.45
failMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected