Skip to content
Snippets Groups Projects
Commit c1ccd6c6 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Prototype for MSC2448

parent d4dac1f8
Branches
Tags
No related merge requests found
......@@ -55,6 +55,8 @@ struct ImageInfo
std::string mimetype;
//! Encryption members. If present, they replace thumbnail_url.
std::optional<crypto::EncryptedFile> thumbnail_file;
//! experimental blurhash, see MSC2448
std::string blurhash;
};
//! Deserialization method needed by @p nlohmann::json.
......@@ -126,6 +128,8 @@ struct VideoInfo
ThumbnailInfo thumbnail_info;
//! Encryption members. If present, they replace thumbnail_url.
std::optional<crypto::EncryptedFile> thumbnail_file;
//! experimental blurhash, see MSC2448
std::string blurhash;
};
//! Deserialization method needed by @p nlohmann::json.
......
......@@ -55,6 +55,9 @@ from_json(const json &obj, ImageInfo &info)
if (obj.find("thumbnail_file") != obj.end())
info.thumbnail_file = obj.at("thumbnail_file").get<crypto::EncryptedFile>();
if (obj.find("xyz.amorgan.blurhash") != obj.end())
info.blurhash = obj.at("xyz.amorgan.blurhash").get<std::string>();
}
void
......@@ -70,6 +73,8 @@ to_json(json &obj, const ImageInfo &info)
}
if (info.thumbnail_file)
obj["thumbnail_file"] = info.thumbnail_file.value();
if (!info.blurhash.empty())
obj["xyz.amorgan.blurhash"] = info.blurhash;
}
void
......@@ -151,6 +156,9 @@ from_json(const json &obj, VideoInfo &info)
if (obj.find("thumbnail_file") != obj.end())
info.thumbnail_file = obj.at("thumbnail_file").get<crypto::EncryptedFile>();
if (obj.find("xyz.amorgan.blurhash") != obj.end())
info.blurhash = obj.at("xyz.amorgan.blurhash").get<std::string>();
}
void
......@@ -160,11 +168,15 @@ to_json(json &obj, const VideoInfo &info)
obj["h"] = info.h;
obj["w"] = info.w;
obj["duration"] = info.duration;
obj["mimetype"] = info.mimetype;
if (!info.thumbnail_url.empty()) {
obj["thumbnail_url"] = info.thumbnail_url;
obj["thumbnail_info"] = info.thumbnail_info;
obj["mimetype"] = info.mimetype;
}
if (info.thumbnail_file)
obj["thumbnail_file"] = info.thumbnail_file.value();
if (!info.blurhash.empty())
obj["xyz.amorgan.blurhash"] = info.blurhash;
}
void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment