Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export plaintext message content in JSON text field #26295

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions Telegram/SourceFiles/export/output/export_output_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ QByteArray SerializeText(
const auto text = ranges::views::all(
data
) | ranges::views::transform([&](const Data::TextPart &part) {
if ((part.type == Type::Text) && !serializeToObjects) {
return SerializeString(part.text);
}
const auto typeString = [&] {
switch (part.type) {
case Type::Unknown: return "unknown";
Expand All @@ -187,6 +184,10 @@ QByteArray SerializeText(
}
Unexpected("Type in SerializeText.");
}();
if (!serializeToObjects) {
return SerializeString(part.text);
}

const auto additionalName = (part.type == Type::MentionName)
? "user_id"
: (part.type == Type::CustomEmoji)
Expand All @@ -213,9 +214,14 @@ QByteArray SerializeText(
context.nesting.pop_back();

if (!serializeToObjects) {
if (data.size() == 1 && data[0].type == Data::TextPart::Type::Text) {
return text[0];
auto result = QByteArray();
result.append('"');
for (const auto &part : text) {
result.append(part.mid(1, part.size() - 2));
}
result.append('"');
return result;

}
return SerializeArray(context, text);
}
Expand Down