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

Method getCustomEmoji

Telegram/SourceFiles/export/export_api_wrap.cpp:2091–2125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2089}
2090
2091std::optional<QByteArray> ApiWrap::getCustomEmoji(QByteArray &data) {
2092 if (const auto id = data.toULongLong()) {
2093 const auto i = _resolvedCustomEmoji.find(id);
2094 if (i == end(_resolvedCustomEmoji)) {
2095 return Data::TextPart::UnavailableEmoji();
2096 }
2097 auto &file = i->second.file;
2098 const auto fileProgress = [=](FileProgress value) {
2099 if (_chatProcess) {
2100 return loadMessageEmojiProgress(value);
2101 } else if (_topicProcess) {
2102 return loadTopicEmojiProgress(value);
2103 }
2104 return true;
2105 };
2106 const auto ready = processFileLoad(
2107 file,
2108 { .customEmojiId = id },
2109 fileProgress,
2110 [=](const QString &path) { loadCustomEmojiDone(id, path); });
2111 if (!ready) {
2112 return std::nullopt;
2113 }
2114 using SkipReason = Data::File::SkipReason;
2115 if (file.skipReason == SkipReason::Unavailable) {
2116 return Data::TextPart::UnavailableEmoji();
2117 } else if (file.skipReason == SkipReason::FileType
2118 || file.skipReason == SkipReason::FileSize) {
2119 return QByteArray();
2120 } else {
2121 return file.relativePath.toUtf8();
2122 }
2123 }
2124 return data;
2125}
2126
2127bool ApiWrap::messageCustomEmojiReady(Data::Message &message) {
2128 for (auto &part : message.text) {

Callers

nothing calls this directly

Calls 2

QByteArrayClass · 0.85
findMethod · 0.45

Tested by

no test coverage detected