mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Add reactions to export chat history (#28252)
Co-authored-by: 23rd <23rd@vivaldi.net>
This commit is contained in:
@@ -1726,6 +1726,15 @@ void ApiWrap::collectMessagesCustomEmoji(const Data::MessagesSlice &slice) {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const auto &reaction : message.reactions) {
|
||||
if (reaction.type == Data::Reaction::Type::CustomEmoji) {
|
||||
if (const auto id = reaction.documentId.toULongLong()) {
|
||||
if (!_resolvedCustomEmoji.contains(id)) {
|
||||
_unresolvedCustomEmoji.emplace(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1803,38 +1812,57 @@ Data::FileOrigin ApiWrap::currentFileMessageOrigin() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<QByteArray> ApiWrap::getCustomEmoji(QByteArray &data) {
|
||||
if (const auto id = data.toULongLong()) {
|
||||
const auto i = _resolvedCustomEmoji.find(id);
|
||||
if (i == end(_resolvedCustomEmoji)) {
|
||||
return Data::TextPart::UnavailableEmoji();
|
||||
}
|
||||
auto &file = i->second.file;
|
||||
const auto fileProgress = [=](FileProgress value) {
|
||||
return loadMessageEmojiProgress(value);
|
||||
};
|
||||
const auto ready = processFileLoad(
|
||||
file,
|
||||
{ .customEmojiId = id },
|
||||
fileProgress,
|
||||
[=](const QString &path) {
|
||||
loadMessageEmojiDone(id, path);
|
||||
});
|
||||
if (!ready) {
|
||||
return std::nullopt;
|
||||
}
|
||||
using SkipReason = Data::File::SkipReason;
|
||||
if (file.skipReason == SkipReason::Unavailable) {
|
||||
return Data::TextPart::UnavailableEmoji();
|
||||
} else if (file.skipReason == SkipReason::FileType
|
||||
|| file.skipReason == SkipReason::FileSize) {
|
||||
return QByteArray();
|
||||
} else {
|
||||
return file.relativePath.toUtf8();
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
bool ApiWrap::messageCustomEmojiReady(Data::Message &message) {
|
||||
for (auto &part : message.text) {
|
||||
if (part.type == Data::TextPart::Type::CustomEmoji) {
|
||||
if (const auto id = part.additional.toULongLong()) {
|
||||
const auto i = _resolvedCustomEmoji.find(id);
|
||||
if (i == end(_resolvedCustomEmoji)) {
|
||||
part.additional = Data::TextPart::UnavailableEmoji();
|
||||
} else {
|
||||
auto &file = i->second.file;
|
||||
const auto fileProgress = [=](FileProgress value) {
|
||||
return loadMessageEmojiProgress(value);
|
||||
};
|
||||
const auto ready = processFileLoad(
|
||||
file,
|
||||
{ .customEmojiId = id },
|
||||
fileProgress,
|
||||
[=](const QString &path) {
|
||||
loadMessageEmojiDone(id, path);
|
||||
});
|
||||
if (!ready) {
|
||||
return false;
|
||||
}
|
||||
using SkipReason = Data::File::SkipReason;
|
||||
if (file.skipReason == SkipReason::Unavailable) {
|
||||
part.additional = Data::TextPart::UnavailableEmoji();
|
||||
} else if (file.skipReason == SkipReason::FileType
|
||||
|| file.skipReason == SkipReason::FileSize) {
|
||||
part.additional = QByteArray();
|
||||
} else {
|
||||
part.additional = file.relativePath.toUtf8();
|
||||
}
|
||||
}
|
||||
auto data = getCustomEmoji(part.additional);
|
||||
if (data.has_value()) {
|
||||
part.additional = *data;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto &reaction : message.reactions) {
|
||||
if (reaction.type == Data::Reaction::Type::CustomEmoji) {
|
||||
auto data = getCustomEmoji(reaction.documentId);
|
||||
if (data.has_value()) {
|
||||
reaction.documentId = *data;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user