| 2089 | } |
| 2090 | |
| 2091 | std::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 | |
| 2127 | bool ApiWrap::messageCustomEmojiReady(Data::Message &message) { |
| 2128 | for (auto &part : message.text) { |
nothing calls this directly
no test coverage detected