1 | #pragma once |
2 | |
3 | /// @file |
4 | /// @brief A file 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.file`. |
23 | struct File |
24 | { |
25 | /// @brief A human-readable description of the file. |
26 | /// |
27 | /// This is recommended to be the filename of the original upload. |
28 | std::string body; |
29 | /// @brief The original filename of the uploaded file. |
30 | /// |
31 | /// SPEC_BUG: The filename is not really required. |
32 | std::string filename; |
33 | //! Must be 'm.file'. |
34 | std::string msgtype; |
35 | //! The matrix URL of the file. |
36 | std::string url; |
37 | //! Information about the file referred to in the url. |
38 | mtx::common::FileInfo info; |
39 | //! Encryption members. If present, they replace url. |
40 | std::optional<crypto::EncryptedFile> file; |
41 | //! Relates to for rich replies |
42 | mtx::common::Relations relations; |
43 | |
44 | friend void from_json(const nlohmann::json &obj, File &content); |
45 | friend void to_json(nlohmann::json &obj, const File &content); |
46 | }; |
47 | |
48 | } // namespace msg |
49 | } // namespace events |
50 | } // namespace mtx |
51 | |