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

Method resolveCustomEmoji

Telegram/SourceFiles/export/export_api_wrap.cpp:2017–2065  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2015}
2016
2017void ApiWrap::resolveCustomEmoji() {
2018 if (_unresolvedCustomEmoji.empty()) {
2019 loadNextMessageFile();
2020 return;
2021 }
2022 const auto count = std::min(
2023 int(_unresolvedCustomEmoji.size()),
2024 kMaxEmojiPerRequest);
2025 auto v = QVector<MTPlong>();
2026 v.reserve(count);
2027 const auto till = end(_unresolvedCustomEmoji);
2028 const auto from = end(_unresolvedCustomEmoji) - count;
2029 for (auto i = from; i != till; ++i) {
2030 v.push_back(MTP_long(*i));
2031 }
2032 _unresolvedCustomEmoji.erase(from, till);
2033 const auto finalize = [=] {
2034 for (const auto &id : v) {
2035 if (_resolvedCustomEmoji.contains(id.v)) {
2036 continue;
2037 }
2038 _resolvedCustomEmoji.emplace(
2039 id.v,
2040 Data::Document{
2041 .file = {
2042 .skipReason = Data::File::SkipReason::Unavailable,
2043 },
2044 });
2045 }
2046 resolveCustomEmoji();
2047 };
2048 mainRequest(MTPmessages_GetCustomEmojiDocuments(
2049 MTP_vector<MTPlong>(v)
2050 )).fail([=](const MTP::Error &error) {
2051 LOG(("Export Error: Failed to get documents for emoji."));
2052 finalize();
2053 return true;
2054 }).done([=](const MTPVector<MTPDocument> &result) {
2055 for (const auto &entry : result.v) {
2056 auto document = Data::ParseDocument(
2057 _chatProcess->context,
2058 entry,
2059 _chatProcess->info.relativePath,
2060 TimeId());
2061 _resolvedCustomEmoji.emplace(document.id, std::move(document));
2062 }
2063 finalize();
2064 }).send();
2065}
2066
2067Data::Message *ApiWrap::currentFileMessage() const {
2068 Expects(_chatProcess != nullptr);

Callers

nothing calls this directly

Calls 10

MTP_longFunction · 0.85
ParseDocumentFunction · 0.85
emplaceMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45
containsMethod · 0.45
sendMethod · 0.45
doneMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected