2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Apply file type/size restrictions in export.

This commit is contained in:
John Preston
2018-06-17 09:39:03 +01:00
parent df91b2bfeb
commit 8d52ca6be6
5 changed files with 123 additions and 41 deletions

View File

@@ -171,6 +171,13 @@ QByteArray SerializeMessage(
const auto pushAction = [&](const QByteArray &action) {
push("Action", action);
};
const auto pushTTL = [&](
const QByteArray &label = "Self destruct period") {
if (const auto ttl = message.media.ttl) {
push(label, NumberToString(ttl) + " sec.");
}
};
message.action.content.match([&](const ActionChatCreate &data) {
pushActor();
pushAction("Create group");
@@ -299,11 +306,12 @@ QByteArray SerializeMessage(
}
message.media.content.match([&](const Photo &photo) {
pushTTL();
}, [&](const Document &data) {
const auto pushPath = [&](const QByteArray &label) {
push(label, FormatFilePath(data.file));
};
if (!data.stickerEmoji.isEmpty()) {
if (data.isSticker) {
pushPath("Sticker");
push("Emoji", data.stickerEmoji);
} else if (data.isVideoMessage) {
@@ -321,7 +329,7 @@ QByteArray SerializeMessage(
} else {
pushPath("File");
}
if (data.stickerEmoji.isEmpty()) {
if (!data.isSticker) {
push("Mime type", data.mime);
}
if (data.duration) {
@@ -331,6 +339,7 @@ QByteArray SerializeMessage(
push("Width", NumberToString(data.width));
push("Height", NumberToString(data.height));
}
pushTTL();
}, [&](const ContactInfo &data) {
push("Contact information", SerializeKeyValue({
{ "First name", data.firstName },
@@ -342,6 +351,7 @@ QByteArray SerializeMessage(
{ "Latitude", NumberToString(data.latitude) },
{ "Longitude", NumberToString(data.longitude) },
}) : QByteArray("(empty value)"));
pushTTL("Live location period");
}, [&](const Venue &data) {
push("Place name", data.title);
push("Address", data.address);