Debian Codegraph @

mtxclient/include/mtx/responses/media.hpp

raw symbols SCIP
1 #pragma once
2
3 /// @file
4 /// @brief Responses returned by the media repo.
5
6 #if __has_include(<nlohmann/json_fwd.hpp>)
7 #include <nlohmann/json_fwd.hpp>
8 #else
9 #include <nlohmann/json.hpp>
10 #endif
11
12 #include <optional>
13 #include <string>
14
15 namespace mtx {
16 namespace responses {
17
18 //! Represents the response of `POST /_matrix/media/r0/upload`
19 struct ContentURI
20 {
21 //! The MXC URI for the uploaded content.
22 std::string content_uri;
23
24 friend void from_json(const nlohmann::json &obj, ContentURI &response);
25 };
26
27 // The json response is returned as prefixed fields (e.g. og:image:alt), not objects, so from_json
28 // would be impractical
29 //! Represents an OpenGraph og:image
30 struct OGImage
31 {
32 //! MIME type of the media
33 std::optional<std::string> type;
34 //! The number of pixels wide
35 std::optional<std::int32_t> width;
36 //! The number of pixels high
37 std::optional<std::int32_t> height;
38 //! A description of the media
39 std::optional<std::string> alt;
40 //! mxc:// URI of the media
41 std::string url;
42 //! Byte size of the og:image
43 std::uint64_t size;
44 };
45
46 //! Represents the response of `GET /_matrix/media/v3/preview_url`, see https://ogp.me
47 struct URLPreview
48 {
49 //! og:title
50 std::string title;
51 //! og:url
52 std::string url;
53 //! Structure containing og:image and related fields
54 OGImage image;
55
56 //! og:description
57 std::optional<std::string> description;
58 //! og:site_name
59 std::optional<std::string> site_name;
60
61 friend void from_json(const nlohmann::json &obj, URLPreview &response);
62 };
63 }
64 }