libQuotient
A Qt library for building matrix clients
directory.h
Go to the documentation of this file.
1 // THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
2 
3 #pragma once
4 
5 #include <Quotient/jobs/basejob.h>
6 
7 namespace Quotient {
8 
9 //! \brief Create a new mapping from room alias to room ID.
10 class QUOTIENT_API SetRoomAliasJob : public BaseJob {
11 public:
12  //! \param roomAlias
13  //! The room alias to set. Its format is defined
14  //! [in the appendices](/appendices/#room-aliases).
15  //!
16  //! \param roomId
17  //! The room ID to set.
18  explicit SetRoomAliasJob(const QString& roomAlias, const QString& roomId);
19 };
20 
21 //! \brief Get the room ID corresponding to this room alias.
22 //!
23 //! Requests that the server resolve a room alias to a room ID.
24 //!
25 //! The server will use the federation API to resolve the alias if the
26 //! domain part of the alias does not correspond to the server's own
27 //! domain.
28 class QUOTIENT_API GetRoomIdByAliasJob : public BaseJob {
29 public:
30  //! \param roomAlias
31  //! The room alias. Its format is defined
32  //! [in the appendices](/appendices/#room-aliases).
33  explicit GetRoomIdByAliasJob(const QString& roomAlias);
34 
35  //! \brief Construct a URL without creating a full-fledged job object
36  //!
37  //! This function can be used when a URL for GetRoomIdByAliasJob
38  //! is necessary but the job itself isn't.
39  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomAlias);
40 
41  // Result properties
42 
43  //! The room ID for this room alias.
44  QString roomId() const { return loadFromJson<QString>("room_id"_L1); }
45 
46  //! A list of servers that are aware of this room alias.
47  QStringList servers() const { return loadFromJson<QStringList>("servers"_L1); }
48 
49  struct Response {
50  //! The room ID for this room alias.
51  QString roomId{};
52 
53  //! A list of servers that are aware of this room alias.
54  QStringList servers{};
55  };
56 };
57 
58 template <std::derived_from<GetRoomIdByAliasJob> JobT>
59 constexpr inline auto doCollectResponse<JobT> =
60  [](JobT* j) -> GetRoomIdByAliasJob::Response { return { j->roomId(), j->servers() }; };
61 
62 //! \brief Remove a mapping of room alias to room ID.
63 //!
64 //! Remove a mapping of room alias to room ID.
65 //!
66 //! Servers may choose to implement additional access control checks here, for instance that
67 //! room aliases can only be deleted by their creator or a server administrator.
68 //!
69 //! **Note:**
70 //! Servers may choose to update the `alt_aliases` for the `m.room.canonical_alias`
71 //! state event in the room when an alias is removed. Servers which choose to update the
72 //! canonical alias event are recommended to, in addition to their other relevant permission
73 //! checks, delete the alias and return a successful response even if the user does not
74 //! have permission to update the `m.room.canonical_alias` event.
75 class QUOTIENT_API DeleteRoomAliasJob : public BaseJob {
76 public:
77  //! \param roomAlias
78  //! The room alias to remove. Its format is defined
79  //! [in the appendices](/appendices/#room-aliases).
80  explicit DeleteRoomAliasJob(const QString& roomAlias);
81 
82  //! \brief Construct a URL without creating a full-fledged job object
83  //!
84  //! This function can be used when a URL for DeleteRoomAliasJob
85  //! is necessary but the job itself isn't.
86  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomAlias);
87 };
88 
89 //! \brief Get a list of local aliases on a given room.
90 //!
91 //! Get a list of aliases maintained by the local server for the
92 //! given room.
93 //!
94 //! This endpoint can be called by users who are in the room (external
95 //! users receive an `M_FORBIDDEN` error response). If the room's
96 //! `m.room.history_visibility` maps to `world_readable`, any
97 //! user can call this endpoint.
98 //!
99 //! Servers may choose to implement additional access control checks here,
100 //! such as allowing server administrators to view aliases regardless of
101 //! membership.
102 //!
103 //! **Note:**
104 //! Clients are recommended not to display this list of aliases prominently
105 //! as they are not curated, unlike those listed in the `m.room.canonical_alias`
106 //! state event.
107 class QUOTIENT_API GetLocalAliasesJob : public BaseJob {
108 public:
109  //! \param roomId
110  //! The room ID to find local aliases of.
111  explicit GetLocalAliasesJob(const QString& roomId);
112 
113  //! \brief Construct a URL without creating a full-fledged job object
114  //!
115  //! This function can be used when a URL for GetLocalAliasesJob
116  //! is necessary but the job itself isn't.
117  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId);
118 
119  // Result properties
120 
121  //! The server's local aliases on the room. Can be empty.
122  QStringList aliases() const { return loadFromJson<QStringList>("aliases"_L1); }
123 };
124 
125 inline auto collectResponse(const GetLocalAliasesJob* job) { return job->aliases(); }
126 
127 } // namespace Quotient