1#pragma once
2
3/// @file
4/// @brief Responses from the capabilities API.
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
12namespace mtx {
13namespace responses {
14namespace capabilities {
15//! Any version not explicitly labelled as stable in the available versions is to be treated as
16//! unstable. For example, a version listed as future-stable should be treated as unstable.
17enum class RoomVersionStability
18{
19 Unstable, //!< Any room version not listed as stable.
20 Stable, //!< A stable room versions
21};
22void
23from_json(const nlohmann::json &obj, RoomVersionStability &stab);
24
25//! The room versions the server supports.
26struct RoomVersionsCapability
27{
28 //! Required: The default room version the server is using for new rooms.
29 std::string default_ = "1";
30 //! Required: A detailed description of the room versions the server supports.
31 std::map<std::string, RoomVersionStability> available = {
32 {"1", RoomVersionStability::Stable},
33 };
34
35 friend void from_json(const nlohmann::json &obj, RoomVersionsCapability &cap);
36};
37
38//! any capability that can be enabled or disabled.
39struct Enabled
40{
41 //! If this capability is enabled.
42 bool enabled = true;
43
44 friend void from_json(const nlohmann::json &obj, Enabled &cap);
45};
46
47//! Response from the `GET /_matrix/client/v3/capabilities` endpoint.
48//
49//! Gets information about the server’s supported feature set and other relevant capabilities.
50struct Capabilities
51{
52 //! The room versions the server supports.
53 RoomVersionsCapability room_versions;
54 //! Capability to indicate if the user can change their password.
55 Enabled change_password;
56 //! Capability to indicate if the user can change their displayname.
57 Enabled set_displayname;
58 //! Capability to indicate if the user can change their avatar.
59 Enabled set_avatar_url;
60 //! This capability has a single flag, enabled, to denote whether the user is able to add,
61 //! remove, or change 3PID associations on their account.
62 Enabled change_3pid;
63
64 friend void from_json(const nlohmann::json &obj, Capabilities &caps);
65};
66}
67}
68}
69