| 1 | #pragma once |
| 2 | |
| 3 | /// @file |
| 4 | /// @brief Images sent in a room. |
| 5 | |
| 6 | #include <optional> |
| 7 | #include <string> |
| 8 | |
| 9 | #if __has_include(<nlohmann/json_fwd.hpp>) |
| 10 | #include <nlohmann/json_fwd.hpp> |
| 11 | #else |
| 12 | #include <nlohmann/json.hpp> |
| 13 | #endif |
| 14 | |
| 15 | #include "mtx/common.hpp" |
| 16 | #include "mtx/events/common.hpp" |
| 17 | |
| 18 | namespace mtx { |
| 19 | namespace events { |
| 20 | namespace msg { |
| 21 | |
| 22 | //! Content of `m.room.message` with msgtype `m.image`. |
| 23 | struct Image |
| 24 | { |
| 25 | //! A textual representation of the image. This could be |
| 26 | //! the alt text of the image, the filename of the image, |
| 27 | //! or some kind of content description for accessibility e.g. 'image attachment |
| 28 | std::string body; |
| 29 | //! Must be 'm.image'. |
| 30 | std::string msgtype; |
| 31 | //! The Matrix URL to the image. |
| 32 | std::string url; |
| 33 | //! Metadata about the image referred to in `url`. |
| 34 | mtx::common::ImageInfo info; |
| 35 | //! Encryption members. If present, they replace url. |
| 36 | std::optional<crypto::EncryptedFile> file; |
| 37 | //! Relates to for rich replies |
| 38 | mtx::common::Relations relations; |
| 39 | |
| 40 | friend void from_json(const nlohmann::json &obj, Image &content); |
| 41 | friend void to_json(nlohmann::json &obj, const Image &content); |
| 42 | }; |
| 43 | |
| 44 | //! Content of `m.sticker`. |
| 45 | struct StickerImage |
| 46 | { |
| 47 | //! A textual representation of the image. This could be |
| 48 | //! the alt text of the image, the filename of the image, |
| 49 | //! or some kind of content description for accessibility e.g. 'image attachment |
| 50 | std::string body; |
| 51 | //! The Matrix URL to the image. |
| 52 | std::string url; |
| 53 | //! Metadata about the image referred to in `url`. |
| 54 | mtx::common::ImageInfo info; |
| 55 | //! Encryption members. If present, they replace url. |
| 56 | std::optional<crypto::EncryptedFile> file; |
| 57 | //! Relates to for rich replies |
| 58 | mtx::common::Relations relations; |
| 59 | |
| 60 | friend void from_json(const nlohmann::json &obj, StickerImage &content); |
| 61 | friend void to_json(nlohmann::json &obj, const StickerImage &content); |
| 62 | }; |
| 63 | |
| 64 | } // namespace msg |
| 65 | } // namespace events |
| 66 | } // namespace mtx |
| 67 | |