From c641e3f070d6687e10a2cdb9fe3e4f7d12c5704f Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 Sep 2020 22:45:04 +0200 Subject: csapi/profile.*: require displayname/avatar_url See https://github.com/matrix-org/matrix-doc/issues/2717 --- lib/csapi/profile.cpp | 4 ++-- lib/csapi/profile.h | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/csapi') diff --git a/lib/csapi/profile.cpp b/lib/csapi/profile.cpp index cb8f72be..8436b8e6 100644 --- a/lib/csapi/profile.cpp +++ b/lib/csapi/profile.cpp @@ -15,7 +15,7 @@ SetDisplayNameJob::SetDisplayNameJob(const QString& userId, % "/displayname") { QJsonObject _data; - addParam(_data, QStringLiteral("displayname"), displayname); + addParam<>(_data, QStringLiteral("displayname"), displayname); setRequestData(std::move(_data)); } @@ -39,7 +39,7 @@ SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QString& avatarUrl % "/avatar_url") { QJsonObject _data; - addParam(_data, QStringLiteral("avatar_url"), avatarUrl); + addParam<>(_data, QStringLiteral("avatar_url"), avatarUrl); setRequestData(std::move(_data)); } diff --git a/lib/csapi/profile.h b/lib/csapi/profile.h index 88bf3166..3858fab2 100644 --- a/lib/csapi/profile.h +++ b/lib/csapi/profile.h @@ -24,7 +24,7 @@ public: * The new display name for this user. */ explicit SetDisplayNameJob(const QString& userId, - const QString& displayname = {}); + const QString& displayname); }; /*! \brief Get the user's display name. @@ -73,8 +73,7 @@ public: * \param avatarUrl * The new avatar URL for this user. */ - explicit SetAvatarUrlJob(const QString& userId, - const QString& avatarUrl = {}); + explicit SetAvatarUrlJob(const QString& userId, const QString& avatarUrl); }; /*! \brief Get the user's avatar URL. -- cgit v1.2.3 From 21fd088d207ee2c2724c5b250875a843b618497d Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 6 Nov 2020 14:11:49 +0100 Subject: ChangePasswordJob: logoutDevices doesn't need Omittable This is generated by GTAD 0.7.1 (to be released), based on the changed registration.yaml (to be committed and pulled). --- lib/csapi/registration.cpp | 2 +- lib/csapi/registration.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/csapi') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index b80abc84..33f61265 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -58,7 +58,7 @@ RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( } ChangePasswordJob::ChangePasswordJob(const QString& newPassword, - Omittable logoutDevices, + bool logoutDevices, const Omittable& auth) : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), QStringLiteral("/_matrix/client/r0") % "/account/password") diff --git a/lib/csapi/registration.h b/lib/csapi/registration.h index 62bc35f1..6864fd47 100644 --- a/lib/csapi/registration.h +++ b/lib/csapi/registration.h @@ -222,7 +222,7 @@ public: * * \param logoutDevices * Whether the user's other access tokens, and their associated devices, - * should be revoked if the request succeeds. Defaults to true. + * should be revoked if the request succeeds. * * When ``false``, the server can still take advantage of `the soft logout * method <#soft-logout>`_ for the user's remaining devices. @@ -232,7 +232,7 @@ public: * authentication API. */ explicit ChangePasswordJob(const QString& newPassword, - Omittable logoutDevices = none, + bool logoutDevices = true, const Omittable& auth = none); }; -- cgit v1.2.3 From 21554bccc39ab2f63869c244ed880686805887cb Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 24 Nov 2020 16:50:46 +0100 Subject: csapi/search.* --- lib/csapi/search.cpp | 28 +++++ lib/csapi/search.h | 306 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 334 insertions(+) create mode 100644 lib/csapi/search.cpp create mode 100644 lib/csapi/search.h (limited to 'lib/csapi') diff --git a/lib/csapi/search.cpp b/lib/csapi/search.cpp new file mode 100644 index 00000000..5649d52a --- /dev/null +++ b/lib/csapi/search.cpp @@ -0,0 +1,28 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "search.h" + +#include + +using namespace Quotient; + +auto queryToSearch(const QString& nextBatch) +{ + BaseJob::Query _q; + addParam(_q, QStringLiteral("next_batch"), nextBatch); + return _q; +} + +SearchJob::SearchJob(const Categories& searchCategories, + const QString& nextBatch) + : BaseJob(HttpVerb::Post, QStringLiteral("SearchJob"), + QStringLiteral("/_matrix/client/r0") % "/search", + queryToSearch(nextBatch)) +{ + QJsonObject _data; + addParam<>(_data, QStringLiteral("search_categories"), searchCategories); + setRequestData(std::move(_data)); + addExpectedKey("search_categories"); +} diff --git a/lib/csapi/search.h b/lib/csapi/search.h new file mode 100644 index 00000000..c009ded6 --- /dev/null +++ b/lib/csapi/search.h @@ -0,0 +1,306 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "csapi/definitions/room_event_filter.h" + +#include "events/eventloader.h" +#include "jobs/basejob.h" + +namespace Quotient { + +/*! \brief Perform a server-side search. + * + * Performs a full text search across different categories. + */ +class SearchJob : public BaseJob { +public: + // Inner data structures + + /// Configures whether any context for the events + /// returned are included in the response. + struct IncludeEventContext { + /// How many events before the result are + /// returned. By default, this is ``5``. + Omittable beforeLimit; + /// How many events after the result are + /// returned. By default, this is ``5``. + Omittable afterLimit; + /// Requests that the server returns the + /// historic profile information for the users + /// that sent the events that were returned. + /// By default, this is ``false``. + Omittable includeProfile; + }; + + /// Configuration for group. + struct Group { + /// Key that defines the group. + QString key; + }; + + /// Requests that the server partitions the result set + /// based on the provided list of keys. + struct Groupings { + /// List of groups to request. + QVector groupBy; + }; + + /// Mapping of category name to search criteria. + struct RoomEventsCriteria { + /// The string to search events for + QString searchTerm; + /// The keys to search. Defaults to all. + QStringList keys; + /// This takes a `filter`_. + RoomEventFilter filter; + /// The order in which to search for results. + /// By default, this is ``"rank"``. + QString orderBy; + /// Configures whether any context for the events + /// returned are included in the response. + Omittable eventContext; + /// Requests the server return the current state for + /// each room returned. + Omittable includeState; + /// Requests that the server partitions the result set + /// based on the provided list of keys. + Omittable groupings; + }; + + /// Describes which categories to search in and their criteria. + struct Categories { + /// Mapping of category name to search criteria. + Omittable roomEvents; + }; + + /// Performs a full text search across different categories. + struct UserProfile { + /// Performs a full text search across different categories. + QString displayname; + /// Performs a full text search across different categories. + QString avatarUrl; + }; + + /// Context for result, if requested. + struct EventContext { + /// Pagination token for the start of the chunk + QString begin; + /// Pagination token for the end of the chunk + QString end; + /// The historic profile information of the + /// users that sent the events returned. + /// + /// The ``string`` key is the user ID for which + /// the profile belongs to. + QHash profileInfo; + /// Events just before the result. + RoomEvents eventsBefore; + /// Events just after the result. + RoomEvents eventsAfter; + }; + + /// The result object. + struct Result { + /// A number that describes how closely this result matches the search. + /// Higher is closer. + Omittable rank; + /// The event that matched. + RoomEventPtr result; + /// Context for result, if requested. + Omittable context; + }; + + /// The results for a particular group value. + struct GroupValue { + /// Token that can be used to get the next batch + /// of results in the group, by passing as the + /// `next_batch` parameter to the next call. If + /// this field is absent, there are no more + /// results in this group. + QString nextBatch; + /// Key that can be used to order different + /// groups. + Omittable order; + /// Which results are in this group. + QStringList results; + }; + + /// Mapping of category name to search criteria. + struct ResultRoomEvents { + /// An approximate count of the total number of results found. + Omittable count; + /// List of words which should be highlighted, useful for stemming which + /// may change the query terms. + QStringList highlights; + /// List of results in the requested order. + std::vector results; + /// The current state for every room in the results. + /// This is included if the request had the + /// ``include_state`` key set with a value of ``true``. + /// + /// The ``string`` key is the room ID for which the ``State + /// Event`` array belongs to. + UnorderedMap state; + /// Any groups that were requested. + /// + /// The outer ``string`` key is the group key requested (eg: ``room_id`` + /// or ``sender``). The inner ``string`` key is the grouped value (eg: + /// a room's ID or a user's ID). + QHash> groups; + /// Token that can be used to get the next batch of + /// results, by passing as the `next_batch` parameter to + /// the next call. If this field is absent, there are no + /// more results. + QString nextBatch; + }; + + /// Describes which categories to search in and their criteria. + struct ResultCategories { + /// Mapping of category name to search criteria. + Omittable roomEvents; + }; + + // Construction/destruction + + /*! \brief Perform a server-side search. + * + * \param searchCategories + * Describes which categories to search in and their criteria. + * + * \param nextBatch + * The point to return events from. If given, this should be a + * ``next_batch`` result from a previous call to this endpoint. + */ + explicit SearchJob(const Categories& searchCategories, + const QString& nextBatch = {}); + + // Result properties + + /// Describes which categories to search in and their criteria. + ResultCategories searchCategories() const + { + return loadFromJson("search_categories"_ls); + } +}; + +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, + const SearchJob::IncludeEventContext& pod) + { + addParam(jo, QStringLiteral("before_limit"), + pod.beforeLimit); + addParam(jo, QStringLiteral("after_limit"), pod.afterLimit); + addParam(jo, QStringLiteral("include_profile"), + pod.includeProfile); + } +}; + +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const SearchJob::Group& pod) + { + addParam(jo, QStringLiteral("key"), pod.key); + } +}; + +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const SearchJob::Groupings& pod) + { + addParam(jo, QStringLiteral("group_by"), pod.groupBy); + } +}; + +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const SearchJob::RoomEventsCriteria& pod) + { + addParam<>(jo, QStringLiteral("search_term"), pod.searchTerm); + addParam(jo, QStringLiteral("keys"), pod.keys); + addParam(jo, QStringLiteral("filter"), pod.filter); + addParam(jo, QStringLiteral("order_by"), pod.orderBy); + addParam(jo, QStringLiteral("event_context"), + pod.eventContext); + addParam(jo, QStringLiteral("include_state"), + pod.includeState); + addParam(jo, QStringLiteral("groupings"), pod.groupings); + } +}; + +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const SearchJob::Categories& pod) + { + addParam(jo, QStringLiteral("room_events"), pod.roomEvents); + } +}; + +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, SearchJob::UserProfile& result) + { + fromJson(jo.value("displayname"_ls), result.displayname); + fromJson(jo.value("avatar_url"_ls), result.avatarUrl); + } +}; + +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, SearchJob::EventContext& result) + { + fromJson(jo.value("start"_ls), result.begin); + fromJson(jo.value("end"_ls), result.end); + fromJson(jo.value("profile_info"_ls), result.profileInfo); + fromJson(jo.value("events_before"_ls), result.eventsBefore); + fromJson(jo.value("events_after"_ls), result.eventsAfter); + } +}; + +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, SearchJob::Result& result) + { + fromJson(jo.value("rank"_ls), result.rank); + fromJson(jo.value("result"_ls), result.result); + fromJson(jo.value("context"_ls), result.context); + } +}; + +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, SearchJob::GroupValue& result) + { + fromJson(jo.value("next_batch"_ls), result.nextBatch); + fromJson(jo.value("order"_ls), result.order); + fromJson(jo.value("results"_ls), result.results); + } +}; + +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, + SearchJob::ResultRoomEvents& result) + { + fromJson(jo.value("count"_ls), result.count); + fromJson(jo.value("highlights"_ls), result.highlights); + fromJson(jo.value("results"_ls), result.results); + fromJson(jo.value("state"_ls), result.state); + fromJson(jo.value("groups"_ls), result.groups); + fromJson(jo.value("next_batch"_ls), result.nextBatch); + } +}; + +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, + SearchJob::ResultCategories& result) + { + fromJson(jo.value("room_events"_ls), result.roomEvents); + } +}; + +} // namespace Quotient -- cgit v1.2.3 From 0d4315008374d9a4dfb11f934875b1a16670ec74 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Wed, 23 Jun 2021 19:12:38 +0200 Subject: Re-generate API files --- lib/application-service/definitions/protocol.h | 9 +- lib/csapi/account-data.h | 4 +- lib/csapi/admin.h | 5 +- lib/csapi/administrative_contact.h | 65 ++++--- lib/csapi/appservice_room_directory.cpp | 4 +- lib/csapi/appservice_room_directory.h | 14 +- lib/csapi/banning.cpp | 4 +- lib/csapi/banning.h | 10 +- lib/csapi/content-repo.h | 74 +++++--- lib/csapi/create_room.h | 210 ++++++++++----------- lib/csapi/cross_signing.cpp | 34 ++++ lib/csapi/cross_signing.h | 72 +++++++ lib/csapi/definitions/cross_signing_key.h | 47 +++++ lib/csapi/definitions/device_keys.h | 8 +- lib/csapi/definitions/event_filter.h | 8 +- lib/csapi/definitions/openid_token.h | 4 +- lib/csapi/definitions/public_rooms_response.h | 8 + lib/csapi/definitions/push_condition.h | 17 +- lib/csapi/definitions/push_rule.h | 4 +- lib/csapi/definitions/request_email_validation.h | 5 +- lib/csapi/definitions/request_msisdn_validation.h | 5 +- lib/csapi/definitions/request_token_response.h | 6 +- lib/csapi/definitions/room_event_filter.h | 25 +-- lib/csapi/definitions/sync_filter.h | 8 +- lib/csapi/definitions/third_party_signed.h | 2 +- lib/csapi/definitions/user_identifier.h | 5 +- lib/csapi/device_management.h | 11 +- lib/csapi/directory.h | 25 +-- lib/csapi/event_context.h | 34 ++-- lib/csapi/filter.h | 12 +- lib/csapi/inviting.cpp | 4 +- lib/csapi/inviting.h | 16 +- lib/csapi/joining.cpp | 8 +- lib/csapi/joining.h | 42 +++-- lib/csapi/keys.h | 73 +++++-- lib/csapi/kicking.h | 9 +- lib/csapi/knocking.cpp | 28 +++ lib/csapi/knocking.h | 58 ++++++ lib/csapi/leaving.cpp | 15 +- lib/csapi/leaving.h | 11 +- lib/csapi/list_joined_rooms.h | 2 +- lib/csapi/list_public_rooms.h | 22 ++- lib/csapi/login.h | 48 +++-- lib/csapi/logout.h | 11 +- lib/csapi/message_pagination.h | 54 +++--- lib/csapi/notifications.h | 15 +- lib/csapi/openid.h | 14 +- lib/csapi/peeking_events.h | 29 ++- lib/csapi/presence.h | 12 +- lib/csapi/profile.h | 16 +- lib/csapi/pusher.h | 38 ++-- lib/csapi/pushrules.h | 42 +++-- lib/csapi/read_markers.h | 2 +- lib/csapi/receipts.h | 4 +- lib/csapi/redaction.h | 14 +- lib/csapi/registration.h | 147 +++++++-------- lib/csapi/report_content.cpp | 6 +- lib/csapi/report_content.h | 3 +- lib/csapi/room_send.h | 10 +- lib/csapi/room_state.h | 33 ++-- lib/csapi/rooms.h | 28 +-- lib/csapi/search.h | 24 +-- lib/csapi/sso_login_redirect.cpp | 24 +++ lib/csapi/sso_login_redirect.h | 36 +++- lib/csapi/tags.h | 4 +- lib/csapi/third_party_membership.h | 15 +- lib/csapi/to_device.cpp | 2 +- lib/csapi/to_device.h | 2 +- lib/csapi/typing.h | 6 +- lib/csapi/users.h | 9 +- lib/csapi/versions.h | 10 +- lib/csapi/voip.h | 5 +- lib/csapi/wellknown.h | 2 +- lib/csapi/whoami.h | 20 +- .../definitions/request_email_validation.h | 6 +- .../definitions/request_msisdn_validation.h | 8 +- 76 files changed, 1119 insertions(+), 607 deletions(-) create mode 100644 lib/csapi/cross_signing.cpp create mode 100644 lib/csapi/cross_signing.h create mode 100644 lib/csapi/definitions/cross_signing_key.h create mode 100644 lib/csapi/knocking.cpp create mode 100644 lib/csapi/knocking.h (limited to 'lib/csapi') diff --git a/lib/application-service/definitions/protocol.h b/lib/application-service/definitions/protocol.h index 6aee9c57..213dbf19 100644 --- a/lib/application-service/definitions/protocol.h +++ b/lib/application-service/definitions/protocol.h @@ -40,7 +40,7 @@ struct ProtocolInstance { /// provided at the higher level Protocol object. QString icon; - /// Preset values for ``fields`` the client may use to search by. + /// Preset values for `fields` the client may use to search by. QJsonObject fields; /// A unique identifier across all instances. @@ -81,10 +81,9 @@ struct ThirdPartyProtocol { /// A content URI representing an icon for the third party protocol. QString icon; - /// The type definitions for the fields defined in the ``user_fields`` and - /// ``location_fields``. Each entry in those arrays MUST have an entry here. - /// The - /// ``string`` key for this object is field name itself. + /// The type definitions for the fields defined in the `user_fields` and + /// `location_fields`. Each entry in those arrays MUST have an entry here. + /// The `string` key for this object is field name itself. /// /// May be an empty object if no fields are defined. QHash fieldTypes; diff --git a/lib/csapi/account-data.h b/lib/csapi/account-data.h index 9a31596f..0c760e80 100644 --- a/lib/csapi/account-data.h +++ b/lib/csapi/account-data.h @@ -12,7 +12,7 @@ namespace Quotient { * * Set some account_data for the client. This config is only visible to the user * that set the account_data. The config will be synced to clients in the - * top-level ``account_data``. + * top-level `account_data`. */ class SetAccountDataJob : public BaseJob { public: @@ -65,7 +65,7 @@ public: * * Set some account_data for the client on a given room. This config is only * visible to the user that set the account_data. The config will be synced to - * clients in the per-room ``account_data``. + * clients in the per-room `account_data`. */ class SetAccountDataPerRoomJob : public BaseJob { public: diff --git a/lib/csapi/admin.h b/lib/csapi/admin.h index 570bf24a..d4fe639b 100644 --- a/lib/csapi/admin.h +++ b/lib/csapi/admin.h @@ -74,7 +74,10 @@ public: // Result properties /// The Matrix user ID of the user. - QString userId() const { return loadFromJson("user_id"_ls); } + QString userId() const + { + return loadFromJson("user_id"_ls); + } /// Each key is an identifier for one of the user's devices. QHash devices() const diff --git a/lib/csapi/administrative_contact.h b/lib/csapi/administrative_contact.h index 1966d533..e436971d 100644 --- a/lib/csapi/administrative_contact.h +++ b/lib/csapi/administrative_contact.h @@ -93,14 +93,14 @@ struct JsonObjectConverter { * * Adds contact information to the user's account. * - * This endpoint is deprecated in favour of the more specific ``/3pid/add`` - * and ``/3pid/bind`` endpoints. + * This endpoint is deprecated in favour of the more specific `/3pid/add` + * and `/3pid/bind` endpoints. * - * .. Note:: - * Previously this endpoint supported a ``bind`` parameter. This parameter - * has been removed, making this endpoint behave as though it was ``false``. - * This results in this endpoint being an equivalent to ``/3pid/bind`` rather - * than dual-purpose. + * **Note:** + * Previously this endpoint supported a `bind` parameter. This parameter + * has been removed, making this endpoint behave as though it was `false`. + * This results in this endpoint being an equivalent to `/3pid/bind` rather + * than dual-purpose. */ class Post3PIDsJob : public BaseJob { public: @@ -144,7 +144,8 @@ struct JsonObjectConverter { /*! \brief Adds contact information to the user's account. * - * This API endpoint uses the `User-Interactive Authentication API`_. + * This API endpoint uses the [User-Interactive Authentication + * API](/client-server-api/#user-interactive-authentication-api). * * Adds contact information to the user's account. Homeservers should use 3PIDs * added through this endpoint for password resets instead of relying on the @@ -206,7 +207,7 @@ public: * Removes a third party identifier from the user's account. This might not * cause an unbind of the identifier from the identity server. * - * Unlike other endpoints, this endpoint does not take an ``id_access_token`` + * Unlike other endpoints, this endpoint does not take an `id_access_token` * parameter because the homeserver is expected to sign the request to the * identity server instead. */ @@ -222,9 +223,9 @@ public: * * \param idServer * The identity server to unbind from. If not provided, the homeserver - * MUST use the ``id_server`` the identifier was added through. If the - * homeserver does not know the original ``id_server``, it MUST return - * a ``id_server_unbind_result`` of ``no-support``. + * MUST use the `id_server` the identifier was added through. If the + * homeserver does not know the original `id_server`, it MUST return + * a `id_server_unbind_result` of `no-support`. */ explicit Delete3pidFromAccountJob(const QString& medium, const QString& address, @@ -233,8 +234,8 @@ public: // Result properties /// An indicator as to whether or not the homeserver was able to unbind - /// the 3PID from the identity server. ``success`` indicates that the - /// indentity server has unbound the identifier whereas ``no-support`` + /// the 3PID from the identity server. `success` indicates that the + /// indentity server has unbound the identifier whereas `no-support` /// indicates that the identity server refuses to support the request /// or the homeserver was not able to determine an identity server to /// unbind from. @@ -249,7 +250,7 @@ public: * Removes a user's third party identifier from the provided identity server * without removing it from the homeserver. * - * Unlike other endpoints, this endpoint does not take an ``id_access_token`` + * Unlike other endpoints, this endpoint does not take an `id_access_token` * parameter because the homeserver is expected to sign the request to the * identity server instead. */ @@ -265,9 +266,9 @@ public: * * \param idServer * The identity server to unbind from. If not provided, the homeserver - * MUST use the ``id_server`` the identifier was added through. If the - * homeserver does not know the original ``id_server``, it MUST return - * a ``id_server_unbind_result`` of ``no-support``. + * MUST use the `id_server` the identifier was added through. If the + * homeserver does not know the original `id_server`, it MUST return + * a `id_server_unbind_result` of `no-support`. */ explicit Unbind3pidFromAccountJob(const QString& medium, const QString& address, @@ -276,8 +277,8 @@ public: // Result properties /// An indicator as to whether or not the identity server was able to unbind - /// the 3PID. ``success`` indicates that the identity server has unbound the - /// identifier whereas ``no-support`` indicates that the identity server + /// the 3PID. `success` indicates that the identity server has unbound the + /// identifier whereas `no-support` indicates that the identity server /// refuses to support the request or the homeserver was not able to /// determine an identity server to unbind from. QString idServerUnbindResult() const @@ -293,7 +294,9 @@ public: * already associated with an account on this homeserver. This API should * be used to request validation tokens when adding an email address to an * account. This API's parameters and response are identical to that of - * the |/register/email/requestToken|_ endpoint. The homeserver should validate + * the + * [`/register/email/requestToken`](/client-server-api/#post_matrixclientr0registeremailrequesttoken) + * endpoint. The homeserver should validate * the email itself, either by sending a validation email itself or by using * a service it has control over. */ @@ -307,9 +310,11 @@ public: * already associated with an account on this homeserver. This API should * be used to request validation tokens when adding an email address to an * account. This API's parameters and response are identical to that of - * the |/register/email/requestToken|_ endpoint. The homeserver should - * validate the email itself, either by sending a validation email itself or - * by using a service it has control over. + * the + * [`/register/email/requestToken`](/client-server-api/#post_matrixclientr0registeremailrequesttoken) + * endpoint. The homeserver should validate + * the email itself, either by sending a validation email itself or by + * using a service it has control over. */ explicit RequestTokenTo3PIDEmailJob(const EmailValidationData& body); @@ -331,7 +336,9 @@ public: * already associated with an account on this homeserver. This API should * be used to request validation tokens when adding a phone number to an * account. This API's parameters and response are identical to that of - * the |/register/msisdn/requestToken|_ endpoint. The homeserver should validate + * the + * [`/register/msisdn/requestToken`](/client-server-api/#post_matrixclientr0registermsisdnrequesttoken) + * endpoint. The homeserver should validate * the phone number itself, either by sending a validation message itself or by * using a service it has control over. */ @@ -345,9 +352,11 @@ public: * already associated with an account on this homeserver. This API should * be used to request validation tokens when adding a phone number to an * account. This API's parameters and response are identical to that of - * the |/register/msisdn/requestToken|_ endpoint. The homeserver should - * validate the phone number itself, either by sending a validation message - * itself or by using a service it has control over. + * the + * [`/register/msisdn/requestToken`](/client-server-api/#post_matrixclientr0registermsisdnrequesttoken) + * endpoint. The homeserver should validate + * the phone number itself, either by sending a validation message itself + * or by using a service it has control over. */ explicit RequestTokenTo3PIDMSISDNJob(const MsisdnValidationData& body); diff --git a/lib/csapi/appservice_room_directory.cpp b/lib/csapi/appservice_room_directory.cpp index e8ec55bf..4d87e4af 100644 --- a/lib/csapi/appservice_room_directory.cpp +++ b/lib/csapi/appservice_room_directory.cpp @@ -8,10 +8,10 @@ using namespace Quotient; -UpdateAppserviceRoomDirectoryVsibilityJob::UpdateAppserviceRoomDirectoryVsibilityJob( +UpdateAppserviceRoomDirectoryVisibilityJob::UpdateAppserviceRoomDirectoryVisibilityJob( const QString& networkId, const QString& roomId, const QString& visibility) : BaseJob(HttpVerb::Put, - QStringLiteral("UpdateAppserviceRoomDirectoryVsibilityJob"), + QStringLiteral("UpdateAppserviceRoomDirectoryVisibilityJob"), QStringLiteral("/_matrix/client/r0") % "/directory/list/appservice/" % networkId % "/" % roomId) { diff --git a/lib/csapi/appservice_room_directory.h b/lib/csapi/appservice_room_directory.h index 3fa02a07..56a69592 100644 --- a/lib/csapi/appservice_room_directory.h +++ b/lib/csapi/appservice_room_directory.h @@ -17,11 +17,11 @@ namespace Quotient { * This API is similar to the room directory visibility API used by clients * to update the homeserver's more general room directory. * - * This API requires the use of an application service access token - * (``as_token``) instead of a typical client's access_token. This API cannot be - * invoked by users who are not identified as application services. + * This API requires the use of an application service access token (`as_token`) + * instead of a typical client's access_token. This API cannot be invoked by + * users who are not identified as application services. */ -class UpdateAppserviceRoomDirectoryVsibilityJob : public BaseJob { +class UpdateAppserviceRoomDirectoryVisibilityJob : public BaseJob { public: /*! \brief Updates a room's visibility in the application service's room * directory. @@ -38,9 +38,9 @@ public: * Whether the room should be visible (public) in the directory * or not (private). */ - explicit UpdateAppserviceRoomDirectoryVsibilityJob(const QString& networkId, - const QString& roomId, - const QString& visibility); + explicit UpdateAppserviceRoomDirectoryVisibilityJob( + const QString& networkId, const QString& roomId, + const QString& visibility); }; } // namespace Quotient diff --git a/lib/csapi/banning.cpp b/lib/csapi/banning.cpp index 8a8ec664..8e0add1a 100644 --- a/lib/csapi/banning.cpp +++ b/lib/csapi/banning.cpp @@ -19,12 +19,14 @@ BanJob::BanJob(const QString& roomId, const QString& userId, setRequestData(std::move(_data)); } -UnbanJob::UnbanJob(const QString& roomId, const QString& userId) +UnbanJob::UnbanJob(const QString& roomId, const QString& userId, + const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("UnbanJob"), QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/unban") { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); + addParam(_data, QStringLiteral("reason"), reason); setRequestData(std::move(_data)); } diff --git a/lib/csapi/banning.h b/lib/csapi/banning.h index 37ae91ee..7a9697d3 100644 --- a/lib/csapi/banning.h +++ b/lib/csapi/banning.h @@ -30,7 +30,8 @@ public: * * \param reason * The reason the user has been banned. This will be supplied as the - * ``reason`` on the target's updated `m.room.member`_ event. + * `reason` on the target's updated + * [`m.room.member`](/client-server-api/#mroommember) event. */ explicit BanJob(const QString& roomId, const QString& userId, const QString& reason = {}); @@ -54,8 +55,13 @@ public: * * \param userId * The fully qualified user ID of the user being unbanned. + * + * \param reason + * Optional reason to be included as the `reason` on the subsequent + * membership event. */ - explicit UnbanJob(const QString& roomId, const QString& userId); + explicit UnbanJob(const QString& roomId, const QString& userId, + const QString& reason = {}); }; } // namespace Quotient diff --git a/lib/csapi/content-repo.h b/lib/csapi/content-repo.h index ed67485c..a41453b2 100644 --- a/lib/csapi/content-repo.h +++ b/lib/csapi/content-repo.h @@ -32,7 +32,8 @@ public: // Result properties - /// The `MXC URI`_ to the uploaded content. + /// The [MXC URI](/client-server-api/#matrix-content-mxc-uris) to the + /// uploaded content. QString contentUri() const { return loadFromJson("content_uri"_ls); @@ -47,10 +48,10 @@ public: /*! \brief Download content from the content repository. * * \param serverName - * The server name from the ``mxc://`` URI (the authoritory component) + * The server name from the `mxc://` URI (the authoritory component) * * \param mediaId - * The media ID from the ``mxc://`` URI (the path component) + * The media ID from the `mxc://` URI (the path component) * * \param allowRemote * Indicates to the server that it should not attempt to fetch the media @@ -71,7 +72,10 @@ public: // Result properties /// The content type of the file that was previously uploaded. - QString contentType() const { return reply()->rawHeader("Content-Type"); } + QString contentType() const + { + return reply()->rawHeader("Content-Type"); + } /// The name of the file that was previously uploaded, if set. QString contentDisposition() const @@ -80,7 +84,10 @@ public: } /// The content that was previously uploaded. - QIODevice* data() { return reply(); } + QIODevice* data() + { + return reply(); + } }; /*! \brief Download content from the content repository overriding the file name @@ -95,13 +102,13 @@ public: * name * * \param serverName - * The server name from the ``mxc://`` URI (the authoritory component) + * The server name from the `mxc://` URI (the authoritory component) * * \param mediaId - * The media ID from the ``mxc://`` URI (the path component) + * The media ID from the `mxc://` URI (the path component) * * \param fileName - * A filename to give in the ``Content-Disposition`` header. + * A filename to give in the `Content-Disposition` header. * * \param allowRemote * Indicates to the server that it should not attempt to fetch the media @@ -125,9 +132,12 @@ public: // Result properties /// The content type of the file that was previously uploaded. - QString contentType() const { return reply()->rawHeader("Content-Type"); } + QString contentType() const + { + return reply()->rawHeader("Content-Type"); + } - /// The ``fileName`` requested or the name of the file that was previously + /// The `fileName` requested or the name of the file that was previously /// uploaded, if set. QString contentDisposition() const { @@ -135,23 +145,27 @@ public: } /// The content that was previously uploaded. - QIODevice* data() { return reply(); } + QIODevice* data() + { + return reply(); + } }; /*! \brief Download a thumbnail of content from the content repository * * Download a thumbnail of content from the content repository. - * See the `thumbnailing <#thumbnails>`_ section for more information. + * See the [Thumbnails](/client-server-api/#thumbnails) section for more + * information. */ class GetContentThumbnailJob : public BaseJob { public: /*! \brief Download a thumbnail of content from the content repository * * \param serverName - * The server name from the ``mxc://`` URI (the authoritory component) + * The server name from the `mxc://` URI (the authoritory component) * * \param mediaId - * The media ID from the ``mxc://`` URI (the path component) + * The media ID from the `mxc://` URI (the path component) * * \param width * The *desired* width of the thumbnail. The actual thumbnail may be @@ -162,8 +176,8 @@ public: * larger than the size specified. * * \param method - * The desired resizing method. See the `thumbnailing <#thumbnails>`_ - * section for more information. + * The desired resizing method. See the + * [Thumbnails](/client-server-api/#thumbnails) section for more information. * * \param allowRemote * Indicates to the server that it should not attempt to fetch @@ -188,10 +202,16 @@ public: // Result properties /// The content type of the thumbnail. - QString contentType() const { return reply()->rawHeader("Content-Type"); } + QString contentType() const + { + return reply()->rawHeader("Content-Type"); + } /// A thumbnail of the requested content. - QIODevice* data() { return reply(); } + QIODevice* data() + { + return reply(); + } }; /*! \brief Get information about a URL for a client @@ -199,11 +219,11 @@ public: * Get information about a URL for the client. Typically this is called when a * client sees a URL in a message and wants to render a preview for the user. * - * .. Note:: - * Clients should consider avoiding this endpoint for URLs posted in encrypted - * rooms. Encrypted rooms often contain more sensitive information the users - * do not want to share with the homeserver, and this can mean that the URLs - * being shared should also not be shared with the homeserver. + * **Note:** + * Clients should consider avoiding this endpoint for URLs posted in encrypted + * rooms. Encrypted rooms often contain more sensitive information the users + * do not want to share with the homeserver, and this can mean that the URLs + * being shared should also not be shared with the homeserver. */ class GetUrlPreviewJob : public BaseJob { public: @@ -235,8 +255,12 @@ public: return loadFromJson>("matrix:image:size"_ls); } - /// An `MXC URI`_ to the image. Omitted if there is no image. - QString ogImage() const { return loadFromJson("og:image"_ls); } + /// An [MXC URI](/client-server-api/#matrix-content-mxc-uris) to the image. + /// Omitted if there is no image. + QString ogImage() const + { + return loadFromJson("og:image"_ls); + } }; /*! \brief Get the configuration for the content repository. diff --git a/lib/csapi/create_room.h b/lib/csapi/create_room.h index 6a718ff4..8c6af7d4 100644 --- a/lib/csapi/create_room.h +++ b/lib/csapi/create_room.h @@ -16,47 +16,42 @@ namespace Quotient { * the new room, including checking power levels for each event. It MUST * apply the events implied by the request in the following order: * - * 1. The ``m.room.create`` event itself. Must be the first event in the + * 1. The `m.room.create` event itself. Must be the first event in the * room. * - * 2. An ``m.room.member`` event for the creator to join the room. This is + * 2. An `m.room.member` event for the creator to join the room. This is * needed so the remaining events can be sent. * - * 3. A default ``m.room.power_levels`` event, giving the room creator + * 3. A default `m.room.power_levels` event, giving the room creator * (and not other members) permission to send state events. Overridden - * by the ``power_level_content_override`` parameter. + * by the `power_level_content_override` parameter. * - * 4. Events set by the ``preset``. Currently these are the - * ``m.room.join_rules``, - * ``m.room.history_visibility``, and ``m.room.guest_access`` state events. + * 4. Events set by the `preset`. Currently these are the `m.room.join_rules`, + * `m.room.history_visibility`, and `m.room.guest_access` state events. * - * 5. Events listed in ``initial_state``, in the order that they are + * 5. Events listed in `initial_state`, in the order that they are * listed. * - * 6. Events implied by ``name`` and ``topic`` (``m.room.name`` and - * ``m.room.topic`` state events). + * 6. Events implied by `name` and `topic` (`m.room.name` and `m.room.topic` + * state events). * - * 7. Invite events implied by ``invite`` and ``invite_3pid`` (``m.room.member`` - * with - * ``membership: invite`` and ``m.room.third_party_invite``). + * 7. Invite events implied by `invite` and `invite_3pid` (`m.room.member` with + * `membership: invite` and `m.room.third_party_invite`). * * The available presets do the following with respect to room state: * - * ======================== ============== ====================== - * ================ ========= Preset ``join_rules`` - * ``history_visibility`` ``guest_access`` Other - * ======================== ============== ====================== - * ================ ========= - * ``private_chat`` ``invite`` ``shared`` ``can_join`` - * ``trusted_private_chat`` ``invite`` ``shared`` ``can_join`` All - * invitees are given the same power level as the room creator. - * ``public_chat`` ``public`` ``shared`` ``forbidden`` - * ======================== ============== ====================== - * ================ ========= + * | Preset | `join_rules` | `history_visibility` | + * `guest_access` | Other | + * |------------------------|--------------|----------------------|----------------|-------| + * | `private_chat` | `invite` | `shared` | `can_join` + * | | | `trusted_private_chat` | `invite` | `shared` | + * `can_join` | All invitees are given the same power level as the room + * creator. | | `public_chat` | `public` | `shared` | + * `forbidden` | | * - * The server will create a ``m.room.create`` event in the room with the + * The server will create a `m.room.create` event in the room with the * requesting user as the creator, alongside other keys provided in the - * ``creation_content``. + * `creation_content`. */ class CreateRoomJob : public BaseJob { public: @@ -68,50 +63,44 @@ public: /// the new room, including checking power levels for each event. It MUST /// apply the events implied by the request in the following order: /// - /// 1. The ``m.room.create`` event itself. Must be the first event in the + /// 1. The `m.room.create` event itself. Must be the first event in the /// room. /// - /// 2. An ``m.room.member`` event for the creator to join the room. This is + /// 2. An `m.room.member` event for the creator to join the room. This is /// needed so the remaining events can be sent. /// - /// 3. A default ``m.room.power_levels`` event, giving the room creator + /// 3. A default `m.room.power_levels` event, giving the room creator /// (and not other members) permission to send state events. Overridden - /// by the ``power_level_content_override`` parameter. + /// by the `power_level_content_override` parameter. /// - /// 4. Events set by the ``preset``. Currently these are the - /// ``m.room.join_rules``, - /// ``m.room.history_visibility``, and ``m.room.guest_access`` state - /// events. + /// 4. Events set by the `preset`. Currently these are the + /// `m.room.join_rules`, + /// `m.room.history_visibility`, and `m.room.guest_access` state events. /// - /// 5. Events listed in ``initial_state``, in the order that they are + /// 5. Events listed in `initial_state`, in the order that they are /// listed. /// - /// 6. Events implied by ``name`` and ``topic`` (``m.room.name`` and - /// ``m.room.topic`` + /// 6. Events implied by `name` and `topic` (`m.room.name` and `m.room.topic` /// state events). /// - /// 7. Invite events implied by ``invite`` and ``invite_3pid`` - /// (``m.room.member`` with - /// ``membership: invite`` and ``m.room.third_party_invite``). + /// 7. Invite events implied by `invite` and `invite_3pid` (`m.room.member` + /// with + /// `membership: invite` and `m.room.third_party_invite`). /// /// The available presets do the following with respect to room state: /// - /// ======================== ============== ====================== - /// ================ ========= - /// Preset ``join_rules`` ``history_visibility`` - /// ``guest_access`` Other - /// ======================== ============== ====================== - /// ================ ========= - /// ``private_chat`` ``invite`` ``shared`` ``can_join`` - /// ``trusted_private_chat`` ``invite`` ``shared`` ``can_join`` All - /// invitees are given the same power level as the room creator. - /// ``public_chat`` ``public`` ``shared`` ``forbidden`` - /// ======================== ============== ====================== - /// ================ ========= + /// | Preset | `join_rules` | `history_visibility` | + /// `guest_access` | Other | + /// |------------------------|--------------|----------------------|----------------|-------| + /// | `private_chat` | `invite` | `shared` | + /// `can_join` | | | `trusted_private_chat` | `invite` | + /// `shared` | `can_join` | All invitees are given the same + /// power level as the room creator. | | `public_chat` | `public` + /// | `shared` | `forbidden` | | /// - /// The server will create a ``m.room.create`` event in the room with the + /// The server will create a `m.room.create` event in the room with the /// requesting user as the creator, alongside other keys provided in the - /// ``creation_content``. + /// `creation_content`. struct Invite3pid { /// The hostname+port of the identity server which should be used for /// third party identifier lookups. @@ -121,7 +110,7 @@ public: /// r0.5-compatible clients and this specification version. QString idAccessToken; /// The kind of address being passed in the address field, for example - /// ``email``. + /// `email`. QString medium; /// The invitee's third party identifier. QString address; @@ -133,50 +122,44 @@ public: /// the new room, including checking power levels for each event. It MUST /// apply the events implied by the request in the following order: /// - /// 1. The ``m.room.create`` event itself. Must be the first event in the + /// 1. The `m.room.create` event itself. Must be the first event in the /// room. /// - /// 2. An ``m.room.member`` event for the creator to join the room. This is + /// 2. An `m.room.member` event for the creator to join the room. This is /// needed so the remaining events can be sent. /// - /// 3. A default ``m.room.power_levels`` event, giving the room creator + /// 3. A default `m.room.power_levels` event, giving the room creator /// (and not other members) permission to send state events. Overridden - /// by the ``power_level_content_override`` parameter. + /// by the `power_level_content_override` parameter. /// - /// 4. Events set by the ``preset``. Currently these are the - /// ``m.room.join_rules``, - /// ``m.room.history_visibility``, and ``m.room.guest_access`` state - /// events. + /// 4. Events set by the `preset`. Currently these are the + /// `m.room.join_rules`, + /// `m.room.history_visibility`, and `m.room.guest_access` state events. /// - /// 5. Events listed in ``initial_state``, in the order that they are + /// 5. Events listed in `initial_state`, in the order that they are /// listed. /// - /// 6. Events implied by ``name`` and ``topic`` (``m.room.name`` and - /// ``m.room.topic`` + /// 6. Events implied by `name` and `topic` (`m.room.name` and `m.room.topic` /// state events). /// - /// 7. Invite events implied by ``invite`` and ``invite_3pid`` - /// (``m.room.member`` with - /// ``membership: invite`` and ``m.room.third_party_invite``). + /// 7. Invite events implied by `invite` and `invite_3pid` (`m.room.member` + /// with + /// `membership: invite` and `m.room.third_party_invite`). /// /// The available presets do the following with respect to room state: /// - /// ======================== ============== ====================== - /// ================ ========= - /// Preset ``join_rules`` ``history_visibility`` - /// ``guest_access`` Other - /// ======================== ============== ====================== - /// ================ ========= - /// ``private_chat`` ``invite`` ``shared`` ``can_join`` - /// ``trusted_private_chat`` ``invite`` ``shared`` ``can_join`` All - /// invitees are given the same power level as the room creator. - /// ``public_chat`` ``public`` ``shared`` ``forbidden`` - /// ======================== ============== ====================== - /// ================ ========= + /// | Preset | `join_rules` | `history_visibility` | + /// `guest_access` | Other | + /// |------------------------|--------------|----------------------|----------------|-------| + /// | `private_chat` | `invite` | `shared` | + /// `can_join` | | | `trusted_private_chat` | `invite` | + /// `shared` | `can_join` | All invitees are given the same + /// power level as the room creator. | | `public_chat` | `public` + /// | `shared` | `forbidden` | | /// - /// The server will create a ``m.room.create`` event in the room with the + /// The server will create a `m.room.create` event in the room with the /// requesting user as the creator, alongside other keys provided in the - /// ``creation_content``. + /// `creation_content`. struct StateEvent { /// The type of event to send. QString type; @@ -191,12 +174,12 @@ public: /*! \brief Create a new room * * \param visibility - * A ``public`` visibility indicates that the room will be shown - * in the published room list. A ``private`` visibility will hide + * A `public` visibility indicates that the room will be shown + * in the published room list. A `private` visibility will hide * the room from the published room list. Rooms default to - * ``private`` visibility if this key is not included. NB: This - * should not be confused with ``join_rules`` which also uses the - * word ``public``. + * `private` visibility if this key is not included. NB: This + * should not be confused with `join_rules` which also uses the + * word `public`. * * \param roomAliasName * The desired room alias **local part**. If this is included, a @@ -204,20 +187,20 @@ public: * room. The alias will belong on the *same* homeserver which * created the room. For example, if this was set to "foo" and * sent to the homeserver "example.com" the complete room alias - * would be ``#foo:example.com``. + * would be `#foo:example.com`. * * The complete room alias will become the canonical alias for * the room. * * \param name - * If this is included, an ``m.room.name`` event will be sent + * If this is included, an `m.room.name` event will be sent * into the room to indicate the name of the room. See Room - * Events for more information on ``m.room.name``. + * Events for more information on `m.room.name`. * * \param topic - * If this is included, an ``m.room.topic`` event will be sent + * If this is included, an `m.room.topic` event will be sent * into the room to indicate the topic for the room. See Room - * Events for more information on ``m.room.topic``. + * Events for more information on `m.room.topic`. * * \param invite * A list of user IDs to invite to the room. This will tell the @@ -230,14 +213,14 @@ public: * \param roomVersion * The room version to set for the room. If not provided, the homeserver * is to use its configured default. If provided, the homeserver will return - * a 400 error with the errcode ``M_UNSUPPORTED_ROOM_VERSION`` if it does - * not support the room version. + * a 400 error with the errcode `M_UNSUPPORTED_ROOM_VERSION` if it does not + * support the room version. * * \param creationContent - * Extra keys, such as ``m.federate``, to be added to the content - * of the `m.room.create`_ event. The server will clobber the following - * keys: ``creator``, ``room_version``. Future versions of the - * specification may allow the server to clobber other keys. + * Extra keys, such as `m.federate`, to be added to the content + * of the [`m.room.create`](client-server-api/#mroomcreate) event. The + * server will clobber the following keys: `creator`, `room_version`. Future + * versions of the specification may allow the server to clobber other keys. * * \param initialState * A list of state events to set in the new room. This allows @@ -245,28 +228,30 @@ public: * room. The expected format of the state events are an object * with type, state_key and content keys set. * - * Takes precedence over events set by ``preset``, but gets - * overriden by ``name`` and ``topic`` keys. + * Takes precedence over events set by `preset`, but gets + * overriden by `name` and `topic` keys. * * \param preset * Convenience parameter for setting various default state events * based on a preset. * - * If unspecified, the server should use the ``visibility`` to determine - * which preset to use. A visbility of ``public`` equates to a preset of - * ``public_chat`` and ``private`` visibility equates to a preset of - * ``private_chat``. + * If unspecified, the server should use the `visibility` to determine + * which preset to use. A visbility of `public` equates to a preset of + * `public_chat` and `private` visibility equates to a preset of + * `private_chat`. * * \param isDirect - * This flag makes the server set the ``is_direct`` flag on the - * ``m.room.member`` events sent to the users in ``invite`` and - * ``invite_3pid``. See `Direct Messaging`_ for more information. + * This flag makes the server set the `is_direct` flag on the + * `m.room.member` events sent to the users in `invite` and + * `invite_3pid`. See [Direct + * Messaging](/client-server-api/#direct-messaging) for more information. * * \param powerLevelContentOverride * The power level content to override in the default power level * event. This object is applied on top of the generated - * `m.room.power_levels`_ event content prior to it being sent to the room. - * Defaults to overriding nothing. + * [`m.room.power_levels`](client-server-api/#mroompower_levels) + * event content prior to it being sent to the room. Defaults to + * overriding nothing. */ explicit CreateRoomJob(const QString& visibility = {}, const QString& roomAliasName = {}, @@ -283,7 +268,10 @@ public: // Result properties /// The created room's ID. - QString roomId() const { return loadFromJson("room_id"_ls); } + QString roomId() const + { + return loadFromJson("room_id"_ls); + } }; template <> diff --git a/lib/csapi/cross_signing.cpp b/lib/csapi/cross_signing.cpp new file mode 100644 index 00000000..9bfc026a --- /dev/null +++ b/lib/csapi/cross_signing.cpp @@ -0,0 +1,34 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "cross_signing.h" + +#include + +using namespace Quotient; + +UploadCrossSigningKeysJob::UploadCrossSigningKeysJob( + const Omittable& masterKey, + const Omittable& selfSigningKey, + const Omittable& userSigningKey) + : BaseJob(HttpVerb::Post, QStringLiteral("UploadCrossSigningKeysJob"), + QStringLiteral("/_matrix/client/r0") + % "/keys/device_signing/upload") +{ + QJsonObject _data; + addParam(_data, QStringLiteral("master_key"), masterKey); + addParam(_data, QStringLiteral("self_signing_key"), + selfSigningKey); + addParam(_data, QStringLiteral("user_signing_key"), + userSigningKey); + setRequestData(std::move(_data)); +} + +UploadCrossSigningSignaturesJob::UploadCrossSigningSignaturesJob( + const QHash>& signatures) + : BaseJob(HttpVerb::Post, QStringLiteral("UploadCrossSigningSignaturesJob"), + QStringLiteral("/_matrix/client/r0") % "/keys/signatures/upload") +{ + setRequestData(Data(toJson(signatures))); +} diff --git a/lib/csapi/cross_signing.h b/lib/csapi/cross_signing.h new file mode 100644 index 00000000..2ab65e06 --- /dev/null +++ b/lib/csapi/cross_signing.h @@ -0,0 +1,72 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "csapi/definitions/cross_signing_key.h" + +#include "jobs/basejob.h" + +namespace Quotient { + +/*! \brief Upload cross-signing keys. + * + * Publishes cross-signing keys for the user. + * + * This API endpoint uses the [User-Interactive Authentication + * API](/client-server-api/#user-interactive-authentication-api). + */ +class UploadCrossSigningKeysJob : public BaseJob { +public: + /*! \brief Upload cross-signing keys. + * + * \param masterKey + * Optional. The user\'s master key. + * + * \param selfSigningKey + * Optional. The user\'s self-signing key. Must be signed by + * the accompanying master key, or by the user\'s most recently + * uploaded master key if no master key is included in the + * request. + * + * \param userSigningKey + * Optional. The user\'s user-signing key. Must be signed by + * the accompanying master key, or by the user\'s most recently + * uploaded master key if no master key is included in the + * request. + */ + explicit UploadCrossSigningKeysJob( + const Omittable& masterKey = none, + const Omittable& selfSigningKey = none, + const Omittable& userSigningKey = none); +}; + +/*! \brief Upload cross-signing signatures. + * + * Publishes cross-signing signatures for the user. The request body is a + * map from user ID to key ID to signed JSON object. + */ +class UploadCrossSigningSignaturesJob : public BaseJob { +public: + /*! \brief Upload cross-signing signatures. + * + * \param signatures + * The signatures to be published. + */ + explicit UploadCrossSigningSignaturesJob( + const QHash>& signatures = {}); + + // Result properties + + /// A map from user ID to key ID to an error for any signatures + /// that failed. If a signature was invalid, the `errcode` will + /// be set to `M_INVALID_SIGNATURE`. + QHash> failures() const + { + return loadFromJson>>( + "failures"_ls); + } +}; + +} // namespace Quotient diff --git a/lib/csapi/definitions/cross_signing_key.h b/lib/csapi/definitions/cross_signing_key.h new file mode 100644 index 00000000..0cec8161 --- /dev/null +++ b/lib/csapi/definitions/cross_signing_key.h @@ -0,0 +1,47 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "converters.h" + +namespace Quotient { +/// Cross signing key +struct CrossSigningKey { + /// The ID of the user the key belongs to. + QString userId; + + /// What the key is used for. + QStringList usage; + + /// The public key. The object must have exactly one property, whose name + /// is in the form `:`, and whose + /// value is the unpadded base64 public key. + QHash keys; + + /// Signatures of the key, calculated using the process described at + /// [Signing JSON](/appendices/#signing-json). Optional for the master key. + /// Other keys must be signed by the user\'s master key. + QJsonObject signatures; +}; + +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const CrossSigningKey& pod) + { + addParam<>(jo, QStringLiteral("user_id"), pod.userId); + addParam<>(jo, QStringLiteral("usage"), pod.usage); + addParam<>(jo, QStringLiteral("keys"), pod.keys); + addParam(jo, QStringLiteral("signatures"), pod.signatures); + } + static void fillFrom(const QJsonObject& jo, CrossSigningKey& pod) + { + fromJson(jo.value("user_id"_ls), pod.userId); + fromJson(jo.value("usage"_ls), pod.usage); + fromJson(jo.value("keys"_ls), pod.keys); + fromJson(jo.value("signatures"_ls), pod.signatures); + } +}; + +} // namespace Quotient diff --git a/lib/csapi/definitions/device_keys.h b/lib/csapi/definitions/device_keys.h index 3065f218..84ecefae 100644 --- a/lib/csapi/definitions/device_keys.h +++ b/lib/csapi/definitions/device_keys.h @@ -21,15 +21,15 @@ struct DeviceKeys { QStringList algorithms; /// Public identity keys. The names of the properties should be in the - /// format ``:``. The keys themselves should be + /// format `:`. The keys themselves should be /// encoded as specified by the key algorithm. QHash keys; /// Signatures for the device key object. A map from user ID, to a map from - /// ``:`` to the signature. + /// `:` to the signature. /// - /// The signature is calculated using the process described at `Signing - /// JSON`_. + /// The signature is calculated using the process described at [Signing + /// JSON](/appendices/#signing-json). QHash> signatures; }; diff --git a/lib/csapi/definitions/event_filter.h b/lib/csapi/definitions/event_filter.h index 67497412..c55d4f92 100644 --- a/lib/csapi/definitions/event_filter.h +++ b/lib/csapi/definitions/event_filter.h @@ -14,13 +14,13 @@ struct EventFilter { /// A list of sender IDs to exclude. If this list is absent then no senders /// are excluded. A matching sender will be excluded even if it is listed in - /// the ``'senders'`` filter. + /// the `'senders'` filter. QStringList notSenders; /// A list of event types to exclude. If this list is absent then no event /// types are excluded. A matching type will be excluded even if it is - /// listed in the ``'types'`` filter. A '*' can be used as a wildcard to - /// match any sequence of characters. + /// listed in the `'types'` filter. A '*' can be used as a wildcard to match + /// any sequence of characters. QStringList notTypes; /// A list of senders IDs to include. If this list is absent then all @@ -28,7 +28,7 @@ struct EventFilter { QStringList senders; /// A list of event types to include. If this list is absent then all event - /// types are included. A ``'*'`` can be used as a wildcard to match any + /// types are included. A `'*'` can be used as a wildcard to match any /// sequence of characters. QStringList types; }; diff --git a/lib/csapi/definitions/openid_token.h b/lib/csapi/definitions/openid_token.h index 5e68c376..3c447321 100644 --- a/lib/csapi/definitions/openid_token.h +++ b/lib/csapi/definitions/openid_token.h @@ -11,10 +11,10 @@ namespace Quotient { struct OpenidToken { /// An access token the consumer may use to verify the identity of /// the person who generated the token. This is given to the federation - /// API ``GET /openid/userinfo`` to verify the user's identity. + /// API `GET /openid/userinfo` to verify the user's identity. QString accessToken; - /// The string ``Bearer``. + /// The string `Bearer`. QString tokenType; /// The homeserver domain the consumer should use when attempting to diff --git a/lib/csapi/definitions/public_rooms_response.h b/lib/csapi/definitions/public_rooms_response.h index 8f30e607..34b447d2 100644 --- a/lib/csapi/definitions/public_rooms_response.h +++ b/lib/csapi/definitions/public_rooms_response.h @@ -37,6 +37,12 @@ struct PublicRoomsChunk { /// The URL for the room's avatar, if one is set. QString avatarUrl; + + /// The room's join rule. When not present, the room is assumed to + /// be `public`. Note that rooms with `invite` join rules are not + /// expected here, but rooms with `knock` rules are given their + /// near-public nature. + QString joinRule; }; template <> @@ -54,6 +60,7 @@ struct JsonObjectConverter { addParam<>(jo, QStringLiteral("world_readable"), pod.worldReadable); addParam<>(jo, QStringLiteral("guest_can_join"), pod.guestCanJoin); addParam(jo, QStringLiteral("avatar_url"), pod.avatarUrl); + addParam(jo, QStringLiteral("join_rule"), pod.joinRule); } static void fillFrom(const QJsonObject& jo, PublicRoomsChunk& pod) { @@ -66,6 +73,7 @@ struct JsonObjectConverter { fromJson(jo.value("world_readable"_ls), pod.worldReadable); fromJson(jo.value("guest_can_join"_ls), pod.guestCanJoin); fromJson(jo.value("avatar_url"_ls), pod.avatarUrl); + fromJson(jo.value("join_rule"_ls), pod.joinRule); } }; diff --git a/lib/csapi/definitions/push_condition.h b/lib/csapi/definitions/push_condition.h index a6decf1b..ce66d075 100644 --- a/lib/csapi/definitions/push_condition.h +++ b/lib/csapi/definitions/push_condition.h @@ -9,26 +9,27 @@ namespace Quotient { struct PushCondition { - /// The kind of condition to apply. See `conditions <#conditions>`_ for - /// more information on the allowed kinds and how they work. + /// The kind of condition to apply. See + /// [conditions](/client-server-api/#conditions) for more information on the + /// allowed kinds and how they work. QString kind; - /// Required for ``event_match`` conditions. The dot-separated field of the + /// Required for `event_match` conditions. The dot-separated field of the /// event to match. /// - /// Required for ``sender_notification_permission`` conditions. The field in + /// Required for `sender_notification_permission` conditions. The field in /// the power level event the user needs a minimum power level for. Fields - /// must be specified under the ``notifications`` property in the power - /// level event's ``content``. + /// must be specified under the `notifications` property in the power level + /// event's `content`. QString key; - /// Required for ``event_match`` conditions. The glob-style pattern to + /// Required for `event_match` conditions. The glob-style pattern to /// match against. Patterns with no special glob characters should be /// treated as having asterisks prepended and appended when testing the /// condition. QString pattern; - /// Required for ``room_member_count`` conditions. A decimal integer + /// Required for `room_member_count` conditions. A decimal integer /// optionally prefixed by one of, ==, <, >, >= or <=. A prefix of < matches /// rooms where the member count is strictly less than the given number and /// so forth. If no prefix is present, this parameter defaults to ==. diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index 43749bae..135537c1 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -25,10 +25,10 @@ struct PushRule { /// The conditions that must hold true for an event in order for a rule to /// be applied to an event. A rule with no conditions always matches. Only - /// applicable to ``underride`` and ``override`` rules. + /// applicable to `underride` and `override` rules. QVector conditions; - /// The glob-style pattern to match against. Only applicable to ``content`` + /// The glob-style pattern to match against. Only applicable to `content` /// rules. QString pattern; }; diff --git a/lib/csapi/definitions/request_email_validation.h b/lib/csapi/definitions/request_email_validation.h index ab34862e..b1781e27 100644 --- a/lib/csapi/definitions/request_email_validation.h +++ b/lib/csapi/definitions/request_email_validation.h @@ -16,15 +16,14 @@ struct EmailValidationData : RequestEmailValidation { /// 3PID verification. /// /// This parameter is deprecated with a plan to be removed in a future - /// specification version for ``/account/password`` and ``/register`` - /// requests. + /// specification version for `/account/password` and `/register` requests. QString idServer; /// An access token previously registered with the identity server. Servers /// can treat this as optional to distinguish between r0.5-compatible /// clients and this specification version. /// - /// Required if an ``id_server`` is supplied. + /// Required if an `id_server` is supplied. QString idAccessToken; }; diff --git a/lib/csapi/definitions/request_msisdn_validation.h b/lib/csapi/definitions/request_msisdn_validation.h index 8539cd98..4600b48c 100644 --- a/lib/csapi/definitions/request_msisdn_validation.h +++ b/lib/csapi/definitions/request_msisdn_validation.h @@ -16,15 +16,14 @@ struct MsisdnValidationData : RequestMsisdnValidation { /// 3PID verification. /// /// This parameter is deprecated with a plan to be removed in a future - /// specification version for ``/account/password`` and ``/register`` - /// requests. + /// specification version for `/account/password` and `/register` requests. QString idServer; /// An access token previously registered with the identity server. Servers /// can treat this as optional to distinguish between r0.5-compatible /// clients and this specification version. /// - /// Required if an ``id_server`` is supplied. + /// Required if an `id_server` is supplied. QString idAccessToken; }; diff --git a/lib/csapi/definitions/request_token_response.h b/lib/csapi/definitions/request_token_response.h index 00222839..f9981100 100644 --- a/lib/csapi/definitions/request_token_response.h +++ b/lib/csapi/definitions/request_token_response.h @@ -10,20 +10,20 @@ namespace Quotient { struct RequestTokenResponse { /// The session ID. Session IDs are opaque strings that must consist - /// entirely of the characters ``[0-9a-zA-Z.=_-]``. Their length must not + /// entirely of the characters `[0-9a-zA-Z.=_-]`. Their length must not /// exceed 255 characters and they must not be empty. QString sid; /// An optional field containing a URL where the client must submit the /// validation token to, with identical parameters to the Identity Service - /// API's ``POST /validate/email/submitToken`` endpoint (without the + /// API's `POST /validate/email/submitToken` endpoint (without the /// requirement for an access token). The homeserver must send this token to /// the user (if applicable), who should then be prompted to provide it to /// the client. /// /// If this field is not present, the client can assume that verification /// will happen without the client's involvement provided the homeserver - /// advertises this specification version in the ``/versions`` response + /// advertises this specification version in the `/versions` response /// (ie: r0.5.0). QString submitUrl; }; diff --git a/lib/csapi/definitions/room_event_filter.h b/lib/csapi/definitions/room_event_filter.h index 11e87fde..91caf667 100644 --- a/lib/csapi/definitions/room_event_filter.h +++ b/lib/csapi/definitions/room_event_filter.h @@ -11,30 +11,31 @@ namespace Quotient { struct RoomEventFilter : EventFilter { - /// If ``true``, enables lazy-loading of membership events. See - /// `Lazy-loading room members <#lazy-loading-room-members>`_ - /// for more information. Defaults to ``false``. + /// If `true`, enables lazy-loading of membership events. See + /// [Lazy-loading room + /// members](/client-server-api/#lazy-loading-room-members) for more + /// information. Defaults to `false`. Omittable lazyLoadMembers; - /// If ``true``, sends all membership events for all events, even if they - /// have already been sent to the client. Does not apply unless - /// ``lazy_load_members`` is ``true``. See `Lazy-loading room members - /// <#lazy-loading-room-members>`_ for more information. Defaults to - /// ``false``. + /// If `true`, sends all membership events for all events, even if they have + /// already been sent to the client. Does not apply unless + /// `lazy_load_members` is `true`. See [Lazy-loading room + /// members](/client-server-api/#lazy-loading-room-members) for more + /// information. Defaults to `false`. Omittable includeRedundantMembers; /// A list of room IDs to exclude. If this list is absent then no rooms are /// excluded. A matching room will be excluded even if it is listed in the - /// ``'rooms'`` filter. + /// `'rooms'` filter. QStringList notRooms; /// A list of room IDs to include. If this list is absent then all rooms are /// included. QStringList rooms; - /// If ``true``, includes only events with a ``url`` key in their content. - /// If ``false``, excludes those events. If omitted, ``url`` key is not - /// considered for filtering. + /// If `true`, includes only events with a `url` key in their content. If + /// `false`, excludes those events. If omitted, `url` key is not considered + /// for filtering. Omittable containsUrl; }; diff --git a/lib/csapi/definitions/sync_filter.h b/lib/csapi/definitions/sync_filter.h index 9c8f08d5..62e17962 100644 --- a/lib/csapi/definitions/sync_filter.h +++ b/lib/csapi/definitions/sync_filter.h @@ -14,13 +14,13 @@ namespace Quotient { struct RoomFilter { /// A list of room IDs to exclude. If this list is absent then no rooms are /// excluded. A matching room will be excluded even if it is listed in the - /// ``'rooms'`` filter. This filter is applied before the filters in - /// ``ephemeral``, ``state``, ``timeline`` or ``account_data`` + /// `'rooms'` filter. This filter is applied before the filters in + /// `ephemeral`, `state`, `timeline` or `account_data` QStringList notRooms; /// A list of room IDs to include. If this list is absent then all rooms are - /// included. This filter is applied before the filters in ``ephemeral``, - /// ``state``, ``timeline`` or ``account_data`` + /// included. This filter is applied before the filters in `ephemeral`, + /// `state`, `timeline` or `account_data` QStringList rooms; /// The events that aren't recorded in the room history, e.g. typing and diff --git a/lib/csapi/definitions/third_party_signed.h b/lib/csapi/definitions/third_party_signed.h index 526545d0..7097bda4 100644 --- a/lib/csapi/definitions/third_party_signed.h +++ b/lib/csapi/definitions/third_party_signed.h @@ -7,7 +7,7 @@ #include "converters.h" namespace Quotient { -/// A signature of an ``m.third_party_invite`` token to prove that this user +/// A signature of an `m.third_party_invite` token to prove that this user /// owns a third party identity which has been invited to the room. struct ThirdPartySigned { /// The Matrix ID of the user who issued the invite. diff --git a/lib/csapi/definitions/user_identifier.h b/lib/csapi/definitions/user_identifier.h index dadf6f97..cb585a6a 100644 --- a/lib/csapi/definitions/user_identifier.h +++ b/lib/csapi/definitions/user_identifier.h @@ -9,8 +9,9 @@ namespace Quotient { /// Identification information for a user struct UserIdentifier { - /// The type of identification. See `Identifier types`_ for supported - /// values and additional property descriptions. + /// The type of identification. See [Identifier + /// types](/client-server-api/#identifier-types) for supported values and + /// additional property descriptions. QString type; /// Identification information for a user diff --git a/lib/csapi/device_management.h b/lib/csapi/device_management.h index 47dc7ec8..e2acea18 100644 --- a/lib/csapi/device_management.h +++ b/lib/csapi/device_management.h @@ -59,7 +59,10 @@ public: // Result properties /// Device information - Device device() const { return fromJson(jsonData()); } + Device device() const + { + return fromJson(jsonData()); + } }; /*! \brief Update a device @@ -83,7 +86,8 @@ public: /*! \brief Delete a device * - * This API endpoint uses the `User-Interactive Authentication API`_. + * This API endpoint uses the [User-Interactive Authentication + * API](/client-server-api/#user-interactive-authentication-api). * * Deletes the given device, and invalidates any access token associated with it. */ @@ -104,7 +108,8 @@ public: /*! \brief Bulk deletion of devices * - * This API endpoint uses the `User-Interactive Authentication API`_. + * This API endpoint uses the [User-Interactive Authentication + * API](/client-server-api/#user-interactive-authentication-api). * * Deletes the given devices, and invalidates any access token associated with * them. diff --git a/lib/csapi/directory.h b/lib/csapi/directory.h index 9b109aad..00215cae 100644 --- a/lib/csapi/directory.h +++ b/lib/csapi/directory.h @@ -51,7 +51,10 @@ public: // Result properties /// The room ID for this room alias. - QString roomId() const { return loadFromJson("room_id"_ls); } + QString roomId() const + { + return loadFromJson("room_id"_ls); + } /// A list of servers that are aware of this room alias. QStringList servers() const @@ -68,13 +71,13 @@ public: * instance that room aliases can only be deleted by their creator or a server * administrator. * - * .. Note:: - * Servers may choose to update the ``alt_aliases`` for the - * ``m.room.canonical_alias`` state event in the room when an alias is removed. + * **Note:** + * Servers may choose to update the `alt_aliases` for the + * `m.room.canonical_alias` state event in the room when an alias is removed. * Servers which choose to update the canonical alias event are recommended to, * in addition to their other relevant permission checks, delete the alias and * return a successful response even if the user does not have permission to - * update the ``m.room.canonical_alias`` event. + * update the `m.room.canonical_alias` event. */ class DeleteRoomAliasJob : public BaseJob { public: @@ -99,18 +102,18 @@ public: * given room. * * This endpoint can be called by users who are in the room (external - * users receive an ``M_FORBIDDEN`` error response). If the room's - * ``m.room.history_visibility`` maps to ``world_readable``, any + * users receive an `M_FORBIDDEN` error response). If the room's + * `m.room.history_visibility` maps to `world_readable`, any * user can call this endpoint. * * Servers may choose to implement additional access control checks here, * such as allowing server administrators to view aliases regardless of * membership. * - * .. Note:: - * Clients are recommended not to display this list of aliases prominently - * as they are not curated, unlike those listed in the - * ``m.room.canonical_alias`` state event. + * **Note:** + * Clients are recommended not to display this list of aliases prominently + * as they are not curated, unlike those listed in the `m.room.canonical_alias` + * state event. */ class GetLocalAliasesJob : public BaseJob { public: diff --git a/lib/csapi/event_context.h b/lib/csapi/event_context.h index d82d16ab..6a49769f 100644 --- a/lib/csapi/event_context.h +++ b/lib/csapi/event_context.h @@ -16,8 +16,8 @@ namespace Quotient { * surrounding an event. * * *Note*: This endpoint supports lazy-loading of room member events. See - * `Lazy-loading room members <#lazy-loading-room-members>`_ for more - * information. + * [Lazy-loading room members](/client-server-api/#lazy-loading-room-members) + * for more information. */ class GetEventContextJob : public BaseJob { public: @@ -33,13 +33,13 @@ public: * The maximum number of events to return. Default: 10. * * \param filter - * A JSON ``RoomEventFilter`` to filter the returned events with. The - * filter is only applied to ``events_before``, ``events_after``, and - * ``state``. It is not applied to the ``event`` itself. The filter may - * be applied before or/and after the ``limit`` parameter - whichever the + * A JSON `RoomEventFilter` to filter the returned events with. The + * filter is only applied to `events_before`, `events_after`, and + * `state`. It is not applied to the `event` itself. The filter may + * be applied before or/and after the `limit` parameter - whichever the * homeserver prefers. * - * See `Filtering <#filtering>`_ for more information. + * See [Filtering](/client-server-api/#filtering) for more information. */ explicit GetEventContextJob(const QString& roomId, const QString& eventId, Omittable limit = none, @@ -58,10 +58,16 @@ public: // Result properties /// A token that can be used to paginate backwards with. - QString begin() const { return loadFromJson("start"_ls); } + QString begin() const + { + return loadFromJson("start"_ls); + } /// A token that can be used to paginate forwards with. - QString end() const { return loadFromJson("end"_ls); } + QString end() const + { + return loadFromJson("end"_ls); + } /// A list of room events that happened just before the /// requested event, in reverse-chronological order. @@ -71,7 +77,10 @@ public: } /// Details of the requested event. - RoomEventPtr event() { return takeFromJson("event"_ls); } + RoomEventPtr event() + { + return takeFromJson("event"_ls); + } /// A list of room events that happened just after the /// requested event, in chronological order. @@ -81,7 +90,10 @@ public: } /// The state of the room at the last event returned. - StateEvents state() { return takeFromJson("state"_ls); } + StateEvents state() + { + return takeFromJson("state"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/filter.h b/lib/csapi/filter.h index f07b489c..7e9e14ee 100644 --- a/lib/csapi/filter.h +++ b/lib/csapi/filter.h @@ -32,10 +32,13 @@ public: // Result properties /// The ID of the filter that was created. Cannot start - /// with a ``{`` as this character is used to determine + /// with a `{` as this character is used to determine /// if the filter provided is inline JSON or a previously /// declared filter by homeservers on some APIs. - QString filterId() const { return loadFromJson("filter_id"_ls); } + QString filterId() const + { + return loadFromJson("filter_id"_ls); + } }; /*! \brief Download a filter @@ -64,7 +67,10 @@ public: // Result properties /// The filter definition. - Filter filter() const { return fromJson(jsonData()); } + Filter filter() const + { + return fromJson(jsonData()); + } }; } // namespace Quotient diff --git a/lib/csapi/inviting.cpp b/lib/csapi/inviting.cpp index 01620f9e..1e2554f4 100644 --- a/lib/csapi/inviting.cpp +++ b/lib/csapi/inviting.cpp @@ -8,12 +8,14 @@ using namespace Quotient; -InviteUserJob::InviteUserJob(const QString& roomId, const QString& userId) +InviteUserJob::InviteUserJob(const QString& roomId, const QString& userId, + const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("InviteUserJob"), QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/invite") { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); + addParam(_data, QStringLiteral("reason"), reason); setRequestData(std::move(_data)); } diff --git a/lib/csapi/inviting.h b/lib/csapi/inviting.h index 59a61b89..eb13cc95 100644 --- a/lib/csapi/inviting.h +++ b/lib/csapi/inviting.h @@ -9,13 +9,12 @@ namespace Quotient { /*! \brief Invite a user to participate in a particular room. - * - * .. _invite-by-user-id-endpoint: * * *Note that there are two forms of this API, which are documented separately. * This version of the API requires that the inviter knows the Matrix * identifier of the invitee. The other is documented in the* - * `third party invites section`_. + * [third party invites + * section](/client-server-api/#post_matrixclientr0roomsroomidinvite-1). * * This API invites a user to participate in a particular room. * They do not start participating in the room until they actually join the @@ -25,9 +24,7 @@ namespace Quotient { * join that room. * * If the user was invited to the room, the homeserver will append a - * ``m.room.member`` event to the room. - * - * .. _third party invites section: `invite-by-third-party-id-endpoint`_ + * `m.room.member` event to the room. */ class InviteUserJob : public BaseJob { public: @@ -38,8 +35,13 @@ public: * * \param userId * The fully qualified user ID of the invitee. + * + * \param reason + * Optional reason to be included as the `reason` on the subsequent + * membership event. */ - explicit InviteUserJob(const QString& roomId, const QString& userId); + explicit InviteUserJob(const QString& roomId, const QString& userId, + const QString& reason = {}); }; } // namespace Quotient diff --git a/lib/csapi/joining.cpp b/lib/csapi/joining.cpp index 4761e949..998d0b42 100644 --- a/lib/csapi/joining.cpp +++ b/lib/csapi/joining.cpp @@ -9,13 +9,15 @@ using namespace Quotient; JoinRoomByIdJob::JoinRoomByIdJob( - const QString& roomId, const Omittable& thirdPartySigned) + const QString& roomId, const Omittable& thirdPartySigned, + const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("JoinRoomByIdJob"), QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/join") { QJsonObject _data; addParam(_data, QStringLiteral("third_party_signed"), thirdPartySigned); + addParam(_data, QStringLiteral("reason"), reason); setRequestData(std::move(_data)); addExpectedKey("room_id"); } @@ -29,7 +31,8 @@ auto queryToJoinRoom(const QStringList& serverName) JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, const QStringList& serverName, - const Omittable& thirdPartySigned) + const Omittable& thirdPartySigned, + const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("JoinRoomJob"), QStringLiteral("/_matrix/client/r0") % "/join/" % roomIdOrAlias, queryToJoinRoom(serverName)) @@ -37,6 +40,7 @@ JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, QJsonObject _data; addParam(_data, QStringLiteral("third_party_signed"), thirdPartySigned); + addParam(_data, QStringLiteral("reason"), reason); setRequestData(std::move(_data)); addExpectedKey("room_id"); } diff --git a/lib/csapi/joining.h b/lib/csapi/joining.h index dd936f92..6dcd1351 100644 --- a/lib/csapi/joining.h +++ b/lib/csapi/joining.h @@ -13,7 +13,7 @@ namespace Quotient { /*! \brief Start the requesting user participating in a particular room. * * *Note that this API requires a room ID, not alias.* - * ``/join/{roomIdOrAlias}`` *exists if you have a room alias.* + * `/join/{roomIdOrAlias}` *exists if you have a room alias.* * * This API starts a user participating in a particular room, if that user * is allowed to participate in that room. After this call, the client is @@ -21,7 +21,9 @@ namespace Quotient { * events associated with the room until the user leaves the room. * * After a user has joined a room, the room will appear as an entry in the - * response of the |/initialSync|_ and |/sync|_ APIs. + * response of the + * [`/initialSync`](/client-server-api/#get_matrixclientr0initialsync) and + * [`/sync`](/client-server-api/#get_matrixclientr0sync) APIs. */ class JoinRoomByIdJob : public BaseJob { public: @@ -32,23 +34,31 @@ public: * * \param thirdPartySigned * If supplied, the homeserver must verify that it matches a pending - * ``m.room.third_party_invite`` event in the room, and perform + * `m.room.third_party_invite` event in the room, and perform * key validity checking if required by the event. + * + * \param reason + * Optional reason to be included as the `reason` on the subsequent + * membership event. */ explicit JoinRoomByIdJob( const QString& roomId, - const Omittable& thirdPartySigned = none); + const Omittable& thirdPartySigned = none, + const QString& reason = {}); // Result properties /// The joined room ID. - QString roomId() const { return loadFromJson("room_id"_ls); } + QString roomId() const + { + return loadFromJson("room_id"_ls); + } }; /*! \brief Start the requesting user participating in a particular room. * * *Note that this API takes either a room ID or alias, unlike* - * ``/room/{roomId}/join``. + * `/room/{roomId}/join`. * * This API starts a user participating in a particular room, if that user * is allowed to participate in that room. After this call, the client is @@ -56,7 +66,9 @@ public: * events associated with the room until the user leaves the room. * * After a user has joined a room, the room will appear as an entry in the - * response of the |/initialSync|_ and |/sync|_ APIs. + * response of the + * [`/initialSync`](/client-server-api/#get_matrixclientr0initialsync) and + * [`/sync`](/client-server-api/#get_matrixclientr0sync) APIs. */ class JoinRoomJob : public BaseJob { public: @@ -70,18 +82,26 @@ public: * must be participating in the room. * * \param thirdPartySigned - * If a ``third_party_signed`` was supplied, the homeserver must verify - * that it matches a pending ``m.room.third_party_invite`` event in the + * If a `third_party_signed` was supplied, the homeserver must verify + * that it matches a pending `m.room.third_party_invite` event in the * room, and perform key validity checking if required by the event. + * + * \param reason + * Optional reason to be included as the `reason` on the subsequent + * membership event. */ explicit JoinRoomJob( const QString& roomIdOrAlias, const QStringList& serverName = {}, - const Omittable& thirdPartySigned = none); + const Omittable& thirdPartySigned = none, + const QString& reason = {}); // Result properties /// The joined room ID. - QString roomId() const { return loadFromJson("room_id"_ls); } + QString roomId() const + { + return loadFromJson("room_id"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/keys.h b/lib/csapi/keys.h index 8f6c8cc9..53ba6495 100644 --- a/lib/csapi/keys.h +++ b/lib/csapi/keys.h @@ -4,6 +4,7 @@ #pragma once +#include "csapi/definitions/cross_signing_key.h" #include "csapi/definitions/device_keys.h" #include "jobs/basejob.h" @@ -25,8 +26,8 @@ public: * \param oneTimeKeys * One-time public keys for "pre-key" messages. The names of * the properties should be in the format - * ``:``. The format of the key is determined - * by the `key algorithm <#key-algorithms>`_. + * `:`. The format of the key is determined + * by the [key algorithm](/client-server-api/#key-algorithms). * * May be absent if no new one-time keys are required. */ @@ -98,7 +99,7 @@ public: /// /// If the homeserver could be reached, but the user or device /// was unknown, no failure is recorded. Instead, the corresponding - /// user or device is missing from the ``device_keys`` result. + /// user or device is missing from the `device_keys` result. QHash failures() const { return loadFromJson>("failures"_ls); @@ -107,13 +108,45 @@ public: /// Information on the queried devices. A map from user ID, to a /// map from device ID to device information. For each device, /// the information returned will be the same as uploaded via - /// ``/keys/upload``, with the addition of an ``unsigned`` + /// `/keys/upload`, with the addition of an `unsigned` /// property. QHash> deviceKeys() const { return loadFromJson>>( "device_keys"_ls); } + + /// Information on the master cross-signing keys of the queried users. + /// A map from user ID, to master key information. For each key, the + /// information returned will be the same as uploaded via + /// `/keys/device_signing/upload`, along with the signatures + /// uploaded via `/keys/signatures/upload` that the requesting user + /// is allowed to see. + QHash masterKeys() const + { + return loadFromJson>("master_keys"_ls); + } + + /// Information on the self-signing keys of the queried users. A map + /// from user ID, to self-signing key information. For each key, the + /// information returned will be the same as uploaded via + /// `/keys/device_signing/upload`. + QHash selfSigningKeys() const + { + return loadFromJson>( + "self_signing_keys"_ls); + } + + /// Information on the user-signing key of the user making the + /// request, if they queried their own device information. A map + /// from user ID, to user-signing key information. The + /// information returned will be the same as uploaded via + /// `/keys/device_signing/upload`. + QHash userSigningKeys() const + { + return loadFromJson>( + "user_signing_keys"_ls); + } }; template <> @@ -163,18 +196,17 @@ public: /// /// If the homeserver could be reached, but the user or device /// was unknown, no failure is recorded. Instead, the corresponding - /// user or device is missing from the ``one_time_keys`` result. + /// user or device is missing from the `one_time_keys` result. QHash failures() const { return loadFromJson>("failures"_ls); } /// One-time keys for the queried devices. A map from user ID, to a - /// map from devices to a map from ``:`` to the key - /// object. + /// map from devices to a map from `:` to the key object. /// - /// See the `key algorithms <#key-algorithms>`_ section for information - /// on the Key Object format. + /// See the [key algorithms](/client-server-api/#key-algorithms) section for + /// information on the Key Object format. QHash> oneTimeKeys() const { return loadFromJson>>( @@ -190,26 +222,28 @@ public: * The server should include in the results any users who: * * * currently share a room with the calling user (ie, both users have - * membership state ``join``); *and* + * membership state `join`); *and* * * added new device identity keys or removed an existing device with - * identity keys, between ``from`` and ``to``. + * identity keys, between `from` and `to`. */ class GetKeysChangesJob : public BaseJob { public: /*! \brief Query users with recent device key updates. * * \param from - * The desired start point of the list. Should be the ``next_batch`` field - * from a response to an earlier call to |/sync|. Users who have not + * The desired start point of the list. Should be the `next_batch` field + * from a response to an earlier call to + * [`/sync`](/client-server-api/#get_matrixclientr0sync). Users who have not * uploaded new device identity keys since this point, nor deleted * existing devices with identity keys since then, will be excluded * from the results. * * \param to - * The desired end point of the list. Should be the ``next_batch`` - * field from a recent call to |/sync| - typically the most recent - * such call. This may be used by the server as a hint to check its - * caches are up to date. + * The desired end point of the list. Should be the `next_batch` + * field from a recent call to + * [`/sync`](/client-server-api/#get_matrixclientr0sync) - typically the + * most recent such call. This may be used by the server as a hint to check + * its caches are up to date. */ explicit GetKeysChangesJob(const QString& from, const QString& to); @@ -233,7 +267,10 @@ public: /// The Matrix User IDs of all users who may have left all /// the end-to-end encrypted rooms they previously shared /// with the user. - QStringList left() const { return loadFromJson("left"_ls); } + QStringList left() const + { + return loadFromJson("left"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/kicking.h b/lib/csapi/kicking.h index 2645a54f..11018368 100644 --- a/lib/csapi/kicking.h +++ b/lib/csapi/kicking.h @@ -15,10 +15,10 @@ namespace Quotient { * The caller must have the required power level in order to perform this * operation. * - * Kicking a user adjusts the target member's membership state to be ``leave`` - * with an optional ``reason``. Like with other membership changes, a user can + * Kicking a user adjusts the target member's membership state to be `leave` + * with an optional `reason`. Like with other membership changes, a user can * directly adjust the target member's state by making a request to - * ``/rooms//state/m.room.member/``. + * `/rooms//state/m.room.member/`. */ class KickJob : public BaseJob { public: @@ -32,7 +32,8 @@ public: * * \param reason * The reason the user has been kicked. This will be supplied as the - * ``reason`` on the target's updated `m.room.member`_ event. + * `reason` on the target's updated + * [`m.room.member`](/client-server-api/#mroommember) event. */ explicit KickJob(const QString& roomId, const QString& userId, const QString& reason = {}); diff --git a/lib/csapi/knocking.cpp b/lib/csapi/knocking.cpp new file mode 100644 index 00000000..4b561300 --- /dev/null +++ b/lib/csapi/knocking.cpp @@ -0,0 +1,28 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "knocking.h" + +#include + +using namespace Quotient; + +auto queryToKnockRoom(const QStringList& serverName) +{ + BaseJob::Query _q; + addParam(_q, QStringLiteral("server_name"), serverName); + return _q; +} + +KnockRoomJob::KnockRoomJob(const QString& roomIdOrAlias, + const QStringList& serverName, const QString& reason) + : BaseJob(HttpVerb::Post, QStringLiteral("KnockRoomJob"), + QStringLiteral("/_matrix/client/r0") % "/knock/" % roomIdOrAlias, + queryToKnockRoom(serverName)) +{ + QJsonObject _data; + addParam(_data, QStringLiteral("reason"), reason); + setRequestData(std::move(_data)); + addExpectedKey("room_id"); +} diff --git a/lib/csapi/knocking.h b/lib/csapi/knocking.h new file mode 100644 index 00000000..607b55a9 --- /dev/null +++ b/lib/csapi/knocking.h @@ -0,0 +1,58 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "jobs/basejob.h" + +namespace Quotient { + +/*! \brief Knock on a room, requesting permission to join. + * + * *Note that this API takes either a room ID or alias, unlike other membership + * APIs.* + * + * This API "knocks" on the room to ask for permission to join, if the user + * is allowed to knock on the room. Acceptance of the knock happens out of + * band from this API, meaning that the client will have to watch for updates + * regarding the acceptance/rejection of the knock. + * + * If the room history settings allow, the user will still be able to see + * history of the room while being in the "knock" state. The user will have + * to accept the invitation to join the room (acceptance of knock) to see + * messages reliably. See the `/join` endpoints for more information about + * history visibility to the user. + * + * The knock will appear as an entry in the response of the + * [`/sync`](/client-server-api/#get_matrixclientr0sync) API. + */ +class KnockRoomJob : public BaseJob { +public: + /*! \brief Knock on a room, requesting permission to join. + * + * \param roomIdOrAlias + * The room identifier or alias to knock upon. + * + * \param serverName + * The servers to attempt to knock on the room through. One of the servers + * must be participating in the room. + * + * \param reason + * Optional reason to be included as the `reason` on the subsequent + * membership event. + */ + explicit KnockRoomJob(const QString& roomIdOrAlias, + const QStringList& serverName = {}, + const QString& reason = {}); + + // Result properties + + /// The knocked room ID. + QString roomId() const + { + return loadFromJson("room_id"_ls); + } +}; + +} // namespace Quotient diff --git a/lib/csapi/leaving.cpp b/lib/csapi/leaving.cpp index 8bd170bf..f4c5f120 100644 --- a/lib/csapi/leaving.cpp +++ b/lib/csapi/leaving.cpp @@ -8,18 +8,15 @@ using namespace Quotient; -QUrl LeaveRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/rooms/" % roomId % "/leave"); -} - -LeaveRoomJob::LeaveRoomJob(const QString& roomId) +LeaveRoomJob::LeaveRoomJob(const QString& roomId, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("LeaveRoomJob"), QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/leave") -{} +{ + QJsonObject _data; + addParam(_data, QStringLiteral("reason"), reason); + setRequestData(std::move(_data)); +} QUrl ForgetRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { diff --git a/lib/csapi/leaving.h b/lib/csapi/leaving.h index 1bea7e41..2e402d16 100644 --- a/lib/csapi/leaving.h +++ b/lib/csapi/leaving.h @@ -28,15 +28,12 @@ public: * * \param roomId * The room identifier to leave. - */ - explicit LeaveRoomJob(const QString& roomId); - - /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for LeaveRoomJob - * is necessary but the job itself isn't. + * \param reason + * Optional reason to be included as the `reason` on the subsequent + * membership event. */ - static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); + explicit LeaveRoomJob(const QString& roomId, const QString& reason = {}); }; /*! \brief Stop the requesting user remembering about a particular room. diff --git a/lib/csapi/list_joined_rooms.h b/lib/csapi/list_joined_rooms.h index 1034aa7b..59a24a49 100644 --- a/lib/csapi/list_joined_rooms.h +++ b/lib/csapi/list_joined_rooms.h @@ -26,7 +26,7 @@ public: // Result properties - /// The ID of each room in which the user has ``joined`` membership. + /// The ID of each room in which the user has `joined` membership. QStringList joinedRooms() const { return loadFromJson("joined_rooms"_ls); diff --git a/lib/csapi/list_public_rooms.h b/lib/csapi/list_public_rooms.h index b0cb79d2..1c73c0af 100644 --- a/lib/csapi/list_public_rooms.h +++ b/lib/csapi/list_public_rooms.h @@ -111,12 +111,18 @@ public: /// A pagination token for the response. The absence of this token /// means there are no more results to fetch and the client should /// stop paginating. - QString nextBatch() const { return loadFromJson("next_batch"_ls); } + QString nextBatch() const + { + return loadFromJson("next_batch"_ls); + } /// A pagination token that allows fetching previous results. The /// absence of this token means there are no results before this /// batch, i.e. this is the first batch. - QString prevBatch() const { return loadFromJson("prev_batch"_ls); } + QString prevBatch() const + { + return loadFromJson("prev_batch"_ls); + } /// An estimate on the total number of public rooms, if the /// server has an estimate. @@ -170,7 +176,7 @@ public: * * \param thirdPartyInstanceId * The specific third party network/protocol to request from the - * homeserver. Can only be used if ``include_all_networks`` is false. + * homeserver. Can only be used if `include_all_networks` is false. */ explicit QueryPublicRoomsJob(const QString& server = {}, Omittable limit = none, @@ -190,12 +196,18 @@ public: /// A pagination token for the response. The absence of this token /// means there are no more results to fetch and the client should /// stop paginating. - QString nextBatch() const { return loadFromJson("next_batch"_ls); } + QString nextBatch() const + { + return loadFromJson("next_batch"_ls); + } /// A pagination token that allows fetching previous results. The /// absence of this token means there are no results before this /// batch, i.e. this is the first batch. - QString prevBatch() const { return loadFromJson("prev_batch"_ls); } + QString prevBatch() const + { + return loadFromJson("prev_batch"_ls); + } /// An estimate on the total number of public rooms, if the /// server has an estimate. diff --git a/lib/csapi/login.h b/lib/csapi/login.h index a406fc79..ce783af2 100644 --- a/lib/csapi/login.h +++ b/lib/csapi/login.h @@ -14,17 +14,17 @@ namespace Quotient { /*! \brief Get the supported login types to authenticate users * * Gets the homeserver's supported login types to authenticate users. Clients - * should pick one of these and supply it as the ``type`` when logging in. + * should pick one of these and supply it as the `type` when logging in. */ class GetLoginFlowsJob : public BaseJob { public: // Inner data structures /// Gets the homeserver's supported login types to authenticate users. - /// Clients should pick one of these and supply it as the ``type`` when + /// Clients should pick one of these and supply it as the `type` when /// logging in. struct LoginFlow { - /// The login type. This is supplied as the ``type`` when + /// The login type. This is supplied as the `type` when /// logging in. QString type; }; @@ -64,13 +64,14 @@ struct JsonObjectConverter { * Authenticates the user, and issues an access token they can * use to authorize themself in subsequent requests. * - * If the client does not supply a ``device_id``, the server must + * If the client does not supply a `device_id`, the server must * auto-generate one. * - * The returned access token must be associated with the ``device_id`` + * The returned access token must be associated with the `device_id` * supplied by the client or generated by the server. The server may * invalidate any access token previously associated with that device. See - * `Relationship between access tokens and devices`_. + * [Relationship between access tokens and + * devices](/client-server-api/#relationship-between-access-tokens-and-devices). */ class LoginJob : public BaseJob { public: @@ -83,30 +84,33 @@ public: * Authenticates the user, and issues an access token they can * use to authorize themself in subsequent requests. * - * If the client does not supply a ``device_id``, the server must + * If the client does not supply a `device_id`, the server must * auto-generate one. * - * The returned access token must be associated with the ``device_id`` + * The returned access token must be associated with the `device_id` * supplied by the client or generated by the server. The server may * invalidate any access token previously associated with that device. See - * `Relationship between access tokens and devices`_. + * [Relationship between access tokens and + * devices](/client-server-api/#relationship-between-access-tokens-and-devices). * * \param password - * Required when ``type`` is ``m.login.password``. The user's + * Required when `type` is `m.login.password`. The user's * password. * * \param token - * Required when ``type`` is ``m.login.token``. Part of `Token-based`_ - * login. + * Required when `type` is `m.login.token`. Part of Token-based login. * * \param deviceId * ID of the client device. If this does not correspond to a - * known client device, a new device will be created. The server - * will auto-generate a device_id if this is not specified. + * known client device, a new device will be created. The given + * device ID must not be the same as a + * [cross-signing](/client-server-api/#cross-signing) key ID. + * The server will auto-generate a device_id + * if this is not specified. * * \param initialDeviceDisplayName * A display name to assign to the newly-created device. Ignored - * if ``device_id`` corresponds to a known device. + * if `device_id` corresponds to a known device. */ explicit LoginJob(const QString& type, const Omittable& identifier = none, @@ -117,7 +121,10 @@ public: // Result properties /// The fully-qualified Matrix ID for the account. - QString userId() const { return loadFromJson("user_id"_ls); } + QString userId() const + { + return loadFromJson("user_id"_ls); + } /// An access token for the account. /// This access token can then be used to authorize other requests. @@ -130,8 +137,8 @@ public: /// been registered. /// /// **Deprecated**. Clients should extract the server_name from - /// ``user_id`` (by splitting at the first colon) if they require - /// it. Note also that ``homeserver`` is not spelt this way. + /// `user_id` (by splitting at the first colon) if they require + /// it. Note also that `homeserver` is not spelt this way. QString homeServer() const { return loadFromJson("home_server"_ls); @@ -139,7 +146,10 @@ public: /// ID of the logged-in device. Will be the same as the /// corresponding parameter in the request, if one was specified. - QString deviceId() const { return loadFromJson("device_id"_ls); } + QString deviceId() const + { + return loadFromJson("device_id"_ls); + } /// Optional client configuration provided by the server. If present, /// clients SHOULD use the provided object to reconfigure themselves, diff --git a/lib/csapi/logout.h b/lib/csapi/logout.h index 78f14e40..2e4c2692 100644 --- a/lib/csapi/logout.h +++ b/lib/csapi/logout.h @@ -12,7 +12,8 @@ namespace Quotient { * * Invalidates an existing access token, so that it can no longer be used for * authorization. The device associated with the access token is also deleted. - * `Device keys <#device-keys>`_ for the device are deleted alongside the device. + * [Device keys](/client-server-api/#device-keys) for the device are deleted + * alongside the device. */ class LogoutJob : public BaseJob { public: @@ -31,10 +32,12 @@ public: * * Invalidates all access tokens for a user, so that they can no longer be used * for authorization. This includes the access token that made this request. All - * devices for the user are also deleted. `Device keys <#device-keys>`_ for the - * device are deleted alongside the device. + * devices for the user are also deleted. [Device + * keys](/client-server-api/#device-keys) for the device are deleted alongside + * the device. * - * This endpoint does not use the `User-Interactive Authentication API`_ because + * This endpoint does not use the [User-Interactive Authentication + * API](/client-server-api/#user-interactive-authentication-api) because * User-Interactive Authentication is designed to protect against attacks where * the someone gets hold of a single access token then takes over the account. * This endpoint invalidates all access tokens for the user, including the token diff --git a/lib/csapi/message_pagination.h b/lib/csapi/message_pagination.h index 286d4237..020ef543 100644 --- a/lib/csapi/message_pagination.h +++ b/lib/csapi/message_pagination.h @@ -15,8 +15,8 @@ namespace Quotient { * pagination query parameters to paginate history in the room. * * *Note*: This endpoint supports lazy-loading of room member events. See - * `Lazy-loading room members <#lazy-loading-room-members>`_ for more - * information. + * [Lazy-loading room members](/client-server-api/#lazy-loading-room-members) + * for more information. */ class GetRoomEventsJob : public BaseJob { public: @@ -27,8 +27,8 @@ public: * * \param from * The token to start returning events from. This token can be obtained - * from a ``prev_batch`` token returned for each room by the sync API, - * or from a ``start`` or ``end`` token returned by a previous request + * from a `prev_batch` token returned for each room by the sync API, + * or from a `start` or `end` token returned by a previous request * to this endpoint. * * \param dir @@ -36,8 +36,8 @@ public: * * \param to * The token to stop returning events at. This token can be obtained from - * a ``prev_batch`` token returned for each room by the sync endpoint, - * or from a ``start`` or ``end`` token returned by a previous request to + * a `prev_batch` token returned for each room by the sync endpoint, + * or from a `start` or `end` token returned by a previous request to * this endpoint. * * \param limit @@ -64,29 +64,41 @@ public: // Result properties - /// The token the pagination starts from. If ``dir=b`` this will be - /// the token supplied in ``from``. - QString begin() const { return loadFromJson("start"_ls); } + /// The token the pagination starts from. If `dir=b` this will be + /// the token supplied in `from`. + QString begin() const + { + return loadFromJson("start"_ls); + } - /// The token the pagination ends at. If ``dir=b`` this token should + /// The token the pagination ends at. If `dir=b` this token should /// be used again to request even earlier events. - QString end() const { return loadFromJson("end"_ls); } + QString end() const + { + return loadFromJson("end"_ls); + } - /// A list of room events. The order depends on the ``dir`` parameter. - /// For ``dir=b`` events will be in reverse-chronological order, - /// for ``dir=f`` in chronological order, so that events start - /// at the ``from`` point. - RoomEvents chunk() { return takeFromJson("chunk"_ls); } + /// A list of room events. The order depends on the `dir` parameter. + /// For `dir=b` events will be in reverse-chronological order, + /// for `dir=f` in chronological order, so that events start + /// at the `from` point. + RoomEvents chunk() + { + return takeFromJson("chunk"_ls); + } - /// A list of state events relevant to showing the ``chunk``. For example, if - /// ``lazy_load_members`` is enabled in the filter then this may contain - /// the membership events for the senders of events in the ``chunk``. + /// A list of state events relevant to showing the `chunk`. For example, if + /// `lazy_load_members` is enabled in the filter then this may contain + /// the membership events for the senders of events in the `chunk`. /// - /// Unless ``include_redundant_members`` is ``true``, the server + /// Unless `include_redundant_members` is `true`, the server /// may remove membership events which would have already been /// sent to the client in prior calls to this endpoint, assuming /// the membership of those members has not changed. - StateEvents state() { return takeFromJson("state"_ls); } + StateEvents state() + { + return takeFromJson("state"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/notifications.h b/lib/csapi/notifications.h index ff499c7a..0cc165ce 100644 --- a/lib/csapi/notifications.h +++ b/lib/csapi/notifications.h @@ -22,7 +22,7 @@ public: /// user has been, or would have been notified about. struct Notification { /// The action(s) to perform when the conditions for this rule are met. - /// See `Push Rules: API`_. + /// See [Push Rules: API](/client-server-api/#push-rules-api). QVector actions; /// The Event object for the event that triggered the notification. EventPtr event; @@ -35,7 +35,7 @@ public: QString roomId; /// The unix timestamp at which the event notification was sent, /// in milliseconds. - int ts; + qint64 ts; }; // Construction/destruction @@ -49,7 +49,7 @@ public: * Limit on the number of events to return in this request. * * \param only - * Allows basic filtering of events returned. Supply ``highlight`` + * Allows basic filtering of events returned. Supply `highlight` * to return only events where the notification had the highlight * tweak set. */ @@ -68,10 +68,13 @@ public: // Result properties - /// The token to supply in the ``from`` param of the next - /// ``/notifications`` request in order to request more + /// The token to supply in the `from` param of the next + /// `/notifications` request in order to request more /// events. If this is absent, there are no more results. - QString nextToken() const { return loadFromJson("next_token"_ls); } + QString nextToken() const + { + return loadFromJson("next_token"_ls); + } /// The list of events that triggered notifications. std::vector notifications() diff --git a/lib/csapi/openid.h b/lib/csapi/openid.h index efb5f623..88218c20 100644 --- a/lib/csapi/openid.h +++ b/lib/csapi/openid.h @@ -18,7 +18,7 @@ namespace Quotient { * OpenID. * * The access token generated is only valid for the OpenID API. It cannot - * be used to request another OpenID access token or call ``/sync``, for + * be used to request another OpenID access token or call `/sync`, for * example. */ class RequestOpenIdTokenJob : public BaseJob { @@ -38,11 +38,15 @@ public: // Result properties /// OpenID token information. This response is nearly compatible with the - /// response documented in the `OpenID Connect 1.0 Specification - /// `_ - /// with the only difference being the lack of an ``id_token``. Instead, + /// response documented in the + /// [OpenID Connect 1.0 + /// Specification](http://openid.net/specs/openid-connect-core-1_0.html#TokenResponse) + /// with the only difference being the lack of an `id_token`. Instead, /// the Matrix homeserver's name is provided. - OpenidToken tokenData() const { return fromJson(jsonData()); } + OpenidToken tokenData() const + { + return fromJson(jsonData()); + } }; } // namespace Quotient diff --git a/lib/csapi/peeking_events.h b/lib/csapi/peeking_events.h index cecd9f2d..1eee880f 100644 --- a/lib/csapi/peeking_events.h +++ b/lib/csapi/peeking_events.h @@ -13,12 +13,12 @@ namespace Quotient { * * This will listen for new events related to a particular room and return * them to the caller. This will block until an event is received, or until - * the ``timeout`` is reached. + * the `timeout` is reached. * - * This API is the same as the normal ``/events`` endpoint, but can be + * This API is the same as the normal `/events` endpoint, but can be * called by users who have not joined the room. * - * Note that the normal ``/events`` endpoint has been deprecated. This + * Note that the normal `/events` endpoint has been deprecated. This * API will also be deprecated at some point, but its replacement is not * yet known. */ @@ -51,16 +51,25 @@ public: // Result properties - /// A token which correlates to the first value in ``chunk``. This - /// is usually the same token supplied to ``from=``. - QString begin() const { return loadFromJson("start"_ls); } + /// A token which correlates to the first value in `chunk`. This + /// is usually the same token supplied to `from=`. + QString begin() const + { + return loadFromJson("start"_ls); + } - /// A token which correlates to the last value in ``chunk``. This - /// token should be used in the next request to ``/events``. - QString end() const { return loadFromJson("end"_ls); } + /// A token which correlates to the last value in `chunk`. This + /// token should be used in the next request to `/events`. + QString end() const + { + return loadFromJson("end"_ls); + } /// An array of events. - RoomEvents chunk() { return takeFromJson("chunk"_ls); } + RoomEvents chunk() + { + return takeFromJson("chunk"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/presence.h b/lib/csapi/presence.h index a885bf4f..c817ad9f 100644 --- a/lib/csapi/presence.h +++ b/lib/csapi/presence.h @@ -12,7 +12,7 @@ namespace Quotient { * * This API sets the given user's presence state. When setting the status, * the activity time is updated to reflect that activity; the client does - * not need to specify the ``last_active_ago`` field. You cannot set the + * not need to specify the `last_active_ago` field. You cannot set the * presence state of another user. */ class SetPresenceJob : public BaseJob { @@ -55,7 +55,10 @@ public: // Result properties /// This user's presence. - QString presence() const { return loadFromJson("presence"_ls); } + QString presence() const + { + return loadFromJson("presence"_ls); + } /// The length of time in milliseconds since an action was performed /// by this user. @@ -65,7 +68,10 @@ public: } /// The state message for this user if one was set. - QString statusMsg() const { return loadFromJson("status_msg"_ls); } + QString statusMsg() const + { + return loadFromJson("status_msg"_ls); + } /// Whether the user is currently active Omittable currentlyActive() const diff --git a/lib/csapi/profile.h b/lib/csapi/profile.h index 3858fab2..3cda34f8 100644 --- a/lib/csapi/profile.h +++ b/lib/csapi/profile.h @@ -11,7 +11,7 @@ namespace Quotient { /*! \brief Set the user's display name. * * This API sets the given user's display name. You must have permission to - * set this user's display name, e.g. you need to have their ``access_token``. + * set this user's display name, e.g. you need to have their `access_token`. */ class SetDisplayNameJob : public BaseJob { public: @@ -61,7 +61,7 @@ public: /*! \brief Set the user's avatar URL. * * This API sets the given user's avatar URL. You must have permission to - * set this user's avatar URL, e.g. you need to have their ``access_token``. + * set this user's avatar URL, e.g. you need to have their `access_token`. */ class SetAvatarUrlJob : public BaseJob { public: @@ -101,7 +101,10 @@ public: // Result properties /// The user's avatar URL if they have set one, otherwise not present. - QString avatarUrl() const { return loadFromJson("avatar_url"_ls); } + QString avatarUrl() const + { + return loadFromJson("avatar_url"_ls); + } }; /*! \brief Get this user's profile information. @@ -109,7 +112,7 @@ public: * Get the combined profile information for this user. This API may be used * to fetch the user's own profile information or other users; either * locally or on remote homeservers. This API may return keys which are not - * limited to ``displayname`` or ``avatar_url``. + * limited to `displayname` or `avatar_url`. */ class GetUserProfileJob : public BaseJob { public: @@ -130,7 +133,10 @@ public: // Result properties /// The user's avatar URL if they have set one, otherwise not present. - QString avatarUrl() const { return loadFromJson("avatar_url"_ls); } + QString avatarUrl() const + { + return loadFromJson("avatar_url"_ls); + } /// The user's display name if they have set one, otherwise not present. QString displayname() const diff --git a/lib/csapi/pusher.h b/lib/csapi/pusher.h index ae0050d2..13c9ec25 100644 --- a/lib/csapi/pusher.h +++ b/lib/csapi/pusher.h @@ -19,7 +19,7 @@ public: /// A dictionary of information for the pusher implementation /// itself. struct PusherData { - /// Required if ``kind`` is ``http``. The URL to use to send + /// Required if `kind` is `http`. The URL to use to send /// notifications to. QString url; /// The format to use when sending notifications to the Push @@ -29,11 +29,11 @@ public: /// Gets all currently active pushers for the authenticated user. struct Pusher { - /// This is a unique identifier for this pusher. See ``/set`` for + /// This is a unique identifier for this pusher. See `/set` for /// more detail. /// Max length, 512 bytes. QString pushkey; - /// The kind of pusher. ``"http"`` is a pusher that + /// The kind of pusher. `"http"` is a pusher that /// sends HTTP pokes. QString kind; /// This is a reverse-DNS style identifier for the application. @@ -104,27 +104,27 @@ struct JsonObjectConverter { /*! \brief Modify a pusher for this user on the homeserver. * - * This endpoint allows the creation, modification and deletion of `pushers`_ - * for this user ID. The behaviour of this endpoint varies depending on the - * values in the JSON body. + * This endpoint allows the creation, modification and deletion of + * [pushers](/client-server-api/#push-notifications) for this user ID. The + * behaviour of this endpoint varies depending on the values in the JSON body. */ class PostPusherJob : public BaseJob { public: // Inner data structures /// A dictionary of information for the pusher implementation - /// itself. If ``kind`` is ``http``, this should contain ``url`` + /// itself. If `kind` is `http`, this should contain `url` /// which is the URL to use to send notifications to. struct PusherData { - /// Required if ``kind`` is ``http``. The URL to use to send + /// Required if `kind` is `http`. The URL to use to send /// notifications to. MUST be an HTTPS URL with a path of - /// ``/_matrix/push/v1/notify``. + /// `/_matrix/push/v1/notify`. QString url; /// The format to send notifications in to Push Gateways if the - /// ``kind`` is ``http``. The details about what fields the + /// `kind` is `http`. The details about what fields the /// homeserver should send to the push gateway are defined in the - /// `Push Gateway Specification`_. Currently the only format - /// available is 'event_id_only'. + /// [Push Gateway Specification](/push-gateway-api/). Currently the only + /// format available is 'event_id_only'. QString format; }; @@ -140,13 +140,13 @@ public: * client has no such concept, use any unique identifier. * Max length, 512 bytes. * - * If the ``kind`` is ``"email"``, this is the email address to + * If the `kind` is `"email"`, this is the email address to * send notifications to. * * \param kind - * The kind of pusher to configure. ``"http"`` makes a pusher that - * sends HTTP pokes. ``"email"`` makes a pusher that emails the - * user with unread notifications. ``null`` deletes the pusher. + * The kind of pusher to configure. `"http"` makes a pusher that + * sends HTTP pokes. `"email"` makes a pusher that emails the + * user with unread notifications. `null` deletes the pusher. * * \param appId * This is a reverse-DNS style identifier for the application. @@ -154,7 +154,7 @@ public: * different platform versions get different app identifiers. * Max length, 64 chars. * - * If the ``kind`` is ``"email"``, this is ``"m.email"``. + * If the `kind` is `"email"`, this is `"m.email"`. * * \param appDisplayName * A string that will allow the user to identify what application @@ -170,7 +170,7 @@ public: * * \param data * A dictionary of information for the pusher implementation - * itself. If ``kind`` is ``http``, this should contain ``url`` + * itself. If `kind` is `http`, this should contain `url` * which is the URL to use to send notifications to. * * \param profileTag @@ -182,7 +182,7 @@ public: * given pushkey and App ID in addition to any others with * different user IDs. Otherwise, the homeserver must remove any * other pushers with the same App ID and pushkey for different - * users. The default is ``false``. + * users. The default is `false`. */ explicit PostPusherJob(const QString& pushkey, const QString& kind, const QString& appId, const QString& appDisplayName, diff --git a/lib/csapi/pushrules.h b/lib/csapi/pushrules.h index 1c6d5c2d..90d2ce79 100644 --- a/lib/csapi/pushrules.h +++ b/lib/csapi/pushrules.h @@ -15,9 +15,9 @@ namespace Quotient { /*! \brief Retrieve all push rulesets. * * Retrieve all push rulesets for this user. Clients can "drill-down" on - * the rulesets by suffixing a ``scope`` to this path e.g. - * ``/pushrules/global/``. This will return a subset of this data under the - * specified key e.g. the ``global`` key. + * the rulesets by suffixing a `scope` to this path e.g. + * `/pushrules/global/`. This will return a subset of this data under the + * specified key e.g. the `global` key. */ class GetPushRulesJob : public BaseJob { public: @@ -49,7 +49,7 @@ public: /*! \brief Retrieve a push rule. * * \param scope - * ``global`` to specify global rules. + * `global` to specify global rules. * * \param kind * The kind of rule @@ -71,8 +71,11 @@ public: // Result properties /// The specific push rule. This will also include keys specific to the - /// rule itself such as the rule's ``actions`` and ``conditions`` if set. - PushRule pushRule() const { return fromJson(jsonData()); } + /// rule itself such as the rule's `actions` and `conditions` if set. + PushRule pushRule() const + { + return fromJson(jsonData()); + } }; /*! \brief Delete a push rule. @@ -84,7 +87,7 @@ public: /*! \brief Delete a push rule. * * \param scope - * ``global`` to specify global rules. + * `global` to specify global rules. * * \param kind * The kind of rule @@ -117,7 +120,7 @@ public: /*! \brief Add or change a push rule. * * \param scope - * ``global`` to specify global rules. + * `global` to specify global rules. * * \param kind * The kind of rule @@ -129,7 +132,7 @@ public: * The action(s) to perform when the conditions for this rule are met. * * \param before - * Use 'before' with a ``rule_id`` as its value to make the new rule the + * Use 'before' with a `rule_id` as its value to make the new rule the * next-most important rule with respect to the given user defined rule. * It is not possible to add a rule relative to a predefined server rule. * @@ -141,10 +144,10 @@ public: * \param conditions * The conditions that must hold true for an event in order for a * rule to be applied to an event. A rule with no conditions - * always matches. Only applicable to ``underride`` and ``override`` rules. + * always matches. Only applicable to `underride` and `override` rules. * * \param pattern - * Only applicable to ``content`` rules. The glob-style pattern to match + * Only applicable to `content` rules. The glob-style pattern to match * against. */ explicit SetPushRuleJob(const QString& scope, const QString& kind, @@ -165,8 +168,8 @@ public: /*! \brief Get whether a push rule is enabled * * \param scope - * Either ``global`` or ``device/`` to specify global - * rules or device rules for the given ``profile_tag``. + * Either `global` or `device/` to specify global + * rules or device rules for the given `profile_tag`. * * \param kind * The kind of rule @@ -188,7 +191,10 @@ public: // Result properties /// Whether the push rule is enabled or not. - bool enabled() const { return loadFromJson("enabled"_ls); } + bool enabled() const + { + return loadFromJson("enabled"_ls); + } }; /*! \brief Enable or disable a push rule. @@ -200,7 +206,7 @@ public: /*! \brief Enable or disable a push rule. * * \param scope - * ``global`` to specify global rules. + * `global` to specify global rules. * * \param kind * The kind of rule @@ -224,8 +230,8 @@ public: /*! \brief The actions for a push rule * * \param scope - * Either ``global`` or ``device/`` to specify global - * rules or device rules for the given ``profile_tag``. + * Either `global` or `device/` to specify global + * rules or device rules for the given `profile_tag`. * * \param kind * The kind of rule @@ -263,7 +269,7 @@ public: /*! \brief Set the actions for a push rule. * * \param scope - * ``global`` to specify global rules. + * `global` to specify global rules. * * \param kind * The kind of rule diff --git a/lib/csapi/read_markers.h b/lib/csapi/read_markers.h index 0e122c63..00a2aa0d 100644 --- a/lib/csapi/read_markers.h +++ b/lib/csapi/read_markers.h @@ -26,7 +26,7 @@ public: * * \param mRead * The event ID to set the read receipt location at. This is - * equivalent to calling ``/receipt/m.read/$elsewhere:example.org`` + * equivalent to calling `/receipt/m.read/$elsewhere:example.org` * and is provided here to save that extra call. */ explicit SetReadMarkerJob(const QString& roomId, const QString& mFullyRead, diff --git a/lib/csapi/receipts.h b/lib/csapi/receipts.h index 1fac0acf..7ac093cd 100644 --- a/lib/csapi/receipts.h +++ b/lib/csapi/receipts.h @@ -27,8 +27,8 @@ public: * The event ID to acknowledge up to. * * \param receipt - * Extra receipt information to attach to ``content`` if any. The - * server will automatically set the ``ts`` field. + * Extra receipt information to attach to `content` if any. The + * server will automatically set the `ts` field. */ explicit PostReceiptJob(const QString& roomId, const QString& receiptType, const QString& eventId, diff --git a/lib/csapi/redaction.h b/lib/csapi/redaction.h index 541e433a..f12e6b71 100644 --- a/lib/csapi/redaction.h +++ b/lib/csapi/redaction.h @@ -15,9 +15,12 @@ namespace Quotient { * * This cannot be undone. * - * Users may redact their own events, and any user with a power level - * greater than or equal to the ``redact`` power level of the room may - * redact events there. + * Any user with a power level greater than or equal to the `m.room.redaction` + * event power level may send redaction events in the room. If the user's power + * level greater is also greater than or equal to the `redact` power level + * of the room, the user may redact events sent by other users. + * + * Server administrators may redact events sent by users on their server. */ class RedactEventJob : public BaseJob { public: @@ -43,7 +46,10 @@ public: // Result properties /// A unique identifier for the event. - QString eventId() const { return loadFromJson("event_id"_ls); } + QString eventId() const + { + return loadFromJson("event_id"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/registration.h b/lib/csapi/registration.h index 6864fd47..0ad8b101 100644 --- a/lib/csapi/registration.h +++ b/lib/csapi/registration.h @@ -15,8 +15,9 @@ namespace Quotient { /*! \brief Register for an account on this homeserver. * - * This API endpoint uses the `User-Interactive Authentication API`_, except in - * the cases where a guest account is being registered. + * This API endpoint uses the [User-Interactive Authentication + * API](/client-server-api/#user-interactive-authentication-api), except in the + * cases where a guest account is being registered. * * Register for an account on this homeserver. * @@ -31,45 +32,46 @@ namespace Quotient { * If registration is successful, this endpoint will issue an access token * the client can use to authorize itself in subsequent requests. * - * If the client does not supply a ``device_id``, the server must + * If the client does not supply a `device_id`, the server must * auto-generate one. * * The server SHOULD register an account with a User ID based on the - * ``username`` provided, if any. Note that the grammar of Matrix User ID + * `username` provided, if any. Note that the grammar of Matrix User ID * localparts is restricted, so the server MUST either map the provided - * ``username`` onto a ``user_id`` in a logical manner, or reject - * ``username``\s which do not comply to the grammar, with - * ``M_INVALID_USERNAME``. + * `username` onto a `user_id` in a logical manner, or reject + * `username`\s which do not comply to the grammar, with + * `M_INVALID_USERNAME`. * * Matrix clients MUST NOT assume that localpart of the registered - * ``user_id`` matches the provided ``username``. + * `user_id` matches the provided `username`. * - * The returned access token must be associated with the ``device_id`` + * The returned access token must be associated with the `device_id` * supplied by the client or generated by the server. The server may * invalidate any access token previously associated with that device. See - * `Relationship between access tokens and devices`_. + * [Relationship between access tokens and + * devices](/client-server-api/#relationship-between-access-tokens-and-devices). * * When registering a guest account, all parameters in the request body - * with the exception of ``initial_device_display_name`` MUST BE ignored - * by the server. The server MUST pick a ``device_id`` for the account + * with the exception of `initial_device_display_name` MUST BE ignored + * by the server. The server MUST pick a `device_id` for the account * regardless of input. * * Any user ID returned by this API must conform to the grammar given in the - * `Matrix specification <../appendices.html#user-identifiers>`_. + * [Matrix specification](/appendices/#user-identifiers). */ class RegisterJob : public BaseJob { public: /*! \brief Register for an account on this homeserver. * * \param kind - * The kind of account to register. Defaults to ``user``. + * The kind of account to register. Defaults to `user`. * * \param auth * Additional authentication information for the * user-interactive authentication API. Note that this * information is *not* used to define how the registered user * should be authenticated, but is instead used to - * authenticate the ``register`` call itself. + * authenticate the `register` call itself. * * \param username * The basis for the localpart of the desired Matrix ID. If omitted, @@ -85,10 +87,10 @@ public: * * \param initialDeviceDisplayName * A display name to assign to the newly-created device. Ignored - * if ``device_id`` corresponds to a known device. + * if `device_id` corresponds to a known device. * * \param inhibitLogin - * If true, an ``access_token`` and ``device_id`` should not be + * If true, an `access_token` and `device_id` should not be * returned from this call, therefore preventing an automatic * login. Defaults to false. */ @@ -105,12 +107,15 @@ public: /// The fully-qualified Matrix user ID (MXID) that has been registered. /// /// Any user ID returned by this API must conform to the grammar given in - /// the `Matrix specification <../appendices.html#user-identifiers>`_. - QString userId() const { return loadFromJson("user_id"_ls); } + /// the [Matrix specification](/appendices/#user-identifiers). + QString userId() const + { + return loadFromJson("user_id"_ls); + } /// An access token for the account. /// This access token can then be used to authorize other requests. - /// Required if the ``inhibit_login`` option is false. + /// Required if the `inhibit_login` option is false. QString accessToken() const { return loadFromJson("access_token"_ls); @@ -120,8 +125,8 @@ public: /// been registered. /// /// **Deprecated**. Clients should extract the server_name from - /// ``user_id`` (by splitting at the first colon) if they require - /// it. Note also that ``homeserver`` is not spelt this way. + /// `user_id` (by splitting at the first colon) if they require + /// it. Note also that `homeserver` is not spelt this way. QString homeServer() const { return loadFromJson("home_server"_ls); @@ -129,8 +134,11 @@ public: /// ID of the registered device. Will be the same as the /// corresponding parameter in the request, if one was specified. - /// Required if the ``inhibit_login`` option is false. - QString deviceId() const { return loadFromJson("device_id"_ls); } + /// Required if the `inhibit_login` option is false. + QString deviceId() const + { + return loadFromJson("device_id"_ls); + } }; /*! \brief Begins the validation process for an email to be used during @@ -201,9 +209,9 @@ public: * * Changes the password for an account on this homeserver. * - * This API endpoint uses the `User-Interactive Authentication API`_ to - * ensure the user changing the password is actually the owner of the - * account. + * This API endpoint uses the [User-Interactive Authentication + * API](/client-server-api/#user-interactive-authentication-api) to ensure the + * user changing the password is actually the owner of the account. * * An access token should be submitted to this endpoint if the client has * an active session. @@ -224,8 +232,8 @@ public: * Whether the user's other access tokens, and their associated devices, * should be revoked if the request succeeds. * - * When ``false``, the server can still take advantage of `the soft logout - * method <#soft-logout>`_ for the user's remaining devices. + * When `false`, the server can still take advantage of the [soft logout + * method](/client-server-api/#soft-logout) for the user's remaining devices. * * \param auth * Additional authentication information for the user-interactive @@ -242,23 +250,18 @@ public: * The homeserver must check that the given email address **is * associated** with an account on this homeserver. This API should be * used to request validation tokens when authenticating for the - * ``/account/password`` endpoint. + * `/account/password` endpoint. * * This API's parameters and response are identical to that of the - * |/register/email/requestToken|_ endpoint, except that - * ``M_THREEPID_NOT_FOUND`` may be returned if no account matching the + * [`/register/email/requestToken`](/client-server-api/#post_matrixclientr0registeremailrequesttoken) + * endpoint, except that + * `M_THREEPID_NOT_FOUND` may be returned if no account matching the * given email address could be found. The server may instead send an * email to the given address prompting the user to create an account. - * ``M_THREEPID_IN_USE`` may not be returned. + * `M_THREEPID_IN_USE` may not be returned. * * The homeserver should validate the email itself, either by sending a * validation email itself or by using a service it has control over. - * - * - * .. |/register/email/requestToken| replace:: ``/register/email/requestToken`` - * - * .. _/register/email/requestToken: - * #post-matrix-client-r0-register-email-requesttoken */ class RequestTokenToResetPasswordEmailJob : public BaseJob { public: @@ -269,24 +272,18 @@ public: * The homeserver must check that the given email address **is * associated** with an account on this homeserver. This API should be * used to request validation tokens when authenticating for the - * ``/account/password`` endpoint. + * `/account/password` endpoint. * * This API's parameters and response are identical to that of the - * |/register/email/requestToken|_ endpoint, except that - * ``M_THREEPID_NOT_FOUND`` may be returned if no account matching the + * [`/register/email/requestToken`](/client-server-api/#post_matrixclientr0registeremailrequesttoken) + * endpoint, except that + * `M_THREEPID_NOT_FOUND` may be returned if no account matching the * given email address could be found. The server may instead send an * email to the given address prompting the user to create an account. - * ``M_THREEPID_IN_USE`` may not be returned. + * `M_THREEPID_IN_USE` may not be returned. * * The homeserver should validate the email itself, either by sending a * validation email itself or by using a service it has control over. - * - * - * .. |/register/email/requestToken| replace:: - * ``/register/email/requestToken`` - * - * .. _/register/email/requestToken: - * #post-matrix-client-r0-register-email-requesttoken */ explicit RequestTokenToResetPasswordEmailJob(const EmailValidationData& body); @@ -305,22 +302,18 @@ public: * The homeserver must check that the given phone number **is * associated** with an account on this homeserver. This API should be * used to request validation tokens when authenticating for the - * ``/account/password`` endpoint. + * `/account/password` endpoint. * * This API's parameters and response are identical to that of the - * |/register/msisdn/requestToken|_ endpoint, except that - * ``M_THREEPID_NOT_FOUND`` may be returned if no account matching the + * [`/register/msisdn/requestToken`](/client-server-api/#post_matrixclientr0registermsisdnrequesttoken) + * endpoint, except that + * `M_THREEPID_NOT_FOUND` may be returned if no account matching the * given phone number could be found. The server may instead send the SMS * to the given phone number prompting the user to create an account. - * ``M_THREEPID_IN_USE`` may not be returned. + * `M_THREEPID_IN_USE` may not be returned. * * The homeserver should validate the phone number itself, either by sending a * validation message itself or by using a service it has control over. - * - * .. |/register/msisdn/requestToken| replace:: ``/register/msisdn/requestToken`` - * - * .. _/register/msisdn/requestToken: - * #post-matrix-client-r0-register-email-requesttoken */ class RequestTokenToResetPasswordMSISDNJob : public BaseJob { public: @@ -331,23 +324,18 @@ public: * The homeserver must check that the given phone number **is * associated** with an account on this homeserver. This API should be * used to request validation tokens when authenticating for the - * ``/account/password`` endpoint. + * `/account/password` endpoint. * * This API's parameters and response are identical to that of the - * |/register/msisdn/requestToken|_ endpoint, except that - * ``M_THREEPID_NOT_FOUND`` may be returned if no account matching the + * [`/register/msisdn/requestToken`](/client-server-api/#post_matrixclientr0registermsisdnrequesttoken) + * endpoint, except that + * `M_THREEPID_NOT_FOUND` may be returned if no account matching the * given phone number could be found. The server may instead send the SMS * to the given phone number prompting the user to create an account. - * ``M_THREEPID_IN_USE`` may not be returned. + * `M_THREEPID_IN_USE` may not be returned. * * The homeserver should validate the phone number itself, either by sending * a validation message itself or by using a service it has control over. - * - * .. |/register/msisdn/requestToken| replace:: - * ``/register/msisdn/requestToken`` - * - * .. _/register/msisdn/requestToken: - * #post-matrix-client-r0-register-email-requesttoken */ explicit RequestTokenToResetPasswordMSISDNJob( const MsisdnValidationData& body); @@ -366,7 +354,8 @@ public: * Deactivate the user's account, removing all ability for the user to * login again. * - * This API endpoint uses the `User-Interactive Authentication API`_. + * This API endpoint uses the [User-Interactive Authentication + * API](/client-server-api/#user-interactive-authentication-api). * * An access token should be submitted to this endpoint if the client has * an active session. @@ -374,7 +363,7 @@ public: * The homeserver may change the flows available depending on whether a * valid access token is provided. * - * Unlike other endpoints, this endpoint does not take an ``id_access_token`` + * Unlike other endpoints, this endpoint does not take an `id_access_token` * parameter because the homeserver is expected to sign the request to the * identity server instead. */ @@ -388,11 +377,11 @@ public: * * \param idServer * The identity server to unbind all of the user's 3PIDs from. - * If not provided, the homeserver MUST use the ``id_server`` + * If not provided, the homeserver MUST use the `id_server` * that was originally use to bind each identifier. If the - * homeserver does not know which ``id_server`` that was, - * it must return an ``id_server_unbind_result`` of - * ``no-support``. + * homeserver does not know which `id_server` that was, + * it must return an `id_server_unbind_result` of + * `no-support`. */ explicit DeactivateAccountJob(const Omittable& auth = none, const QString& idServer = {}); @@ -400,12 +389,12 @@ public: // Result properties /// An indicator as to whether or not the homeserver was able to unbind - /// the user's 3PIDs from the identity server(s). ``success`` indicates + /// the user's 3PIDs from the identity server(s). `success` indicates /// that all identifiers have been unbound from the identity server while - /// ``no-support`` indicates that one or more identifiers failed to unbind + /// `no-support` indicates that one or more identifiers failed to unbind /// due to the identity server refusing the request or the homeserver /// being unable to determine an identity server to unbind from. This - /// must be ``success`` if the homeserver has no identifiers to unbind + /// must be `success` if the homeserver has no identifiers to unbind /// for the user. QString idServerUnbindResult() const { @@ -447,7 +436,7 @@ public: // Result properties /// A flag to indicate that the username is available. This should always - /// be ``true`` when the server replies with 200 OK. + /// be `true` when the server replies with 200 OK. Omittable available() const { return loadFromJson>("available"_ls); diff --git a/lib/csapi/report_content.cpp b/lib/csapi/report_content.cpp index 0a41625f..ea906380 100644 --- a/lib/csapi/report_content.cpp +++ b/lib/csapi/report_content.cpp @@ -9,13 +9,13 @@ using namespace Quotient; ReportContentJob::ReportContentJob(const QString& roomId, const QString& eventId, - int score, const QString& reason) + Omittable score, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("ReportContentJob"), QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/report/" % eventId) { QJsonObject _data; - addParam<>(_data, QStringLiteral("score"), score); - addParam<>(_data, QStringLiteral("reason"), reason); + addParam(_data, QStringLiteral("score"), score); + addParam(_data, QStringLiteral("reason"), reason); setRequestData(std::move(_data)); } diff --git a/lib/csapi/report_content.h b/lib/csapi/report_content.h index 375e1829..e401c2e1 100644 --- a/lib/csapi/report_content.h +++ b/lib/csapi/report_content.h @@ -31,7 +31,8 @@ public: * The reason the content is being reported. May be blank. */ explicit ReportContentJob(const QString& roomId, const QString& eventId, - int score, const QString& reason); + Omittable score = none, + const QString& reason = {}); }; } // namespace Quotient diff --git a/lib/csapi/room_send.h b/lib/csapi/room_send.h index 39460aca..a9e7ca13 100644 --- a/lib/csapi/room_send.h +++ b/lib/csapi/room_send.h @@ -16,7 +16,7 @@ namespace Quotient { * * The body of the request should be the content object of the event; the * fields in this object will vary depending on the type of event. See - * `Room Events`_ for the m. event specification. + * [Room Events](/client-server-api/#room-events) for the m. event specification. */ class SendMessageJob : public BaseJob { public: @@ -40,7 +40,8 @@ public: * * The body of the request should be the content object of the event; the * fields in this object will vary depending on the type of event. See - * `Room Events`_ for the m. event specification. + * [Room Events](/client-server-api/#room-events) for the m. event + * specification. */ explicit SendMessageJob(const QString& roomId, const QString& eventType, const QString& txnId, const QJsonObject& body = {}); @@ -48,7 +49,10 @@ public: // Result properties /// A unique identifier for the event. - QString eventId() const { return loadFromJson("event_id"_ls); } + QString eventId() const + { + return loadFromJson("event_id"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/room_state.h b/lib/csapi/room_state.h index 447605ff..99eb4fc9 100644 --- a/lib/csapi/room_state.h +++ b/lib/csapi/room_state.h @@ -9,23 +9,21 @@ namespace Quotient { /*! \brief Send a state event to the given room. - * - * .. For backwards compatibility with older links... - * .. _`put-matrix-client-r0-rooms-roomid-state-eventtype`: * * State events can be sent using this endpoint. These events will be - * overwritten if ````, ```` and ```` all + * overwritten if ``, `` and `` all * match. * * Requests to this endpoint **cannot use transaction IDs** - * like other ``PUT`` paths because they cannot be differentiated from the - * ``state_key``. Furthermore, ``POST`` is unsupported on state paths. + * like other `PUT` paths because they cannot be differentiated from the + * `state_key`. Furthermore, `POST` is unsupported on state paths. * * The body of the request should be the content object of the event; the * fields in this object will vary depending on the type of event. See - * `Room Events`_ for the ``m.`` event specification. + * [Room Events](/client-server-api/#room-events) for the `m.` event + * specification. * - * If the event type being sent is ``m.room.canonical_alias`` servers + * If the event type being sent is `m.room.canonical_alias` servers * SHOULD ensure that any new aliases being listed in the event are valid * per their grammar/syntax and that they point to the room ID where the * state event is to be sent. Servers do not validate aliases which are @@ -46,22 +44,20 @@ public: * an empty string, the trailing slash on this endpoint is optional. * * \param body - * .. For backwards compatibility with older links... - * .. _`put-matrix-client-r0-rooms-roomid-state-eventtype`: - * * State events can be sent using this endpoint. These events will be - * overwritten if ````, ```` and ```` all + * overwritten if ``, `` and `` all * match. * * Requests to this endpoint **cannot use transaction IDs** - * like other ``PUT`` paths because they cannot be differentiated from the - * ``state_key``. Furthermore, ``POST`` is unsupported on state paths. + * like other `PUT` paths because they cannot be differentiated from the + * `state_key`. Furthermore, `POST` is unsupported on state paths. * * The body of the request should be the content object of the event; the * fields in this object will vary depending on the type of event. See - * `Room Events`_ for the ``m.`` event specification. + * [Room Events](/client-server-api/#room-events) for the `m.` event + * specification. * - * If the event type being sent is ``m.room.canonical_alias`` servers + * If the event type being sent is `m.room.canonical_alias` servers * SHOULD ensure that any new aliases being listed in the event are valid * per their grammar/syntax and that they point to the room ID where the * state event is to be sent. Servers do not validate aliases which are @@ -75,7 +71,10 @@ public: // Result properties /// A unique identifier for the event. - QString eventId() const { return loadFromJson("event_id"_ls); } + QString eventId() const + { + return loadFromJson("event_id"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/rooms.h b/lib/csapi/rooms.h index f0bfa349..179d7a27 100644 --- a/lib/csapi/rooms.h +++ b/lib/csapi/rooms.h @@ -12,7 +12,7 @@ namespace Quotient { /*! \brief Get a single event by event ID. * - * Get a single event based on ``roomId/eventId``. You must have permission to + * Get a single event based on `roomId/eventId`. You must have permission to * retrieve this event e.g. by being a member in the room for this event. */ class GetOneRoomEventJob : public BaseJob { @@ -38,13 +38,14 @@ public: // Result properties /// The full event. - EventPtr event() { return fromJson(jsonData()); } + EventPtr event() + + { + return fromJson(jsonData()); + } }; /*! \brief Get the state identified by the type and key. - * - * .. For backwards compatibility with older links... - * .. _`get-matrix-client-r0-rooms-roomid-state-eventtype`: * * Looks up the contents of a state event in a room. If the user is * joined to the room then the state is taken from the current @@ -102,7 +103,11 @@ public: // Result properties /// The current state of the room - StateEvents events() { return fromJson(jsonData()); } + StateEvents events() + + { + return fromJson(jsonData()); + } }; /*! \brief Get the m.room.member events for the room. @@ -118,16 +123,15 @@ public: * * \param at * The point in time (pagination token) to return members for in the room. - * This token can be obtained from a ``prev_batch`` token returned for + * This token can be obtained from a `prev_batch` token returned for * each room by the sync API. Defaults to the current state of the room, * as determined by the server. * * \param membership * The kind of membership to filter for. Defaults to no filtering if - * unspecified. When specified alongside ``not_membership``, the two + * unspecified. When specified alongside `not_membership`, the two * parameters create an 'or' condition: either the membership *is* - * the same as ``membership`` **or** *is not* the same as - * ``not_membership``. + * the same as `membership` **or** *is not* the same as `not_membership`. * * \param notMembership * The kind of membership to exclude from the results. Defaults to no @@ -162,7 +166,7 @@ public: * room. The current user must be in the room for it to work, unless it is an * Application Service in which case any of the AS's users must be in the room. * This API is primarily for Application Services and should be faster to - * respond than ``/members`` as it can be implemented more efficiently on the + * respond than `/members` as it can be implemented more efficiently on the * server. */ class GetJoinedMembersByRoomJob : public BaseJob { @@ -173,7 +177,7 @@ public: /// the room. The current user must be in the room for it to work, unless it /// is an Application Service in which case any of the AS's users must be in /// the room. This API is primarily for Application Services and should be - /// faster to respond than ``/members`` as it can be implemented more + /// faster to respond than `/members` as it can be implemented more /// efficiently on the server. struct RoomMember { /// The display name of the user this object is representing. diff --git a/lib/csapi/search.h b/lib/csapi/search.h index c009ded6..b56d9154 100644 --- a/lib/csapi/search.h +++ b/lib/csapi/search.h @@ -23,15 +23,15 @@ public: /// returned are included in the response. struct IncludeEventContext { /// How many events before the result are - /// returned. By default, this is ``5``. + /// returned. By default, this is `5`. Omittable beforeLimit; /// How many events after the result are - /// returned. By default, this is ``5``. + /// returned. By default, this is `5`. Omittable afterLimit; /// Requests that the server returns the /// historic profile information for the users /// that sent the events that were returned. - /// By default, this is ``false``. + /// By default, this is `false`. Omittable includeProfile; }; @@ -54,10 +54,10 @@ public: QString searchTerm; /// The keys to search. Defaults to all. QStringList keys; - /// This takes a `filter`_. + /// This takes a [filter](/client-server-api/#filtering). RoomEventFilter filter; /// The order in which to search for results. - /// By default, this is ``"rank"``. + /// By default, this is `"rank"`. QString orderBy; /// Configures whether any context for the events /// returned are included in the response. @@ -93,7 +93,7 @@ public: /// The historic profile information of the /// users that sent the events returned. /// - /// The ``string`` key is the user ID for which + /// The `string` key is the user ID for which /// the profile belongs to. QHash profileInfo; /// Events just before the result. @@ -139,15 +139,15 @@ public: std::vector results; /// The current state for every room in the results. /// This is included if the request had the - /// ``include_state`` key set with a value of ``true``. + /// `include_state` key set with a value of `true`. /// - /// The ``string`` key is the room ID for which the ``State - /// Event`` array belongs to. + /// The `string` key is the room ID for which the `State + /// Event` array belongs to. UnorderedMap state; /// Any groups that were requested. /// - /// The outer ``string`` key is the group key requested (eg: ``room_id`` - /// or ``sender``). The inner ``string`` key is the grouped value (eg: + /// The outer `string` key is the group key requested (eg: `room_id` + /// or `sender`). The inner `string` key is the grouped value (eg: /// a room's ID or a user's ID). QHash> groups; /// Token that can be used to get the next batch of @@ -172,7 +172,7 @@ public: * * \param nextBatch * The point to return events from. If given, this should be a - * ``next_batch`` result from a previous call to this endpoint. + * `next_batch` result from a previous call to this endpoint. */ explicit SearchJob(const Categories& searchCategories, const QString& nextBatch = {}); diff --git a/lib/csapi/sso_login_redirect.cpp b/lib/csapi/sso_login_redirect.cpp index 85a18560..e3d39807 100644 --- a/lib/csapi/sso_login_redirect.cpp +++ b/lib/csapi/sso_login_redirect.cpp @@ -28,3 +28,27 @@ RedirectToSSOJob::RedirectToSSOJob(const QString& redirectUrl) QStringLiteral("/_matrix/client/r0") % "/login/sso/redirect", queryToRedirectToSSO(redirectUrl), {}, false) {} + +auto queryToRedirectToIdP(const QString& redirectUrl) +{ + BaseJob::Query _q; + addParam<>(_q, QStringLiteral("redirectUrl"), redirectUrl); + return _q; +} + +QUrl RedirectToIdPJob::makeRequestUrl(QUrl baseUrl, const QString& idpId, + const QString& redirectUrl) +{ + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/login/sso/redirect/" % idpId, + queryToRedirectToIdP(redirectUrl)); +} + +RedirectToIdPJob::RedirectToIdPJob(const QString& idpId, + const QString& redirectUrl) + : BaseJob(HttpVerb::Get, QStringLiteral("RedirectToIdPJob"), + QStringLiteral("/_matrix/client/r0") % "/login/sso/redirect/" + % idpId, + queryToRedirectToIdP(redirectUrl), {}, false) +{} diff --git a/lib/csapi/sso_login_redirect.h b/lib/csapi/sso_login_redirect.h index d6330e38..ade1eb7d 100644 --- a/lib/csapi/sso_login_redirect.h +++ b/lib/csapi/sso_login_redirect.h @@ -13,7 +13,9 @@ namespace Quotient { * A web-based Matrix client should instruct the user's browser to * navigate to this endpoint in order to log in via SSO. * - * The server MUST respond with an HTTP redirect to the SSO interface. + * The server MUST respond with an HTTP redirect to the SSO interface, + * or present a page which lets the user select an IdP to continue + * with in the event multiple are supported by the server. */ class RedirectToSSOJob : public BaseJob { public: @@ -33,4 +35,36 @@ public: static QUrl makeRequestUrl(QUrl baseUrl, const QString& redirectUrl); }; +/*! \brief Redirect the user's browser to the SSO interface for an IdP. + * + * This endpoint is the same as `/login/sso/redirect`, though with an + * IdP ID from the original `identity_providers` array to inform the + * server of which IdP the client/user would like to continue with. + * + * The server MUST respond with an HTTP redirect to the SSO interface + * for that IdP. + */ +class RedirectToIdPJob : public BaseJob { +public: + /*! \brief Redirect the user's browser to the SSO interface for an IdP. + * + * \param idpId + * The `id` of the IdP from the `m.login.sso` `identity_providers` + * array denoting the user's selection. + * + * \param redirectUrl + * URI to which the user will be redirected after the homeserver has + * authenticated the user with SSO. + */ + explicit RedirectToIdPJob(const QString& idpId, const QString& redirectUrl); + + /*! \brief Construct a URL without creating a full-fledged job object + * + * This function can be used when a URL for RedirectToIdPJob + * is necessary but the job itself isn't. + */ + static QUrl makeRequestUrl(QUrl baseUrl, const QString& idpId, + const QString& redirectUrl); +}; + } // namespace Quotient diff --git a/lib/csapi/tags.h b/lib/csapi/tags.h index a815d9b3..a854531a 100644 --- a/lib/csapi/tags.h +++ b/lib/csapi/tags.h @@ -18,7 +18,7 @@ public: /// List the tags set by a user on a room. struct Tag { - /// A number in a range ``[0,1]`` describing a relative + /// A number in a range `[0,1]` describing a relative /// position of the room under the given tag. Omittable order; /// List the tags set by a user on a room. @@ -83,7 +83,7 @@ public: * The tag to add. * * \param order - * A number in a range ``[0,1]`` describing a relative + * A number in a range `[0,1]` describing a relative * position of the room under the given tag. * * \param additionalProperties diff --git a/lib/csapi/third_party_membership.h b/lib/csapi/third_party_membership.h index 55cab370..a424678f 100644 --- a/lib/csapi/third_party_membership.h +++ b/lib/csapi/third_party_membership.h @@ -9,15 +9,14 @@ namespace Quotient { /*! \brief Invite a user to participate in a particular room. - * - * .. _invite-by-third-party-id-endpoint: * * *Note that there are two forms of this API, which are documented separately. * This version of the API does not require that the inviter know the Matrix * identifier of the invitee, and instead relies on third party identifiers. * The homeserver uses an identity server to perform the mapping from * third party identifier to a Matrix identifier. The other is documented in - * the* `joining rooms section`_. + * the* [joining rooms + * section](/client-server-api/#post_matrixclientr0roomsroomidinvite). * * This API invites a user to participate in a particular room. * They do not start participating in the room until they actually join the @@ -27,7 +26,7 @@ namespace Quotient { * join that room. * * If the identity server did know the Matrix user identifier for the - * third party identifier, the homeserver will append a ``m.room.member`` + * third party identifier, the homeserver will append a `m.room.member` * event to the room. * * If the identity server does not know a Matrix user identifier for the @@ -35,7 +34,7 @@ namespace Quotient { * which can be accepted upon providing proof of ownership of the third * party identifier. This is achieved by the identity server generating a * token, which it gives to the inviting homeserver. The homeserver will - * add an ``m.room.third_party_invite`` event into the graph for the room, + * add an `m.room.third_party_invite` event into the graph for the room, * containing that token. * * When the invitee binds the invited third party identifier to a Matrix @@ -51,9 +50,7 @@ namespace Quotient { * - The matrix user ID who invited them to the room * * If a token is requested from the identity server, the homeserver will - * append a ``m.room.third_party_invite`` event to the room. - * - * .. _joining rooms section: `invite-by-user-id-endpoint`_ + * append a `m.room.third_party_invite` event to the room. */ class InviteBy3PIDJob : public BaseJob { public: @@ -73,7 +70,7 @@ public: * * \param medium * The kind of address being passed in the address field, for example - * ``email``. + * `email`. * * \param address * The invitee's third party identifier. diff --git a/lib/csapi/to_device.cpp b/lib/csapi/to_device.cpp index 28c4115a..3775174d 100644 --- a/lib/csapi/to_device.cpp +++ b/lib/csapi/to_device.cpp @@ -16,6 +16,6 @@ SendToDeviceJob::SendToDeviceJob( % eventType % "/" % txnId) { QJsonObject _data; - addParam(_data, QStringLiteral("messages"), messages); + addParam<>(_data, QStringLiteral("messages"), messages); setRequestData(std::move(_data)); } diff --git a/lib/csapi/to_device.h b/lib/csapi/to_device.h index f5d69d65..7a237195 100644 --- a/lib/csapi/to_device.h +++ b/lib/csapi/to_device.h @@ -32,7 +32,7 @@ public: */ explicit SendToDeviceJob( const QString& eventType, const QString& txnId, - const QHash>& messages = {}); + const QHash>& messages); }; } // namespace Quotient diff --git a/lib/csapi/typing.h b/lib/csapi/typing.h index 2c953949..64a310d0 100644 --- a/lib/csapi/typing.h +++ b/lib/csapi/typing.h @@ -11,8 +11,8 @@ namespace Quotient { /*! \brief Informs the server that the user has started or stopped typing. * * This tells the server that the user is typing for the next N - * milliseconds where N is the value specified in the ``timeout`` key. - * Alternatively, if ``typing`` is ``false``, it tells the server that the + * milliseconds where N is the value specified in the `timeout` key. + * Alternatively, if `typing` is `false`, it tells the server that the * user has stopped typing. */ class SetTypingJob : public BaseJob { @@ -26,7 +26,7 @@ public: * The room in which the user is typing. * * \param typing - * Whether the user is typing or not. If ``false``, the ``timeout`` + * Whether the user is typing or not. If `false`, the `timeout` * key can be omitted. * * \param timeout diff --git a/lib/csapi/users.h b/lib/csapi/users.h index 6fc26f57..772a6365 100644 --- a/lib/csapi/users.h +++ b/lib/csapi/users.h @@ -19,7 +19,7 @@ namespace Quotient { * * The search is performed case-insensitively on user IDs and display * names preferably using a collation determined based upon the - * ``Accept-Language`` header provided in the request, if present. + * `Accept-Language` header provided in the request, if present. */ class SearchUserDirectoryJob : public BaseJob { public: @@ -34,7 +34,7 @@ public: /// /// The search is performed case-insensitively on user IDs and display /// names preferably using a collation determined based upon the - /// ``Accept-Language`` header provided in the request, if present. + /// `Accept-Language` header provided in the request, if present. struct User { /// The user's matrix user ID. QString userId; @@ -66,7 +66,10 @@ public: } /// Indicates if the result list has been truncated by the limit. - bool limited() const { return loadFromJson("limited"_ls); } + bool limited() const + { + return loadFromJson("limited"_ls); + } }; template <> diff --git a/lib/csapi/versions.h b/lib/csapi/versions.h index 828a7eb9..896e2ea9 100644 --- a/lib/csapi/versions.h +++ b/lib/csapi/versions.h @@ -12,14 +12,14 @@ namespace Quotient { * * Gets the versions of the specification supported by the server. * - * Values will take the form ``rX.Y.Z``. + * Values will take the form `rX.Y.Z`. * - * Only the latest ``Z`` value will be reported for each supported ``X.Y`` - * value. i.e. if the server implements ``r0.0.0``, ``r0.0.1``, and ``r1.2.0``, - * it will report ``r0.0.1`` and ``r1.2.0``. + * Only the latest `Z` value will be reported for each supported `X.Y` value. + * i.e. if the server implements `r0.0.0`, `r0.0.1`, and `r1.2.0`, it will + * report `r0.0.1` and `r1.2.0`. * * The server may additionally advertise experimental features it supports - * through ``unstable_features``. These features should be namespaced and + * through `unstable_features`. These features should be namespaced and * may optionally include version information within their name if desired. * Features listed here are not for optionally toggling parts of the Matrix * specification and should only be used to advertise support for a feature diff --git a/lib/csapi/voip.h b/lib/csapi/voip.h index 087ebbbd..85ab8b41 100644 --- a/lib/csapi/voip.h +++ b/lib/csapi/voip.h @@ -28,7 +28,10 @@ public: // Result properties /// The TURN server credentials. - QJsonObject data() const { return fromJson(jsonData()); } + QJsonObject data() const + { + return fromJson(jsonData()); + } }; } // namespace Quotient diff --git a/lib/csapi/wellknown.h b/lib/csapi/wellknown.h index b21d9fc7..c707d232 100644 --- a/lib/csapi/wellknown.h +++ b/lib/csapi/wellknown.h @@ -14,7 +14,7 @@ namespace Quotient { * * Gets discovery information about the domain. The file may include * additional keys, which MUST follow the Java package naming convention, - * e.g. ``com.example.myapp.property``. This ensures property names are + * e.g. `com.example.myapp.property`. This ensures property names are * suitably namespaced for each application and reduces the risk of * clashes. * diff --git a/lib/csapi/whoami.h b/lib/csapi/whoami.h index af8f1e8a..203742c9 100644 --- a/lib/csapi/whoami.h +++ b/lib/csapi/whoami.h @@ -14,8 +14,8 @@ namespace Quotient { * * Note that, as with the rest of the Client-Server API, * Application Services may masquerade as users within their - * namespace by giving a ``user_id`` query parameter. In this - * situation, the server should verify that the given ``user_id`` + * namespace by giving a `user_id` query parameter. In this + * situation, the server should verify that the given `user_id` * is registered by the appservice, and return it in the response * body. */ @@ -33,8 +33,20 @@ public: // Result properties - /// The user id that owns the access token. - QString userId() const { return loadFromJson("user_id"_ls); } + /// The user ID that owns the access token. + QString userId() const + { + return loadFromJson("user_id"_ls); + } + + /// Device ID associated with the access token. If no device + /// is associated with the access token (such as in the case + /// of application services) then this field can be omitted. + /// Otherwise this is required. + QString deviceId() const + { + return loadFromJson("device_id"_ls); + } }; } // namespace Quotient diff --git a/lib/identity/definitions/request_email_validation.h b/lib/identity/definitions/request_email_validation.h index 079da953..87549505 100644 --- a/lib/identity/definitions/request_email_validation.h +++ b/lib/identity/definitions/request_email_validation.h @@ -11,16 +11,16 @@ namespace Quotient { struct RequestEmailValidation { /// A unique string generated by the client, and used to identify the /// validation attempt. It must be a string consisting of the characters - /// ``[0-9a-zA-Z.=_-]``. Its length must not exceed 255 characters and it + /// `[0-9a-zA-Z.=_-]`. Its length must not exceed 255 characters and it /// must not be empty. QString clientSecret; /// The email address to validate. QString email; - /// The server will only send an email if the ``send_attempt`` + /// The server will only send an email if the `send_attempt` /// is a number greater than the most recent one which it has seen, - /// scoped to that ``email`` + ``client_secret`` pair. This is to + /// scoped to that `email` + `client_secret` pair. This is to /// avoid repeatedly sending the same email in the case of request /// retries between the POSTing user and the identity server. /// The client should increment this value if they desire a new diff --git a/lib/identity/definitions/request_msisdn_validation.h b/lib/identity/definitions/request_msisdn_validation.h index a29fd0de..d2ea463f 100644 --- a/lib/identity/definitions/request_msisdn_validation.h +++ b/lib/identity/definitions/request_msisdn_validation.h @@ -11,20 +11,20 @@ namespace Quotient { struct RequestMsisdnValidation { /// A unique string generated by the client, and used to identify the /// validation attempt. It must be a string consisting of the characters - /// ``[0-9a-zA-Z.=_-]``. Its length must not exceed 255 characters and it + /// `[0-9a-zA-Z.=_-]`. Its length must not exceed 255 characters and it /// must not be empty. QString clientSecret; /// The two-letter uppercase ISO-3166-1 alpha-2 country code that the - /// number in ``phone_number`` should be parsed as if it were dialled from. + /// number in `phone_number` should be parsed as if it were dialled from. QString country; /// The phone number to validate. QString phoneNumber; - /// The server will only send an SMS if the ``send_attempt`` is a + /// The server will only send an SMS if the `send_attempt` is a /// number greater than the most recent one which it has seen, - /// scoped to that ``country`` + ``phone_number`` + ``client_secret`` + /// scoped to that `country` + `phone_number` + `client_secret` /// triple. This is to avoid repeatedly sending the same SMS in /// the case of request retries between the POSTing user and the /// identity server. The client should increment this value if -- cgit v1.2.3 From 7aa6e7c300779f652558397bcb7bb3b726d30cb9 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Fri, 2 Jul 2021 10:34:16 +0200 Subject: Abandon BaseJob::Query - generated API files --- lib/csapi/content-repo.cpp | 10 +++++----- lib/csapi/event_context.cpp | 2 +- lib/csapi/joining.cpp | 2 +- lib/csapi/keys.cpp | 2 +- lib/csapi/knocking.cpp | 2 +- lib/csapi/list_public_rooms.cpp | 4 ++-- lib/csapi/message_pagination.cpp | 2 +- lib/csapi/notifications.cpp | 2 +- lib/csapi/peeking_events.cpp | 2 +- lib/csapi/pushrules.cpp | 2 +- lib/csapi/registration.cpp | 4 ++-- lib/csapi/rooms.cpp | 2 +- lib/csapi/search.cpp | 2 +- lib/csapi/sso_login_redirect.cpp | 4 ++-- lib/csapi/third_party_lookup.cpp | 8 ++++---- 15 files changed, 25 insertions(+), 25 deletions(-) (limited to 'lib/csapi') diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index 7ae89739..e913bfd1 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -10,7 +10,7 @@ using namespace Quotient; auto queryToUploadContent(const QString& filename) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("filename"), filename); return _q; } @@ -28,7 +28,7 @@ UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, auto queryToGetContent(bool allowRemote) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("allow_remote"), allowRemote); return _q; } @@ -55,7 +55,7 @@ GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId, auto queryToGetContentOverrideName(bool allowRemote) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("allow_remote"), allowRemote); return _q; } @@ -88,7 +88,7 @@ GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, auto queryToGetContentThumbnail(int width, int height, const QString& method, bool allowRemote) { - BaseJob::Query _q; + QUrlQuery _q; addParam<>(_q, QStringLiteral("width"), width); addParam<>(_q, QStringLiteral("height"), height); addParam(_q, QStringLiteral("method"), method); @@ -124,7 +124,7 @@ GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, auto queryToGetUrlPreview(const QString& url, Omittable ts) { - BaseJob::Query _q; + QUrlQuery _q; addParam<>(_q, QStringLiteral("url"), url); addParam(_q, QStringLiteral("ts"), ts); return _q; diff --git a/lib/csapi/event_context.cpp b/lib/csapi/event_context.cpp index d2a5f522..3f4cd61e 100644 --- a/lib/csapi/event_context.cpp +++ b/lib/csapi/event_context.cpp @@ -10,7 +10,7 @@ using namespace Quotient; auto queryToGetEventContext(Omittable limit, const QString& filter) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("limit"), limit); addParam(_q, QStringLiteral("filter"), filter); return _q; diff --git a/lib/csapi/joining.cpp b/lib/csapi/joining.cpp index 998d0b42..f5266f0b 100644 --- a/lib/csapi/joining.cpp +++ b/lib/csapi/joining.cpp @@ -24,7 +24,7 @@ JoinRoomByIdJob::JoinRoomByIdJob( auto queryToJoinRoom(const QStringList& serverName) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("server_name"), serverName); return _q; } diff --git a/lib/csapi/keys.cpp b/lib/csapi/keys.cpp index 34ab47c9..ba5d8e12 100644 --- a/lib/csapi/keys.cpp +++ b/lib/csapi/keys.cpp @@ -47,7 +47,7 @@ ClaimKeysJob::ClaimKeysJob( auto queryToGetKeysChanges(const QString& from, const QString& to) { - BaseJob::Query _q; + QUrlQuery _q; addParam<>(_q, QStringLiteral("from"), from); addParam<>(_q, QStringLiteral("to"), to); return _q; diff --git a/lib/csapi/knocking.cpp b/lib/csapi/knocking.cpp index 4b561300..788bb378 100644 --- a/lib/csapi/knocking.cpp +++ b/lib/csapi/knocking.cpp @@ -10,7 +10,7 @@ using namespace Quotient; auto queryToKnockRoom(const QStringList& serverName) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("server_name"), serverName); return _q; } diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp index 415d816c..a4bcb934 100644 --- a/lib/csapi/list_public_rooms.cpp +++ b/lib/csapi/list_public_rooms.cpp @@ -38,7 +38,7 @@ SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob( auto queryToGetPublicRooms(Omittable limit, const QString& since, const QString& server) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("limit"), limit); addParam(_q, QStringLiteral("since"), since); addParam(_q, QStringLiteral("server"), server); @@ -66,7 +66,7 @@ GetPublicRoomsJob::GetPublicRoomsJob(Omittable limit, const QString& since, auto queryToQueryPublicRooms(const QString& server) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("server"), server); return _q; } diff --git a/lib/csapi/message_pagination.cpp b/lib/csapi/message_pagination.cpp index 855c051f..441e4dea 100644 --- a/lib/csapi/message_pagination.cpp +++ b/lib/csapi/message_pagination.cpp @@ -12,7 +12,7 @@ auto queryToGetRoomEvents(const QString& from, const QString& to, const QString& dir, Omittable limit, const QString& filter) { - BaseJob::Query _q; + QUrlQuery _q; addParam<>(_q, QStringLiteral("from"), from); addParam(_q, QStringLiteral("to"), to); addParam<>(_q, QStringLiteral("dir"), dir); diff --git a/lib/csapi/notifications.cpp b/lib/csapi/notifications.cpp index a479d500..a38e46f5 100644 --- a/lib/csapi/notifications.cpp +++ b/lib/csapi/notifications.cpp @@ -11,7 +11,7 @@ using namespace Quotient; auto queryToGetNotifications(const QString& from, Omittable limit, const QString& only) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("from"), from); addParam(_q, QStringLiteral("limit"), limit); addParam(_q, QStringLiteral("only"), only); diff --git a/lib/csapi/peeking_events.cpp b/lib/csapi/peeking_events.cpp index 70a5b6f3..ad2f9afe 100644 --- a/lib/csapi/peeking_events.cpp +++ b/lib/csapi/peeking_events.cpp @@ -11,7 +11,7 @@ using namespace Quotient; auto queryToPeekEvents(const QString& from, Omittable timeout, const QString& roomId) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("from"), from); addParam(_q, QStringLiteral("timeout"), timeout); addParam(_q, QStringLiteral("room_id"), roomId); diff --git a/lib/csapi/pushrules.cpp b/lib/csapi/pushrules.cpp index 86165744..ab7d0038 100644 --- a/lib/csapi/pushrules.cpp +++ b/lib/csapi/pushrules.cpp @@ -57,7 +57,7 @@ DeletePushRuleJob::DeletePushRuleJob(const QString& scope, const QString& kind, auto queryToSetPushRule(const QString& before, const QString& after) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("before"), before); addParam(_q, QStringLiteral("after"), after); return _q; diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 33f61265..38649e63 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -10,7 +10,7 @@ using namespace Quotient; auto queryToRegister(const QString& kind) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("kind"), kind); return _q; } @@ -106,7 +106,7 @@ DeactivateAccountJob::DeactivateAccountJob( auto queryToCheckUsernameAvailability(const QString& username) { - BaseJob::Query _q; + QUrlQuery _q; addParam<>(_q, QStringLiteral("username"), username); return _q; } diff --git a/lib/csapi/rooms.cpp b/lib/csapi/rooms.cpp index 724d941f..3dd87021 100644 --- a/lib/csapi/rooms.cpp +++ b/lib/csapi/rooms.cpp @@ -58,7 +58,7 @@ GetRoomStateJob::GetRoomStateJob(const QString& roomId) auto queryToGetMembersByRoom(const QString& at, const QString& membership, const QString& notMembership) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("at"), at); addParam(_q, QStringLiteral("membership"), membership); addParam(_q, QStringLiteral("not_membership"), notMembership); diff --git a/lib/csapi/search.cpp b/lib/csapi/search.cpp index 5649d52a..05ad871e 100644 --- a/lib/csapi/search.cpp +++ b/lib/csapi/search.cpp @@ -10,7 +10,7 @@ using namespace Quotient; auto queryToSearch(const QString& nextBatch) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("next_batch"), nextBatch); return _q; } diff --git a/lib/csapi/sso_login_redirect.cpp b/lib/csapi/sso_login_redirect.cpp index e3d39807..92601b4d 100644 --- a/lib/csapi/sso_login_redirect.cpp +++ b/lib/csapi/sso_login_redirect.cpp @@ -10,7 +10,7 @@ using namespace Quotient; auto queryToRedirectToSSO(const QString& redirectUrl) { - BaseJob::Query _q; + QUrlQuery _q; addParam<>(_q, QStringLiteral("redirectUrl"), redirectUrl); return _q; } @@ -31,7 +31,7 @@ RedirectToSSOJob::RedirectToSSOJob(const QString& redirectUrl) auto queryToRedirectToIdP(const QString& redirectUrl) { - BaseJob::Query _q; + QUrlQuery _q; addParam<>(_q, QStringLiteral("redirectUrl"), redirectUrl); return _q; } diff --git a/lib/csapi/third_party_lookup.cpp b/lib/csapi/third_party_lookup.cpp index baf1fab5..93687a76 100644 --- a/lib/csapi/third_party_lookup.cpp +++ b/lib/csapi/third_party_lookup.cpp @@ -36,7 +36,7 @@ GetProtocolMetadataJob::GetProtocolMetadataJob(const QString& protocol) auto queryToQueryLocationByProtocol(const QString& searchFields) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("searchFields"), searchFields); return _q; } @@ -61,7 +61,7 @@ QueryLocationByProtocolJob::QueryLocationByProtocolJob( auto queryToQueryUserByProtocol(const QString& fields) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("fields..."), fields); return _q; } @@ -86,7 +86,7 @@ QueryUserByProtocolJob::QueryUserByProtocolJob(const QString& protocol, auto queryToQueryLocationByAlias(const QString& alias) { - BaseJob::Query _q; + QUrlQuery _q; addParam<>(_q, QStringLiteral("alias"), alias); return _q; } @@ -107,7 +107,7 @@ QueryLocationByAliasJob::QueryLocationByAliasJob(const QString& alias) auto queryToQueryUserByID(const QString& userid) { - BaseJob::Query _q; + QUrlQuery _q; addParam<>(_q, QStringLiteral("userid"), userid); return _q; } -- cgit v1.2.3 From f7cbefe5ad626ae1798a5d7bb7546e89ad336acd Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Sat, 7 Aug 2021 16:55:06 +0200 Subject: API files: reformat after .clang-format change See 000b5730. --- lib/csapi/admin.h | 5 +---- lib/csapi/content-repo.h | 35 +++++++---------------------------- lib/csapi/create_room.h | 5 +---- lib/csapi/device_management.h | 5 +---- lib/csapi/directory.h | 5 +---- lib/csapi/event_context.h | 20 ++++---------------- lib/csapi/filter.h | 10 ++-------- lib/csapi/joining.h | 10 ++-------- lib/csapi/keys.h | 5 +---- lib/csapi/knocking.h | 5 +---- lib/csapi/list_public_rooms.h | 20 ++++---------------- lib/csapi/login.h | 10 ++-------- lib/csapi/message_pagination.h | 20 ++++---------------- lib/csapi/notifications.h | 5 +---- lib/csapi/openid.h | 5 +---- lib/csapi/peeking_events.h | 15 +++------------ lib/csapi/presence.h | 10 ++-------- lib/csapi/profile.h | 10 ++-------- lib/csapi/pushrules.h | 10 ++-------- lib/csapi/redaction.h | 5 +---- lib/csapi/registration.h | 10 ++-------- lib/csapi/room_send.h | 5 +---- lib/csapi/room_state.h | 5 +---- lib/csapi/rooms.h | 12 ++---------- lib/csapi/users.h | 5 +---- lib/csapi/voip.h | 5 +---- lib/csapi/whoami.h | 10 ++-------- 27 files changed, 53 insertions(+), 214 deletions(-) (limited to 'lib/csapi') diff --git a/lib/csapi/admin.h b/lib/csapi/admin.h index d4fe639b..570bf24a 100644 --- a/lib/csapi/admin.h +++ b/lib/csapi/admin.h @@ -74,10 +74,7 @@ public: // Result properties /// The Matrix user ID of the user. - QString userId() const - { - return loadFromJson("user_id"_ls); - } + QString userId() const { return loadFromJson("user_id"_ls); } /// Each key is an identifier for one of the user's devices. QHash devices() const diff --git a/lib/csapi/content-repo.h b/lib/csapi/content-repo.h index a41453b2..f3d7309a 100644 --- a/lib/csapi/content-repo.h +++ b/lib/csapi/content-repo.h @@ -72,10 +72,7 @@ public: // Result properties /// The content type of the file that was previously uploaded. - QString contentType() const - { - return reply()->rawHeader("Content-Type"); - } + QString contentType() const { return reply()->rawHeader("Content-Type"); } /// The name of the file that was previously uploaded, if set. QString contentDisposition() const @@ -84,10 +81,7 @@ public: } /// The content that was previously uploaded. - QIODevice* data() - { - return reply(); - } + QIODevice* data() { return reply(); } }; /*! \brief Download content from the content repository overriding the file name @@ -132,10 +126,7 @@ public: // Result properties /// The content type of the file that was previously uploaded. - QString contentType() const - { - return reply()->rawHeader("Content-Type"); - } + QString contentType() const { return reply()->rawHeader("Content-Type"); } /// The `fileName` requested or the name of the file that was previously /// uploaded, if set. @@ -145,10 +136,7 @@ public: } /// The content that was previously uploaded. - QIODevice* data() - { - return reply(); - } + QIODevice* data() { return reply(); } }; /*! \brief Download a thumbnail of content from the content repository @@ -202,16 +190,10 @@ public: // Result properties /// The content type of the thumbnail. - QString contentType() const - { - return reply()->rawHeader("Content-Type"); - } + QString contentType() const { return reply()->rawHeader("Content-Type"); } /// A thumbnail of the requested content. - QIODevice* data() - { - return reply(); - } + QIODevice* data() { return reply(); } }; /*! \brief Get information about a URL for a client @@ -257,10 +239,7 @@ public: /// An [MXC URI](/client-server-api/#matrix-content-mxc-uris) to the image. /// Omitted if there is no image. - QString ogImage() const - { - return loadFromJson("og:image"_ls); - } + QString ogImage() const { return loadFromJson("og:image"_ls); } }; /*! \brief Get the configuration for the content repository. diff --git a/lib/csapi/create_room.h b/lib/csapi/create_room.h index 8c6af7d4..81dfbffc 100644 --- a/lib/csapi/create_room.h +++ b/lib/csapi/create_room.h @@ -268,10 +268,7 @@ public: // Result properties /// The created room's ID. - QString roomId() const - { - return loadFromJson("room_id"_ls); - } + QString roomId() const { return loadFromJson("room_id"_ls); } }; template <> diff --git a/lib/csapi/device_management.h b/lib/csapi/device_management.h index e2acea18..7fb69873 100644 --- a/lib/csapi/device_management.h +++ b/lib/csapi/device_management.h @@ -59,10 +59,7 @@ public: // Result properties /// Device information - Device device() const - { - return fromJson(jsonData()); - } + Device device() const { return fromJson(jsonData()); } }; /*! \brief Update a device diff --git a/lib/csapi/directory.h b/lib/csapi/directory.h index 00215cae..93a31595 100644 --- a/lib/csapi/directory.h +++ b/lib/csapi/directory.h @@ -51,10 +51,7 @@ public: // Result properties /// The room ID for this room alias. - QString roomId() const - { - return loadFromJson("room_id"_ls); - } + QString roomId() const { return loadFromJson("room_id"_ls); } /// A list of servers that are aware of this room alias. QStringList servers() const diff --git a/lib/csapi/event_context.h b/lib/csapi/event_context.h index 6a49769f..4e50edf3 100644 --- a/lib/csapi/event_context.h +++ b/lib/csapi/event_context.h @@ -58,16 +58,10 @@ public: // Result properties /// A token that can be used to paginate backwards with. - QString begin() const - { - return loadFromJson("start"_ls); - } + QString begin() const { return loadFromJson("start"_ls); } /// A token that can be used to paginate forwards with. - QString end() const - { - return loadFromJson("end"_ls); - } + QString end() const { return loadFromJson("end"_ls); } /// A list of room events that happened just before the /// requested event, in reverse-chronological order. @@ -77,10 +71,7 @@ public: } /// Details of the requested event. - RoomEventPtr event() - { - return takeFromJson("event"_ls); - } + RoomEventPtr event() { return takeFromJson("event"_ls); } /// A list of room events that happened just after the /// requested event, in chronological order. @@ -90,10 +81,7 @@ public: } /// The state of the room at the last event returned. - StateEvents state() - { - return takeFromJson("state"_ls); - } + StateEvents state() { return takeFromJson("state"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/filter.h b/lib/csapi/filter.h index 7e9e14ee..01bec36b 100644 --- a/lib/csapi/filter.h +++ b/lib/csapi/filter.h @@ -35,10 +35,7 @@ public: /// with a `{` as this character is used to determine /// if the filter provided is inline JSON or a previously /// declared filter by homeservers on some APIs. - QString filterId() const - { - return loadFromJson("filter_id"_ls); - } + QString filterId() const { return loadFromJson("filter_id"_ls); } }; /*! \brief Download a filter @@ -67,10 +64,7 @@ public: // Result properties /// The filter definition. - Filter filter() const - { - return fromJson(jsonData()); - } + Filter filter() const { return fromJson(jsonData()); } }; } // namespace Quotient diff --git a/lib/csapi/joining.h b/lib/csapi/joining.h index 6dcd1351..d0199b11 100644 --- a/lib/csapi/joining.h +++ b/lib/csapi/joining.h @@ -49,10 +49,7 @@ public: // Result properties /// The joined room ID. - QString roomId() const - { - return loadFromJson("room_id"_ls); - } + QString roomId() const { return loadFromJson("room_id"_ls); } }; /*! \brief Start the requesting user participating in a particular room. @@ -98,10 +95,7 @@ public: // Result properties /// The joined room ID. - QString roomId() const - { - return loadFromJson("room_id"_ls); - } + QString roomId() const { return loadFromJson("room_id"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/keys.h b/lib/csapi/keys.h index 53ba6495..7db09e8d 100644 --- a/lib/csapi/keys.h +++ b/lib/csapi/keys.h @@ -267,10 +267,7 @@ public: /// The Matrix User IDs of all users who may have left all /// the end-to-end encrypted rooms they previously shared /// with the user. - QStringList left() const - { - return loadFromJson("left"_ls); - } + QStringList left() const { return loadFromJson("left"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/knocking.h b/lib/csapi/knocking.h index 607b55a9..1108cb64 100644 --- a/lib/csapi/knocking.h +++ b/lib/csapi/knocking.h @@ -49,10 +49,7 @@ public: // Result properties /// The knocked room ID. - QString roomId() const - { - return loadFromJson("room_id"_ls); - } + QString roomId() const { return loadFromJson("room_id"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/list_public_rooms.h b/lib/csapi/list_public_rooms.h index 1c73c0af..963c8b56 100644 --- a/lib/csapi/list_public_rooms.h +++ b/lib/csapi/list_public_rooms.h @@ -111,18 +111,12 @@ public: /// A pagination token for the response. The absence of this token /// means there are no more results to fetch and the client should /// stop paginating. - QString nextBatch() const - { - return loadFromJson("next_batch"_ls); - } + QString nextBatch() const { return loadFromJson("next_batch"_ls); } /// A pagination token that allows fetching previous results. The /// absence of this token means there are no results before this /// batch, i.e. this is the first batch. - QString prevBatch() const - { - return loadFromJson("prev_batch"_ls); - } + QString prevBatch() const { return loadFromJson("prev_batch"_ls); } /// An estimate on the total number of public rooms, if the /// server has an estimate. @@ -196,18 +190,12 @@ public: /// A pagination token for the response. The absence of this token /// means there are no more results to fetch and the client should /// stop paginating. - QString nextBatch() const - { - return loadFromJson("next_batch"_ls); - } + QString nextBatch() const { return loadFromJson("next_batch"_ls); } /// A pagination token that allows fetching previous results. The /// absence of this token means there are no results before this /// batch, i.e. this is the first batch. - QString prevBatch() const - { - return loadFromJson("prev_batch"_ls); - } + QString prevBatch() const { return loadFromJson("prev_batch"_ls); } /// An estimate on the total number of public rooms, if the /// server has an estimate. diff --git a/lib/csapi/login.h b/lib/csapi/login.h index ce783af2..b35db1eb 100644 --- a/lib/csapi/login.h +++ b/lib/csapi/login.h @@ -121,10 +121,7 @@ public: // Result properties /// The fully-qualified Matrix ID for the account. - QString userId() const - { - return loadFromJson("user_id"_ls); - } + QString userId() const { return loadFromJson("user_id"_ls); } /// An access token for the account. /// This access token can then be used to authorize other requests. @@ -146,10 +143,7 @@ public: /// ID of the logged-in device. Will be the same as the /// corresponding parameter in the request, if one was specified. - QString deviceId() const - { - return loadFromJson("device_id"_ls); - } + QString deviceId() const { return loadFromJson("device_id"_ls); } /// Optional client configuration provided by the server. If present, /// clients SHOULD use the provided object to reconfigure themselves, diff --git a/lib/csapi/message_pagination.h b/lib/csapi/message_pagination.h index 020ef543..363e4d99 100644 --- a/lib/csapi/message_pagination.h +++ b/lib/csapi/message_pagination.h @@ -66,26 +66,17 @@ public: /// The token the pagination starts from. If `dir=b` this will be /// the token supplied in `from`. - QString begin() const - { - return loadFromJson("start"_ls); - } + QString begin() const { return loadFromJson("start"_ls); } /// The token the pagination ends at. If `dir=b` this token should /// be used again to request even earlier events. - QString end() const - { - return loadFromJson("end"_ls); - } + QString end() const { return loadFromJson("end"_ls); } /// A list of room events. The order depends on the `dir` parameter. /// For `dir=b` events will be in reverse-chronological order, /// for `dir=f` in chronological order, so that events start /// at the `from` point. - RoomEvents chunk() - { - return takeFromJson("chunk"_ls); - } + RoomEvents chunk() { return takeFromJson("chunk"_ls); } /// A list of state events relevant to showing the `chunk`. For example, if /// `lazy_load_members` is enabled in the filter then this may contain @@ -95,10 +86,7 @@ public: /// may remove membership events which would have already been /// sent to the client in prior calls to this endpoint, assuming /// the membership of those members has not changed. - StateEvents state() - { - return takeFromJson("state"_ls); - } + StateEvents state() { return takeFromJson("state"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/notifications.h b/lib/csapi/notifications.h index 0cc165ce..0c38fe6b 100644 --- a/lib/csapi/notifications.h +++ b/lib/csapi/notifications.h @@ -71,10 +71,7 @@ public: /// The token to supply in the `from` param of the next /// `/notifications` request in order to request more /// events. If this is absent, there are no more results. - QString nextToken() const - { - return loadFromJson("next_token"_ls); - } + QString nextToken() const { return loadFromJson("next_token"_ls); } /// The list of events that triggered notifications. std::vector notifications() diff --git a/lib/csapi/openid.h b/lib/csapi/openid.h index 88218c20..0be39c8c 100644 --- a/lib/csapi/openid.h +++ b/lib/csapi/openid.h @@ -43,10 +43,7 @@ public: /// Specification](http://openid.net/specs/openid-connect-core-1_0.html#TokenResponse) /// with the only difference being the lack of an `id_token`. Instead, /// the Matrix homeserver's name is provided. - OpenidToken tokenData() const - { - return fromJson(jsonData()); - } + OpenidToken tokenData() const { return fromJson(jsonData()); } }; } // namespace Quotient diff --git a/lib/csapi/peeking_events.h b/lib/csapi/peeking_events.h index 1eee880f..885ff340 100644 --- a/lib/csapi/peeking_events.h +++ b/lib/csapi/peeking_events.h @@ -53,23 +53,14 @@ public: /// A token which correlates to the first value in `chunk`. This /// is usually the same token supplied to `from=`. - QString begin() const - { - return loadFromJson("start"_ls); - } + QString begin() const { return loadFromJson("start"_ls); } /// A token which correlates to the last value in `chunk`. This /// token should be used in the next request to `/events`. - QString end() const - { - return loadFromJson("end"_ls); - } + QString end() const { return loadFromJson("end"_ls); } /// An array of events. - RoomEvents chunk() - { - return takeFromJson("chunk"_ls); - } + RoomEvents chunk() { return takeFromJson("chunk"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/presence.h b/lib/csapi/presence.h index c817ad9f..4ab50e25 100644 --- a/lib/csapi/presence.h +++ b/lib/csapi/presence.h @@ -55,10 +55,7 @@ public: // Result properties /// This user's presence. - QString presence() const - { - return loadFromJson("presence"_ls); - } + QString presence() const { return loadFromJson("presence"_ls); } /// The length of time in milliseconds since an action was performed /// by this user. @@ -68,10 +65,7 @@ public: } /// The state message for this user if one was set. - QString statusMsg() const - { - return loadFromJson("status_msg"_ls); - } + QString statusMsg() const { return loadFromJson("status_msg"_ls); } /// Whether the user is currently active Omittable currentlyActive() const diff --git a/lib/csapi/profile.h b/lib/csapi/profile.h index 3cda34f8..8bbe4f8c 100644 --- a/lib/csapi/profile.h +++ b/lib/csapi/profile.h @@ -101,10 +101,7 @@ public: // Result properties /// The user's avatar URL if they have set one, otherwise not present. - QString avatarUrl() const - { - return loadFromJson("avatar_url"_ls); - } + QString avatarUrl() const { return loadFromJson("avatar_url"_ls); } }; /*! \brief Get this user's profile information. @@ -133,10 +130,7 @@ public: // Result properties /// The user's avatar URL if they have set one, otherwise not present. - QString avatarUrl() const - { - return loadFromJson("avatar_url"_ls); - } + QString avatarUrl() const { return loadFromJson("avatar_url"_ls); } /// The user's display name if they have set one, otherwise not present. QString displayname() const diff --git a/lib/csapi/pushrules.h b/lib/csapi/pushrules.h index 90d2ce79..a5eb48f0 100644 --- a/lib/csapi/pushrules.h +++ b/lib/csapi/pushrules.h @@ -72,10 +72,7 @@ public: /// The specific push rule. This will also include keys specific to the /// rule itself such as the rule's `actions` and `conditions` if set. - PushRule pushRule() const - { - return fromJson(jsonData()); - } + PushRule pushRule() const { return fromJson(jsonData()); } }; /*! \brief Delete a push rule. @@ -191,10 +188,7 @@ public: // Result properties /// Whether the push rule is enabled or not. - bool enabled() const - { - return loadFromJson("enabled"_ls); - } + bool enabled() const { return loadFromJson("enabled"_ls); } }; /*! \brief Enable or disable a push rule. diff --git a/lib/csapi/redaction.h b/lib/csapi/redaction.h index f12e6b71..f0db9f9f 100644 --- a/lib/csapi/redaction.h +++ b/lib/csapi/redaction.h @@ -46,10 +46,7 @@ public: // Result properties /// A unique identifier for the event. - QString eventId() const - { - return loadFromJson("event_id"_ls); - } + QString eventId() const { return loadFromJson("event_id"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/registration.h b/lib/csapi/registration.h index 0ad8b101..c1614f20 100644 --- a/lib/csapi/registration.h +++ b/lib/csapi/registration.h @@ -108,10 +108,7 @@ public: /// /// Any user ID returned by this API must conform to the grammar given in /// the [Matrix specification](/appendices/#user-identifiers). - QString userId() const - { - return loadFromJson("user_id"_ls); - } + QString userId() const { return loadFromJson("user_id"_ls); } /// An access token for the account. /// This access token can then be used to authorize other requests. @@ -135,10 +132,7 @@ public: /// ID of the registered device. Will be the same as the /// corresponding parameter in the request, if one was specified. /// Required if the `inhibit_login` option is false. - QString deviceId() const - { - return loadFromJson("device_id"_ls); - } + QString deviceId() const { return loadFromJson("device_id"_ls); } }; /*! \brief Begins the validation process for an email to be used during diff --git a/lib/csapi/room_send.h b/lib/csapi/room_send.h index a9e7ca13..96f5beca 100644 --- a/lib/csapi/room_send.h +++ b/lib/csapi/room_send.h @@ -49,10 +49,7 @@ public: // Result properties /// A unique identifier for the event. - QString eventId() const - { - return loadFromJson("event_id"_ls); - } + QString eventId() const { return loadFromJson("event_id"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/room_state.h b/lib/csapi/room_state.h index 99eb4fc9..f95af223 100644 --- a/lib/csapi/room_state.h +++ b/lib/csapi/room_state.h @@ -71,10 +71,7 @@ public: // Result properties /// A unique identifier for the event. - QString eventId() const - { - return loadFromJson("event_id"_ls); - } + QString eventId() const { return loadFromJson("event_id"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/rooms.h b/lib/csapi/rooms.h index 179d7a27..51af2c65 100644 --- a/lib/csapi/rooms.h +++ b/lib/csapi/rooms.h @@ -38,11 +38,7 @@ public: // Result properties /// The full event. - EventPtr event() - - { - return fromJson(jsonData()); - } + EventPtr event() { return fromJson(jsonData()); } }; /*! \brief Get the state identified by the type and key. @@ -103,11 +99,7 @@ public: // Result properties /// The current state of the room - StateEvents events() - - { - return fromJson(jsonData()); - } + StateEvents events() { return fromJson(jsonData()); } }; /*! \brief Get the m.room.member events for the room. diff --git a/lib/csapi/users.h b/lib/csapi/users.h index 772a6365..eab18f6c 100644 --- a/lib/csapi/users.h +++ b/lib/csapi/users.h @@ -66,10 +66,7 @@ public: } /// Indicates if the result list has been truncated by the limit. - bool limited() const - { - return loadFromJson("limited"_ls); - } + bool limited() const { return loadFromJson("limited"_ls); } }; template <> diff --git a/lib/csapi/voip.h b/lib/csapi/voip.h index 85ab8b41..087ebbbd 100644 --- a/lib/csapi/voip.h +++ b/lib/csapi/voip.h @@ -28,10 +28,7 @@ public: // Result properties /// The TURN server credentials. - QJsonObject data() const - { - return fromJson(jsonData()); - } + QJsonObject data() const { return fromJson(jsonData()); } }; } // namespace Quotient diff --git a/lib/csapi/whoami.h b/lib/csapi/whoami.h index 203742c9..319f82c5 100644 --- a/lib/csapi/whoami.h +++ b/lib/csapi/whoami.h @@ -34,19 +34,13 @@ public: // Result properties /// The user ID that owns the access token. - QString userId() const - { - return loadFromJson("user_id"_ls); - } + QString userId() const { return loadFromJson("user_id"_ls); } /// Device ID associated with the access token. If no device /// is associated with the access token (such as in the case /// of application services) then this field can be omitted. /// Otherwise this is required. - QString deviceId() const - { - return loadFromJson("device_id"_ls); - } + QString deviceId() const { return loadFromJson("device_id"_ls); } }; } // namespace Quotient -- cgit v1.2.3 From bd649c591fa020fde0bd56a63c13025097b831ae Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Sat, 7 Aug 2021 22:12:46 +0200 Subject: Update generated files This uses API definition files from https://github.com/matrix-org/matrix-doc/pull/3236, and additionally makes uploadFile>content_uri to have 'format: uri' (as suggested in the PR review). Only use this commit with the next one; alone it breaks the build. --- lib/csapi/content-repo.cpp | 6 +++--- lib/csapi/content-repo.h | 11 ++++------- lib/csapi/definitions/public_rooms_response.h | 2 +- lib/csapi/definitions/request_token_response.h | 2 +- lib/csapi/definitions/wellknown/homeserver.h | 2 +- lib/csapi/definitions/wellknown/identity_server.h | 2 +- lib/csapi/profile.cpp | 2 +- lib/csapi/profile.h | 6 +++--- lib/csapi/pusher.h | 4 ++-- lib/csapi/rooms.h | 2 +- lib/csapi/search.h | 2 +- lib/csapi/users.h | 2 +- 12 files changed, 20 insertions(+), 23 deletions(-) (limited to 'lib/csapi') diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index e913bfd1..00bc9706 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -122,7 +122,7 @@ GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, setExpectedContentTypes({ "image/jpeg", "image/png" }); } -auto queryToGetUrlPreview(const QString& url, Omittable ts) +auto queryToGetUrlPreview(const QUrl& url, Omittable ts) { QUrlQuery _q; addParam<>(_q, QStringLiteral("url"), url); @@ -130,7 +130,7 @@ auto queryToGetUrlPreview(const QString& url, Omittable ts) return _q; } -QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, +QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QUrl& url, Omittable ts) { return BaseJob::makeRequestUrl(std::move(baseUrl), @@ -139,7 +139,7 @@ QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, queryToGetUrlPreview(url, ts)); } -GetUrlPreviewJob::GetUrlPreviewJob(const QString& url, Omittable ts) +GetUrlPreviewJob::GetUrlPreviewJob(const QUrl& url, Omittable ts) : BaseJob(HttpVerb::Get, QStringLiteral("GetUrlPreviewJob"), QStringLiteral("/_matrix/media/r0") % "/preview_url", queryToGetUrlPreview(url, ts)) diff --git a/lib/csapi/content-repo.h b/lib/csapi/content-repo.h index f3d7309a..28409f5c 100644 --- a/lib/csapi/content-repo.h +++ b/lib/csapi/content-repo.h @@ -34,10 +34,7 @@ public: /// The [MXC URI](/client-server-api/#matrix-content-mxc-uris) to the /// uploaded content. - QString contentUri() const - { - return loadFromJson("content_uri"_ls); - } + QUrl contentUri() const { return loadFromJson("content_uri"_ls); } }; /*! \brief Download content from the content repository. @@ -219,14 +216,14 @@ public: * return a newer version if it does not have the requested version * available. */ - explicit GetUrlPreviewJob(const QString& url, Omittable ts = none); + explicit GetUrlPreviewJob(const QUrl& url, Omittable ts = none); /*! \brief Construct a URL without creating a full-fledged job object * * This function can be used when a URL for GetUrlPreviewJob * is necessary but the job itself isn't. */ - static QUrl makeRequestUrl(QUrl baseUrl, const QString& url, + static QUrl makeRequestUrl(QUrl baseUrl, const QUrl& url, Omittable ts = none); // Result properties @@ -239,7 +236,7 @@ public: /// An [MXC URI](/client-server-api/#matrix-content-mxc-uris) to the image. /// Omitted if there is no image. - QString ogImage() const { return loadFromJson("og:image"_ls); } + QUrl ogImage() const { return loadFromJson("og:image"_ls); } }; /*! \brief Get the configuration for the content repository. diff --git a/lib/csapi/definitions/public_rooms_response.h b/lib/csapi/definitions/public_rooms_response.h index 34b447d2..2938b4ec 100644 --- a/lib/csapi/definitions/public_rooms_response.h +++ b/lib/csapi/definitions/public_rooms_response.h @@ -36,7 +36,7 @@ struct PublicRoomsChunk { bool guestCanJoin; /// The URL for the room's avatar, if one is set. - QString avatarUrl; + QUrl avatarUrl; /// The room's join rule. When not present, the room is assumed to /// be `public`. Note that rooms with `invite` join rules are not diff --git a/lib/csapi/definitions/request_token_response.h b/lib/csapi/definitions/request_token_response.h index f9981100..d5fbbadb 100644 --- a/lib/csapi/definitions/request_token_response.h +++ b/lib/csapi/definitions/request_token_response.h @@ -25,7 +25,7 @@ struct RequestTokenResponse { /// will happen without the client's involvement provided the homeserver /// advertises this specification version in the `/versions` response /// (ie: r0.5.0). - QString submitUrl; + QUrl submitUrl; }; template <> diff --git a/lib/csapi/definitions/wellknown/homeserver.h b/lib/csapi/definitions/wellknown/homeserver.h index 5cfaca24..b7db4182 100644 --- a/lib/csapi/definitions/wellknown/homeserver.h +++ b/lib/csapi/definitions/wellknown/homeserver.h @@ -10,7 +10,7 @@ namespace Quotient { /// Used by clients to discover homeserver information. struct HomeserverInformation { /// The base URL for the homeserver for client-server connections. - QString baseUrl; + QUrl baseUrl; }; template <> diff --git a/lib/csapi/definitions/wellknown/identity_server.h b/lib/csapi/definitions/wellknown/identity_server.h index 3bd07bd1..885e3d34 100644 --- a/lib/csapi/definitions/wellknown/identity_server.h +++ b/lib/csapi/definitions/wellknown/identity_server.h @@ -10,7 +10,7 @@ namespace Quotient { /// Used by clients to discover identity server information. struct IdentityServerInformation { /// The base URL for the identity server for client-server connections. - QString baseUrl; + QUrl baseUrl; }; template <> diff --git a/lib/csapi/profile.cpp b/lib/csapi/profile.cpp index 8436b8e6..745fa488 100644 --- a/lib/csapi/profile.cpp +++ b/lib/csapi/profile.cpp @@ -33,7 +33,7 @@ GetDisplayNameJob::GetDisplayNameJob(const QString& userId) false) {} -SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QString& avatarUrl) +SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QUrl& avatarUrl) : BaseJob(HttpVerb::Put, QStringLiteral("SetAvatarUrlJob"), QStringLiteral("/_matrix/client/r0") % "/profile/" % userId % "/avatar_url") diff --git a/lib/csapi/profile.h b/lib/csapi/profile.h index 8bbe4f8c..7f9c9e95 100644 --- a/lib/csapi/profile.h +++ b/lib/csapi/profile.h @@ -73,7 +73,7 @@ public: * \param avatarUrl * The new avatar URL for this user. */ - explicit SetAvatarUrlJob(const QString& userId, const QString& avatarUrl); + explicit SetAvatarUrlJob(const QString& userId, const QUrl& avatarUrl); }; /*! \brief Get the user's avatar URL. @@ -101,7 +101,7 @@ public: // Result properties /// The user's avatar URL if they have set one, otherwise not present. - QString avatarUrl() const { return loadFromJson("avatar_url"_ls); } + QUrl avatarUrl() const { return loadFromJson("avatar_url"_ls); } }; /*! \brief Get this user's profile information. @@ -130,7 +130,7 @@ public: // Result properties /// The user's avatar URL if they have set one, otherwise not present. - QString avatarUrl() const { return loadFromJson("avatar_url"_ls); } + QUrl avatarUrl() const { return loadFromJson("avatar_url"_ls); } /// The user's display name if they have set one, otherwise not present. QString displayname() const diff --git a/lib/csapi/pusher.h b/lib/csapi/pusher.h index 13c9ec25..622b0df6 100644 --- a/lib/csapi/pusher.h +++ b/lib/csapi/pusher.h @@ -21,7 +21,7 @@ public: struct PusherData { /// Required if `kind` is `http`. The URL to use to send /// notifications to. - QString url; + QUrl url; /// The format to use when sending notifications to the Push /// Gateway. QString format; @@ -119,7 +119,7 @@ public: /// Required if `kind` is `http`. The URL to use to send /// notifications to. MUST be an HTTPS URL with a path of /// `/_matrix/push/v1/notify`. - QString url; + QUrl url; /// The format to send notifications in to Push Gateways if the /// `kind` is `http`. The details about what fields the /// homeserver should send to the push gateway are defined in the diff --git a/lib/csapi/rooms.h b/lib/csapi/rooms.h index 51af2c65..2620582b 100644 --- a/lib/csapi/rooms.h +++ b/lib/csapi/rooms.h @@ -175,7 +175,7 @@ public: /// The display name of the user this object is representing. QString displayName; /// The mxc avatar url of the user this object is representing. - QString avatarUrl; + QUrl avatarUrl; }; // Construction/destruction diff --git a/lib/csapi/search.h b/lib/csapi/search.h index b56d9154..3d02752a 100644 --- a/lib/csapi/search.h +++ b/lib/csapi/search.h @@ -81,7 +81,7 @@ public: /// Performs a full text search across different categories. QString displayname; /// Performs a full text search across different categories. - QString avatarUrl; + QUrl avatarUrl; }; /// Context for result, if requested. diff --git a/lib/csapi/users.h b/lib/csapi/users.h index eab18f6c..ec186592 100644 --- a/lib/csapi/users.h +++ b/lib/csapi/users.h @@ -41,7 +41,7 @@ public: /// The display name of the user, if one exists. QString displayName; /// The avatar url, as an MXC, if one exists. - QString avatarUrl; + QUrl avatarUrl; }; // Construction/destruction -- cgit v1.2.3 From ed24065f2e9b8fce059c54137c04b790c6ce4fd1 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Sun, 22 Aug 2021 20:05:41 +0200 Subject: Regenerate API files --- lib/csapi/account-data.cpp | 4 ++-- lib/csapi/administrative_contact.cpp | 4 ++-- lib/csapi/content-repo.cpp | 2 +- lib/csapi/cross_signing.cpp | 2 +- lib/csapi/filter.cpp | 2 +- lib/csapi/openid.cpp | 2 +- lib/csapi/receipts.cpp | 2 +- lib/csapi/registration.cpp | 8 ++++---- lib/csapi/room_send.cpp | 2 +- lib/csapi/room_state.cpp | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) (limited to 'lib/csapi') diff --git a/lib/csapi/account-data.cpp b/lib/csapi/account-data.cpp index 6a40e908..80deb8f1 100644 --- a/lib/csapi/account-data.cpp +++ b/lib/csapi/account-data.cpp @@ -14,7 +14,7 @@ SetAccountDataJob::SetAccountDataJob(const QString& userId, const QString& type, QStringLiteral("/_matrix/client/r0") % "/user/" % userId % "/account_data/" % type) { - setRequestData(Data(toJson(content))); + setRequestData(RequestData(toJson(content))); } QUrl GetAccountDataJob::makeRequestUrl(QUrl baseUrl, const QString& userId, @@ -39,7 +39,7 @@ SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, QStringLiteral("/_matrix/client/r0") % "/user/" % userId % "/rooms/" % roomId % "/account_data/" % type) { - setRequestData(Data(toJson(content))); + setRequestData(RequestData(toJson(content))); } QUrl GetAccountDataPerRoomJob::makeRequestUrl(QUrl baseUrl, diff --git a/lib/csapi/administrative_contact.cpp b/lib/csapi/administrative_contact.cpp index fa4f475a..04360299 100644 --- a/lib/csapi/administrative_contact.cpp +++ b/lib/csapi/administrative_contact.cpp @@ -89,7 +89,7 @@ RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob( % "/account/3pid/email/requestToken", false) { - setRequestData(Data(toJson(body))); + setRequestData(RequestData(toJson(body))); } RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob( @@ -99,5 +99,5 @@ RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob( % "/account/3pid/msisdn/requestToken", false) { - setRequestData(Data(toJson(body))); + setRequestData(RequestData(toJson(body))); } diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index 00bc9706..2d82437b 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -22,7 +22,7 @@ UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, queryToUploadContent(filename)) { setRequestHeader("Content-Type", contentType.toLatin1()); - setRequestData(Data(content)); + setRequestData(RequestData(content)); addExpectedKey("content_uri"); } diff --git a/lib/csapi/cross_signing.cpp b/lib/csapi/cross_signing.cpp index 9bfc026a..ed2b15c0 100644 --- a/lib/csapi/cross_signing.cpp +++ b/lib/csapi/cross_signing.cpp @@ -30,5 +30,5 @@ UploadCrossSigningSignaturesJob::UploadCrossSigningSignaturesJob( : BaseJob(HttpVerb::Post, QStringLiteral("UploadCrossSigningSignaturesJob"), QStringLiteral("/_matrix/client/r0") % "/keys/signatures/upload") { - setRequestData(Data(toJson(signatures))); + setRequestData(RequestData(toJson(signatures))); } diff --git a/lib/csapi/filter.cpp b/lib/csapi/filter.cpp index bb3a893f..6b8863cc 100644 --- a/lib/csapi/filter.cpp +++ b/lib/csapi/filter.cpp @@ -13,7 +13,7 @@ DefineFilterJob::DefineFilterJob(const QString& userId, const Filter& filter) QStringLiteral("/_matrix/client/r0") % "/user/" % userId % "/filter") { - setRequestData(Data(toJson(filter))); + setRequestData(RequestData(toJson(filter))); addExpectedKey("filter_id"); } diff --git a/lib/csapi/openid.cpp b/lib/csapi/openid.cpp index 3941e9c0..0447db79 100644 --- a/lib/csapi/openid.cpp +++ b/lib/csapi/openid.cpp @@ -14,5 +14,5 @@ RequestOpenIdTokenJob::RequestOpenIdTokenJob(const QString& userId, QStringLiteral("/_matrix/client/r0") % "/user/" % userId % "/openid/request_token") { - setRequestData(Data(toJson(body))); + setRequestData(RequestData(toJson(body))); } diff --git a/lib/csapi/receipts.cpp b/lib/csapi/receipts.cpp index 00d1c28a..47b18174 100644 --- a/lib/csapi/receipts.cpp +++ b/lib/csapi/receipts.cpp @@ -15,5 +15,5 @@ PostReceiptJob::PostReceiptJob(const QString& roomId, const QString& receiptType QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/receipt/" % receiptType % "/" % eventId) { - setRequestData(Data(toJson(receipt))); + setRequestData(RequestData(toJson(receipt))); } diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 38649e63..c3617bfc 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -44,7 +44,7 @@ RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( % "/register/email/requestToken", false) { - setRequestData(Data(toJson(body))); + setRequestData(RequestData(toJson(body))); } RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( @@ -54,7 +54,7 @@ RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( % "/register/msisdn/requestToken", false) { - setRequestData(Data(toJson(body))); + setRequestData(RequestData(toJson(body))); } ChangePasswordJob::ChangePasswordJob(const QString& newPassword, @@ -78,7 +78,7 @@ RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( % "/account/password/email/requestToken", false) { - setRequestData(Data(toJson(body))); + setRequestData(RequestData(toJson(body))); } RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( @@ -89,7 +89,7 @@ RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( % "/account/password/msisdn/requestToken", false) { - setRequestData(Data(toJson(body))); + setRequestData(RequestData(toJson(body))); } DeactivateAccountJob::DeactivateAccountJob( diff --git a/lib/csapi/room_send.cpp b/lib/csapi/room_send.cpp index 63986c56..9fd8cb96 100644 --- a/lib/csapi/room_send.cpp +++ b/lib/csapi/room_send.cpp @@ -14,6 +14,6 @@ SendMessageJob::SendMessageJob(const QString& roomId, const QString& eventType, QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/send/" % eventType % "/" % txnId) { - setRequestData(Data(toJson(body))); + setRequestData(RequestData(toJson(body))); addExpectedKey("event_id"); } diff --git a/lib/csapi/room_state.cpp b/lib/csapi/room_state.cpp index e18108ac..37e897fa 100644 --- a/lib/csapi/room_state.cpp +++ b/lib/csapi/room_state.cpp @@ -16,6 +16,6 @@ SetRoomStateWithKeyJob::SetRoomStateWithKeyJob(const QString& roomId, QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/state/" % eventType % "/" % stateKey) { - setRequestData(Data(toJson(body))); + setRequestData(RequestData(toJson(body))); addExpectedKey("event_id"); } -- cgit v1.2.3 From 1fd25fe944b67c55435ed4d4d8fd1cbb0989bb5f Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Mon, 4 Oct 2021 18:40:48 +0200 Subject: Regenerate CS API files upon the previous commit --- lib/csapi/account-data.cpp | 28 ++++++++-------- lib/csapi/admin.cpp | 8 ++--- lib/csapi/administrative_contact.cpp | 27 +++++++-------- lib/csapi/appservice_room_directory.cpp | 6 ++-- lib/csapi/banning.cpp | 7 ++-- lib/csapi/capabilities.cpp | 9 ++--- lib/csapi/content-repo.cpp | 41 ++++++++++------------- lib/csapi/create_room.cpp | 4 +-- lib/csapi/cross_signing.cpp | 7 ++-- lib/csapi/device_management.cpp | 19 +++++------ lib/csapi/directory.cpp | 26 ++++++--------- lib/csapi/event_context.cpp | 11 +++--- lib/csapi/filter.cpp | 13 +++----- lib/csapi/inviting.cpp | 5 +-- lib/csapi/joining.cpp | 6 ++-- lib/csapi/keys.cpp | 14 ++++---- lib/csapi/kicking.cpp | 4 +-- lib/csapi/knocking.cpp | 4 +-- lib/csapi/leaving.cpp | 12 +++---- lib/csapi/list_joined_rooms.cpp | 9 ++--- lib/csapi/list_public_rooms.cpp | 20 +++++------ lib/csapi/login.cpp | 9 ++--- lib/csapi/logout.cpp | 14 +++----- lib/csapi/message_pagination.cpp | 7 ++-- lib/csapi/notifications.cpp | 8 ++--- lib/csapi/openid.cpp | 6 ++-- lib/csapi/peeking_events.cpp | 7 ++-- lib/csapi/presence.cpp | 12 +++---- lib/csapi/profile.cpp | 28 ++++++---------- lib/csapi/pusher.cpp | 9 ++--- lib/csapi/pushrules.cpp | 59 +++++++++++++++------------------ lib/csapi/read_markers.cpp | 5 +-- lib/csapi/receipts.cpp | 6 ++-- lib/csapi/redaction.cpp | 6 ++-- lib/csapi/registration.cpp | 28 +++++++--------- lib/csapi/report_content.cpp | 6 ++-- lib/csapi/room_send.cpp | 6 ++-- lib/csapi/room_state.cpp | 6 ++-- lib/csapi/room_upgrades.cpp | 5 +-- lib/csapi/rooms.cpp | 41 ++++++++++------------- lib/csapi/search.cpp | 4 +-- lib/csapi/sso_login_redirect.cpp | 15 ++++----- lib/csapi/tags.cpp | 24 ++++++-------- lib/csapi/third_party_lookup.cpp | 41 ++++++++++------------- lib/csapi/third_party_membership.cpp | 5 +-- lib/csapi/to_device.cpp | 6 ++-- lib/csapi/typing.cpp | 6 ++-- lib/csapi/users.cpp | 4 +-- lib/csapi/versions.cpp | 7 ++-- lib/csapi/voip.cpp | 9 ++--- lib/csapi/wellknown.cpp | 7 ++-- lib/csapi/whoami.cpp | 9 ++--- 52 files changed, 265 insertions(+), 420 deletions(-) (limited to 'lib/csapi') diff --git a/lib/csapi/account-data.cpp b/lib/csapi/account-data.cpp index 80deb8f1..09fc8d40 100644 --- a/lib/csapi/account-data.cpp +++ b/lib/csapi/account-data.cpp @@ -4,15 +4,13 @@ #include "account-data.h" -#include - using namespace Quotient; SetAccountDataJob::SetAccountDataJob(const QString& userId, const QString& type, const QJsonObject& content) : BaseJob(HttpVerb::Put, QStringLiteral("SetAccountDataJob"), - QStringLiteral("/_matrix/client/r0") % "/user/" % userId - % "/account_data/" % type) + makePath("/_matrix/client/r0", "/user/", userId, "/account_data/", + type)) { setRequestData(RequestData(toJson(content))); } @@ -21,14 +19,14 @@ QUrl GetAccountDataJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& type) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") % "/user/" - % userId % "/account_data/" % type); + makePath("/_matrix/client/r0", "/user/", + userId, "/account_data/", type)); } GetAccountDataJob::GetAccountDataJob(const QString& userId, const QString& type) : BaseJob(HttpVerb::Get, QStringLiteral("GetAccountDataJob"), - QStringLiteral("/_matrix/client/r0") % "/user/" % userId - % "/account_data/" % type) + makePath("/_matrix/client/r0", "/user/", userId, "/account_data/", + type)) {} SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, @@ -36,8 +34,8 @@ SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, const QString& type, const QJsonObject& content) : BaseJob(HttpVerb::Put, QStringLiteral("SetAccountDataPerRoomJob"), - QStringLiteral("/_matrix/client/r0") % "/user/" % userId - % "/rooms/" % roomId % "/account_data/" % type) + makePath("/_matrix/client/r0", "/user/", userId, "/rooms/", + roomId, "/account_data/", type)) { setRequestData(RequestData(toJson(content))); } @@ -48,15 +46,15 @@ QUrl GetAccountDataPerRoomJob::makeRequestUrl(QUrl baseUrl, const QString& type) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/user/" % userId % "/rooms/" % roomId - % "/account_data/" % type); + makePath("/_matrix/client/r0", "/user/", + userId, "/rooms/", roomId, + "/account_data/", type)); } GetAccountDataPerRoomJob::GetAccountDataPerRoomJob(const QString& userId, const QString& roomId, const QString& type) : BaseJob(HttpVerb::Get, QStringLiteral("GetAccountDataPerRoomJob"), - QStringLiteral("/_matrix/client/r0") % "/user/" % userId - % "/rooms/" % roomId % "/account_data/" % type) + makePath("/_matrix/client/r0", "/user/", userId, "/rooms/", + roomId, "/account_data/", type)) {} diff --git a/lib/csapi/admin.cpp b/lib/csapi/admin.cpp index 9619c441..81dd0624 100644 --- a/lib/csapi/admin.cpp +++ b/lib/csapi/admin.cpp @@ -4,18 +4,16 @@ #include "admin.h" -#include - using namespace Quotient; QUrl GetWhoIsJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/admin/whois/" % userId); + makePath("/_matrix/client/r0", + "/admin/whois/", userId)); } GetWhoIsJob::GetWhoIsJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetWhoIsJob"), - QStringLiteral("/_matrix/client/r0") % "/admin/whois/" % userId) + makePath("/_matrix/client/r0", "/admin/whois/", userId)) {} diff --git a/lib/csapi/administrative_contact.cpp b/lib/csapi/administrative_contact.cpp index 04360299..589c9fc1 100644 --- a/lib/csapi/administrative_contact.cpp +++ b/lib/csapi/administrative_contact.cpp @@ -4,25 +4,22 @@ #include "administrative_contact.h" -#include - using namespace Quotient; QUrl GetAccount3PIDsJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/account/3pid"); + return BaseJob::makeRequestUrl( + std::move(baseUrl), makePath("/_matrix/client/r0", "/account/3pid")); } GetAccount3PIDsJob::GetAccount3PIDsJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetAccount3PIDsJob"), - QStringLiteral("/_matrix/client/r0") % "/account/3pid") + makePath("/_matrix/client/r0", "/account/3pid")) {} Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds) : BaseJob(HttpVerb::Post, QStringLiteral("Post3PIDsJob"), - QStringLiteral("/_matrix/client/r0") % "/account/3pid") + makePath("/_matrix/client/r0", "/account/3pid")) { QJsonObject _data; addParam<>(_data, QStringLiteral("three_pid_creds"), threePidCreds); @@ -32,7 +29,7 @@ Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds) Add3PIDJob::Add3PIDJob(const QString& clientSecret, const QString& sid, const Omittable& auth) : BaseJob(HttpVerb::Post, QStringLiteral("Add3PIDJob"), - QStringLiteral("/_matrix/client/r0") % "/account/3pid/add") + makePath("/_matrix/client/r0", "/account/3pid/add")) { QJsonObject _data; addParam(_data, QStringLiteral("auth"), auth); @@ -44,7 +41,7 @@ Add3PIDJob::Add3PIDJob(const QString& clientSecret, const QString& sid, Bind3PIDJob::Bind3PIDJob(const QString& clientSecret, const QString& idServer, const QString& idAccessToken, const QString& sid) : BaseJob(HttpVerb::Post, QStringLiteral("Bind3PIDJob"), - QStringLiteral("/_matrix/client/r0") % "/account/3pid/bind") + makePath("/_matrix/client/r0", "/account/3pid/bind")) { QJsonObject _data; addParam<>(_data, QStringLiteral("client_secret"), clientSecret); @@ -58,7 +55,7 @@ Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium, const QString& address, const QString& idServer) : BaseJob(HttpVerb::Post, QStringLiteral("Delete3pidFromAccountJob"), - QStringLiteral("/_matrix/client/r0") % "/account/3pid/delete") + makePath("/_matrix/client/r0", "/account/3pid/delete")) { QJsonObject _data; addParam(_data, QStringLiteral("id_server"), idServer); @@ -72,7 +69,7 @@ Unbind3pidFromAccountJob::Unbind3pidFromAccountJob(const QString& medium, const QString& address, const QString& idServer) : BaseJob(HttpVerb::Post, QStringLiteral("Unbind3pidFromAccountJob"), - QStringLiteral("/_matrix/client/r0") % "/account/3pid/unbind") + makePath("/_matrix/client/r0", "/account/3pid/unbind")) { QJsonObject _data; addParam(_data, QStringLiteral("id_server"), idServer); @@ -85,8 +82,8 @@ Unbind3pidFromAccountJob::Unbind3pidFromAccountJob(const QString& medium, RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob( const EmailValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenTo3PIDEmailJob"), - QStringLiteral("/_matrix/client/r0") - % "/account/3pid/email/requestToken", + makePath("/_matrix/client/r0", + "/account/3pid/email/requestToken"), false) { setRequestData(RequestData(toJson(body))); @@ -95,8 +92,8 @@ RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob( RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob( const MsisdnValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenTo3PIDMSISDNJob"), - QStringLiteral("/_matrix/client/r0") - % "/account/3pid/msisdn/requestToken", + makePath("/_matrix/client/r0", + "/account/3pid/msisdn/requestToken"), false) { setRequestData(RequestData(toJson(body))); diff --git a/lib/csapi/appservice_room_directory.cpp b/lib/csapi/appservice_room_directory.cpp index 4d87e4af..40d784c6 100644 --- a/lib/csapi/appservice_room_directory.cpp +++ b/lib/csapi/appservice_room_directory.cpp @@ -4,16 +4,14 @@ #include "appservice_room_directory.h" -#include - using namespace Quotient; UpdateAppserviceRoomDirectoryVisibilityJob::UpdateAppserviceRoomDirectoryVisibilityJob( const QString& networkId, const QString& roomId, const QString& visibility) : BaseJob(HttpVerb::Put, QStringLiteral("UpdateAppserviceRoomDirectoryVisibilityJob"), - QStringLiteral("/_matrix/client/r0") - % "/directory/list/appservice/" % networkId % "/" % roomId) + makePath("/_matrix/client/r0", "/directory/list/appservice/", + networkId, "/", roomId)) { QJsonObject _data; addParam<>(_data, QStringLiteral("visibility"), visibility); diff --git a/lib/csapi/banning.cpp b/lib/csapi/banning.cpp index 8e0add1a..472128bb 100644 --- a/lib/csapi/banning.cpp +++ b/lib/csapi/banning.cpp @@ -4,14 +4,12 @@ #include "banning.h" -#include - using namespace Quotient; BanJob::BanJob(const QString& roomId, const QString& userId, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("BanJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/ban") + makePath("/_matrix/client/r0", "/rooms/", roomId, "/ban")) { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); @@ -22,8 +20,7 @@ BanJob::BanJob(const QString& roomId, const QString& userId, UnbanJob::UnbanJob(const QString& roomId, const QString& userId, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("UnbanJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/unban") + makePath("/_matrix/client/r0", "/rooms/", roomId, "/unban")) { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); diff --git a/lib/csapi/capabilities.cpp b/lib/csapi/capabilities.cpp index 33a53cad..bc21e462 100644 --- a/lib/csapi/capabilities.cpp +++ b/lib/csapi/capabilities.cpp @@ -4,20 +4,17 @@ #include "capabilities.h" -#include - using namespace Quotient; QUrl GetCapabilitiesJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/capabilities"); + return BaseJob::makeRequestUrl( + std::move(baseUrl), makePath("/_matrix/client/r0", "/capabilities")); } GetCapabilitiesJob::GetCapabilitiesJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetCapabilitiesJob"), - QStringLiteral("/_matrix/client/r0") % "/capabilities") + makePath("/_matrix/client/r0", "/capabilities")) { addExpectedKey("capabilities"); } diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index 2d82437b..6d1e38b6 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -4,8 +4,6 @@ #include "content-repo.h" -#include - using namespace Quotient; auto queryToUploadContent(const QString& filename) @@ -18,7 +16,7 @@ auto queryToUploadContent(const QString& filename) UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, const QString& contentType) : BaseJob(HttpVerb::Post, QStringLiteral("UploadContentJob"), - QStringLiteral("/_matrix/media/r0") % "/upload", + makePath("/_matrix/media/r0", "/upload"), queryToUploadContent(filename)) { setRequestHeader("Content-Type", contentType.toLatin1()); @@ -37,17 +35,16 @@ QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, bool allowRemote) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/media/r0") - % "/download/" % serverName % "/" - % mediaId, + makePath("/_matrix/media/r0", "/download/", + serverName, "/", mediaId), queryToGetContent(allowRemote)); } GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId, bool allowRemote) : BaseJob(HttpVerb::Get, QStringLiteral("GetContentJob"), - QStringLiteral("/_matrix/media/r0") % "/download/" % serverName - % "/" % mediaId, + makePath("/_matrix/media/r0", "/download/", serverName, "/", + mediaId), queryToGetContent(allowRemote), {}, false) { setExpectedContentTypes({ "*/*" }); @@ -67,9 +64,9 @@ QUrl GetContentOverrideNameJob::makeRequestUrl(QUrl baseUrl, bool allowRemote) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/media/r0") - % "/download/" % serverName % "/" - % mediaId % "/" % fileName, + makePath("/_matrix/media/r0", "/download/", + serverName, "/", mediaId, "/", + fileName), queryToGetContentOverrideName(allowRemote)); } @@ -78,8 +75,8 @@ GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, const QString& fileName, bool allowRemote) : BaseJob(HttpVerb::Get, QStringLiteral("GetContentOverrideNameJob"), - QStringLiteral("/_matrix/media/r0") % "/download/" % serverName - % "/" % mediaId % "/" % fileName, + makePath("/_matrix/media/r0", "/download/", serverName, "/", + mediaId, "/", fileName), queryToGetContentOverrideName(allowRemote), {}, false) { setExpectedContentTypes({ "*/*" }); @@ -104,8 +101,7 @@ QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, { return BaseJob::makeRequestUrl( std::move(baseUrl), - QStringLiteral("/_matrix/media/r0") % "/thumbnail/" % serverName % "/" - % mediaId, + makePath("/_matrix/media/r0", "/thumbnail/", serverName, "/", mediaId), queryToGetContentThumbnail(width, height, method, allowRemote)); } @@ -114,8 +110,8 @@ GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, int height, const QString& method, bool allowRemote) : BaseJob(HttpVerb::Get, QStringLiteral("GetContentThumbnailJob"), - QStringLiteral("/_matrix/media/r0") % "/thumbnail/" % serverName - % "/" % mediaId, + makePath("/_matrix/media/r0", "/thumbnail/", serverName, "/", + mediaId), queryToGetContentThumbnail(width, height, method, allowRemote), {}, false) { @@ -134,25 +130,24 @@ QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QUrl& url, Omittable ts) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/media/r0") - % "/preview_url", + makePath("/_matrix/media/r0", + "/preview_url"), queryToGetUrlPreview(url, ts)); } GetUrlPreviewJob::GetUrlPreviewJob(const QUrl& url, Omittable ts) : BaseJob(HttpVerb::Get, QStringLiteral("GetUrlPreviewJob"), - QStringLiteral("/_matrix/media/r0") % "/preview_url", + makePath("/_matrix/media/r0", "/preview_url"), queryToGetUrlPreview(url, ts)) {} QUrl GetConfigJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/media/r0") - % "/config"); + makePath("/_matrix/media/r0", "/config")); } GetConfigJob::GetConfigJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetConfigJob"), - QStringLiteral("/_matrix/media/r0") % "/config") + makePath("/_matrix/media/r0", "/config")) {} diff --git a/lib/csapi/create_room.cpp b/lib/csapi/create_room.cpp index a94f9951..9aaef87f 100644 --- a/lib/csapi/create_room.cpp +++ b/lib/csapi/create_room.cpp @@ -4,8 +4,6 @@ #include "create_room.h" -#include - using namespace Quotient; CreateRoomJob::CreateRoomJob(const QString& visibility, @@ -18,7 +16,7 @@ CreateRoomJob::CreateRoomJob(const QString& visibility, const QString& preset, Omittable isDirect, const QJsonObject& powerLevelContentOverride) : BaseJob(HttpVerb::Post, QStringLiteral("CreateRoomJob"), - QStringLiteral("/_matrix/client/r0") % "/createRoom") + makePath("/_matrix/client/r0", "/createRoom")) { QJsonObject _data; addParam(_data, QStringLiteral("visibility"), visibility); diff --git a/lib/csapi/cross_signing.cpp b/lib/csapi/cross_signing.cpp index ed2b15c0..1fa0e949 100644 --- a/lib/csapi/cross_signing.cpp +++ b/lib/csapi/cross_signing.cpp @@ -4,8 +4,6 @@ #include "cross_signing.h" -#include - using namespace Quotient; UploadCrossSigningKeysJob::UploadCrossSigningKeysJob( @@ -13,8 +11,7 @@ UploadCrossSigningKeysJob::UploadCrossSigningKeysJob( const Omittable& selfSigningKey, const Omittable& userSigningKey) : BaseJob(HttpVerb::Post, QStringLiteral("UploadCrossSigningKeysJob"), - QStringLiteral("/_matrix/client/r0") - % "/keys/device_signing/upload") + makePath("/_matrix/client/r0", "/keys/device_signing/upload")) { QJsonObject _data; addParam(_data, QStringLiteral("master_key"), masterKey); @@ -28,7 +25,7 @@ UploadCrossSigningKeysJob::UploadCrossSigningKeysJob( UploadCrossSigningSignaturesJob::UploadCrossSigningSignaturesJob( const QHash>& signatures) : BaseJob(HttpVerb::Post, QStringLiteral("UploadCrossSigningSignaturesJob"), - QStringLiteral("/_matrix/client/r0") % "/keys/signatures/upload") + makePath("/_matrix/client/r0", "/keys/signatures/upload")) { setRequestData(RequestData(toJson(signatures))); } diff --git a/lib/csapi/device_management.cpp b/lib/csapi/device_management.cpp index eac9a545..da6dbc76 100644 --- a/lib/csapi/device_management.cpp +++ b/lib/csapi/device_management.cpp @@ -4,38 +4,35 @@ #include "device_management.h" -#include - using namespace Quotient; QUrl GetDevicesJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/devices"); + makePath("/_matrix/client/r0", "/devices")); } GetDevicesJob::GetDevicesJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetDevicesJob"), - QStringLiteral("/_matrix/client/r0") % "/devices") + makePath("/_matrix/client/r0", "/devices")) {} QUrl GetDeviceJob::makeRequestUrl(QUrl baseUrl, const QString& deviceId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/devices/" % deviceId); + makePath("/_matrix/client/r0", "/devices/", + deviceId)); } GetDeviceJob::GetDeviceJob(const QString& deviceId) : BaseJob(HttpVerb::Get, QStringLiteral("GetDeviceJob"), - QStringLiteral("/_matrix/client/r0") % "/devices/" % deviceId) + makePath("/_matrix/client/r0", "/devices/", deviceId)) {} UpdateDeviceJob::UpdateDeviceJob(const QString& deviceId, const QString& displayName) : BaseJob(HttpVerb::Put, QStringLiteral("UpdateDeviceJob"), - QStringLiteral("/_matrix/client/r0") % "/devices/" % deviceId) + makePath("/_matrix/client/r0", "/devices/", deviceId)) { QJsonObject _data; addParam(_data, QStringLiteral("display_name"), displayName); @@ -45,7 +42,7 @@ UpdateDeviceJob::UpdateDeviceJob(const QString& deviceId, DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, const Omittable& auth) : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteDeviceJob"), - QStringLiteral("/_matrix/client/r0") % "/devices/" % deviceId) + makePath("/_matrix/client/r0", "/devices/", deviceId)) { QJsonObject _data; addParam(_data, QStringLiteral("auth"), auth); @@ -55,7 +52,7 @@ DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, DeleteDevicesJob::DeleteDevicesJob(const QStringList& devices, const Omittable& auth) : BaseJob(HttpVerb::Post, QStringLiteral("DeleteDevicesJob"), - QStringLiteral("/_matrix/client/r0") % "/delete_devices") + makePath("/_matrix/client/r0", "/delete_devices")) { QJsonObject _data; addParam<>(_data, QStringLiteral("devices"), devices); diff --git a/lib/csapi/directory.cpp b/lib/csapi/directory.cpp index 25ea82e2..b351b4ef 100644 --- a/lib/csapi/directory.cpp +++ b/lib/csapi/directory.cpp @@ -4,14 +4,11 @@ #include "directory.h" -#include - using namespace Quotient; SetRoomAliasJob::SetRoomAliasJob(const QString& roomAlias, const QString& roomId) : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomAliasJob"), - QStringLiteral("/_matrix/client/r0") % "/directory/room/" - % roomAlias) + makePath("/_matrix/client/r0", "/directory/room/", roomAlias)) { QJsonObject _data; addParam<>(_data, QStringLiteral("room_id"), roomId); @@ -21,41 +18,38 @@ SetRoomAliasJob::SetRoomAliasJob(const QString& roomAlias, const QString& roomId QUrl GetRoomIdByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/directory/room/" % roomAlias); + makePath("/_matrix/client/r0", + "/directory/room/", roomAlias)); } GetRoomIdByAliasJob::GetRoomIdByAliasJob(const QString& roomAlias) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomIdByAliasJob"), - QStringLiteral("/_matrix/client/r0") % "/directory/room/" - % roomAlias, + makePath("/_matrix/client/r0", "/directory/room/", roomAlias), false) {} QUrl DeleteRoomAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/directory/room/" % roomAlias); + makePath("/_matrix/client/r0", + "/directory/room/", roomAlias)); } DeleteRoomAliasJob::DeleteRoomAliasJob(const QString& roomAlias) : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteRoomAliasJob"), - QStringLiteral("/_matrix/client/r0") % "/directory/room/" - % roomAlias) + makePath("/_matrix/client/r0", "/directory/room/", roomAlias)) {} QUrl GetLocalAliasesJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/rooms/" % roomId % "/aliases"); + makePath("/_matrix/client/r0", "/rooms/", + roomId, "/aliases")); } GetLocalAliasesJob::GetLocalAliasesJob(const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetLocalAliasesJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/aliases") + makePath("/_matrix/client/r0", "/rooms/", roomId, "/aliases")) { addExpectedKey("aliases"); } diff --git a/lib/csapi/event_context.cpp b/lib/csapi/event_context.cpp index 3f4cd61e..877838e2 100644 --- a/lib/csapi/event_context.cpp +++ b/lib/csapi/event_context.cpp @@ -4,8 +4,6 @@ #include "event_context.h" -#include - using namespace Quotient; auto queryToGetEventContext(Omittable limit, const QString& filter) @@ -22,9 +20,8 @@ QUrl GetEventContextJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& filter) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/rooms/" % roomId % "/context/" - % eventId, + makePath("/_matrix/client/r0", "/rooms/", + roomId, "/context/", eventId), queryToGetEventContext(limit, filter)); } @@ -33,7 +30,7 @@ GetEventContextJob::GetEventContextJob(const QString& roomId, Omittable limit, const QString& filter) : BaseJob(HttpVerb::Get, QStringLiteral("GetEventContextJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/context/" % eventId, + makePath("/_matrix/client/r0", "/rooms/", roomId, "/context/", + eventId), queryToGetEventContext(limit, filter)) {} diff --git a/lib/csapi/filter.cpp b/lib/csapi/filter.cpp index 6b8863cc..38c68be7 100644 --- a/lib/csapi/filter.cpp +++ b/lib/csapi/filter.cpp @@ -4,14 +4,11 @@ #include "filter.h" -#include - using namespace Quotient; DefineFilterJob::DefineFilterJob(const QString& userId, const Filter& filter) : BaseJob(HttpVerb::Post, QStringLiteral("DefineFilterJob"), - QStringLiteral("/_matrix/client/r0") % "/user/" % userId - % "/filter") + makePath("/_matrix/client/r0", "/user/", userId, "/filter")) { setRequestData(RequestData(toJson(filter))); addExpectedKey("filter_id"); @@ -21,12 +18,12 @@ QUrl GetFilterJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& filterId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") % "/user/" - % userId % "/filter/" % filterId); + makePath("/_matrix/client/r0", "/user/", + userId, "/filter/", filterId)); } GetFilterJob::GetFilterJob(const QString& userId, const QString& filterId) : BaseJob(HttpVerb::Get, QStringLiteral("GetFilterJob"), - QStringLiteral("/_matrix/client/r0") % "/user/" % userId - % "/filter/" % filterId) + makePath("/_matrix/client/r0", "/user/", userId, "/filter/", + filterId)) {} diff --git a/lib/csapi/inviting.cpp b/lib/csapi/inviting.cpp index 1e2554f4..39d24611 100644 --- a/lib/csapi/inviting.cpp +++ b/lib/csapi/inviting.cpp @@ -4,15 +4,12 @@ #include "inviting.h" -#include - using namespace Quotient; InviteUserJob::InviteUserJob(const QString& roomId, const QString& userId, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("InviteUserJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/invite") + makePath("/_matrix/client/r0", "/rooms/", roomId, "/invite")) { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); diff --git a/lib/csapi/joining.cpp b/lib/csapi/joining.cpp index f5266f0b..373c1c6a 100644 --- a/lib/csapi/joining.cpp +++ b/lib/csapi/joining.cpp @@ -4,15 +4,13 @@ #include "joining.h" -#include - using namespace Quotient; JoinRoomByIdJob::JoinRoomByIdJob( const QString& roomId, const Omittable& thirdPartySigned, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("JoinRoomByIdJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/join") + makePath("/_matrix/client/r0", "/rooms/", roomId, "/join")) { QJsonObject _data; addParam(_data, QStringLiteral("third_party_signed"), @@ -34,7 +32,7 @@ JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, const Omittable& thirdPartySigned, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("JoinRoomJob"), - QStringLiteral("/_matrix/client/r0") % "/join/" % roomIdOrAlias, + makePath("/_matrix/client/r0", "/join/", roomIdOrAlias), queryToJoinRoom(serverName)) { QJsonObject _data; diff --git a/lib/csapi/keys.cpp b/lib/csapi/keys.cpp index ba5d8e12..d6bd2fab 100644 --- a/lib/csapi/keys.cpp +++ b/lib/csapi/keys.cpp @@ -4,14 +4,12 @@ #include "keys.h" -#include - using namespace Quotient; UploadKeysJob::UploadKeysJob(const Omittable& deviceKeys, const QHash& oneTimeKeys) : BaseJob(HttpVerb::Post, QStringLiteral("UploadKeysJob"), - QStringLiteral("/_matrix/client/r0") % "/keys/upload") + makePath("/_matrix/client/r0", "/keys/upload")) { QJsonObject _data; addParam(_data, QStringLiteral("device_keys"), deviceKeys); @@ -23,7 +21,7 @@ UploadKeysJob::UploadKeysJob(const Omittable& deviceKeys, QueryKeysJob::QueryKeysJob(const QHash& deviceKeys, Omittable timeout, const QString& token) : BaseJob(HttpVerb::Post, QStringLiteral("QueryKeysJob"), - QStringLiteral("/_matrix/client/r0") % "/keys/query") + makePath("/_matrix/client/r0", "/keys/query")) { QJsonObject _data; addParam(_data, QStringLiteral("timeout"), timeout); @@ -36,7 +34,7 @@ ClaimKeysJob::ClaimKeysJob( const QHash>& oneTimeKeys, Omittable timeout) : BaseJob(HttpVerb::Post, QStringLiteral("ClaimKeysJob"), - QStringLiteral("/_matrix/client/r0") % "/keys/claim") + makePath("/_matrix/client/r0", "/keys/claim")) { QJsonObject _data; addParam(_data, QStringLiteral("timeout"), timeout); @@ -57,13 +55,13 @@ QUrl GetKeysChangesJob::makeRequestUrl(QUrl baseUrl, const QString& from, const QString& to) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/keys/changes", + makePath("/_matrix/client/r0", + "/keys/changes"), queryToGetKeysChanges(from, to)); } GetKeysChangesJob::GetKeysChangesJob(const QString& from, const QString& to) : BaseJob(HttpVerb::Get, QStringLiteral("GetKeysChangesJob"), - QStringLiteral("/_matrix/client/r0") % "/keys/changes", + makePath("/_matrix/client/r0", "/keys/changes"), queryToGetKeysChanges(from, to)) {} diff --git a/lib/csapi/kicking.cpp b/lib/csapi/kicking.cpp index 7de5ce01..433e592c 100644 --- a/lib/csapi/kicking.cpp +++ b/lib/csapi/kicking.cpp @@ -4,14 +4,12 @@ #include "kicking.h" -#include - using namespace Quotient; KickJob::KickJob(const QString& roomId, const QString& userId, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("KickJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/kick") + makePath("/_matrix/client/r0", "/rooms/", roomId, "/kick")) { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); diff --git a/lib/csapi/knocking.cpp b/lib/csapi/knocking.cpp index 788bb378..73e13e6e 100644 --- a/lib/csapi/knocking.cpp +++ b/lib/csapi/knocking.cpp @@ -4,8 +4,6 @@ #include "knocking.h" -#include - using namespace Quotient; auto queryToKnockRoom(const QStringList& serverName) @@ -18,7 +16,7 @@ auto queryToKnockRoom(const QStringList& serverName) KnockRoomJob::KnockRoomJob(const QString& roomIdOrAlias, const QStringList& serverName, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("KnockRoomJob"), - QStringLiteral("/_matrix/client/r0") % "/knock/" % roomIdOrAlias, + makePath("/_matrix/client/r0", "/knock/", roomIdOrAlias), queryToKnockRoom(serverName)) { QJsonObject _data; diff --git a/lib/csapi/leaving.cpp b/lib/csapi/leaving.cpp index f4c5f120..0e5386be 100644 --- a/lib/csapi/leaving.cpp +++ b/lib/csapi/leaving.cpp @@ -4,14 +4,11 @@ #include "leaving.h" -#include - using namespace Quotient; LeaveRoomJob::LeaveRoomJob(const QString& roomId, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("LeaveRoomJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/leave") + makePath("/_matrix/client/r0", "/rooms/", roomId, "/leave")) { QJsonObject _data; addParam(_data, QStringLiteral("reason"), reason); @@ -21,12 +18,11 @@ LeaveRoomJob::LeaveRoomJob(const QString& roomId, const QString& reason) QUrl ForgetRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/rooms/" % roomId % "/forget"); + makePath("/_matrix/client/r0", "/rooms/", + roomId, "/forget")); } ForgetRoomJob::ForgetRoomJob(const QString& roomId) : BaseJob(HttpVerb::Post, QStringLiteral("ForgetRoomJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/forget") + makePath("/_matrix/client/r0", "/rooms/", roomId, "/forget")) {} diff --git a/lib/csapi/list_joined_rooms.cpp b/lib/csapi/list_joined_rooms.cpp index 8d7e267f..22ba04da 100644 --- a/lib/csapi/list_joined_rooms.cpp +++ b/lib/csapi/list_joined_rooms.cpp @@ -4,20 +4,17 @@ #include "list_joined_rooms.h" -#include - using namespace Quotient; QUrl GetJoinedRoomsJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/joined_rooms"); + return BaseJob::makeRequestUrl( + std::move(baseUrl), makePath("/_matrix/client/r0", "/joined_rooms")); } GetJoinedRoomsJob::GetJoinedRoomsJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetJoinedRoomsJob"), - QStringLiteral("/_matrix/client/r0") % "/joined_rooms") + makePath("/_matrix/client/r0", "/joined_rooms")) { addExpectedKey("joined_rooms"); } diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp index a4bcb934..25f8da5c 100644 --- a/lib/csapi/list_public_rooms.cpp +++ b/lib/csapi/list_public_rooms.cpp @@ -4,31 +4,27 @@ #include "list_public_rooms.h" -#include - using namespace Quotient; QUrl GetRoomVisibilityOnDirectoryJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/directory/list/room/" % roomId); + makePath("/_matrix/client/r0", + "/directory/list/room/", roomId)); } GetRoomVisibilityOnDirectoryJob::GetRoomVisibilityOnDirectoryJob( const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomVisibilityOnDirectoryJob"), - QStringLiteral("/_matrix/client/r0") % "/directory/list/room/" - % roomId, + makePath("/_matrix/client/r0", "/directory/list/room/", roomId), false) {} SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob( const QString& roomId, const QString& visibility) : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomVisibilityOnDirectoryJob"), - QStringLiteral("/_matrix/client/r0") % "/directory/list/room/" - % roomId) + makePath("/_matrix/client/r0", "/directory/list/room/", roomId)) { QJsonObject _data; addParam(_data, QStringLiteral("visibility"), visibility); @@ -50,15 +46,15 @@ QUrl GetPublicRoomsJob::makeRequestUrl(QUrl baseUrl, Omittable limit, const QString& server) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/publicRooms", + makePath("/_matrix/client/r0", + "/publicRooms"), queryToGetPublicRooms(limit, since, server)); } GetPublicRoomsJob::GetPublicRoomsJob(Omittable limit, const QString& since, const QString& server) : BaseJob(HttpVerb::Get, QStringLiteral("GetPublicRoomsJob"), - QStringLiteral("/_matrix/client/r0") % "/publicRooms", + makePath("/_matrix/client/r0", "/publicRooms"), queryToGetPublicRooms(limit, since, server), {}, false) { addExpectedKey("chunk"); @@ -78,7 +74,7 @@ QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, Omittable includeAllNetworks, const QString& thirdPartyInstanceId) : BaseJob(HttpVerb::Post, QStringLiteral("QueryPublicRoomsJob"), - QStringLiteral("/_matrix/client/r0") % "/publicRooms", + makePath("/_matrix/client/r0", "/publicRooms"), queryToQueryPublicRooms(server)) { QJsonObject _data; diff --git a/lib/csapi/login.cpp b/lib/csapi/login.cpp index a5bac9ea..71fd93c5 100644 --- a/lib/csapi/login.cpp +++ b/lib/csapi/login.cpp @@ -4,20 +4,17 @@ #include "login.h" -#include - using namespace Quotient; QUrl GetLoginFlowsJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/login"); + makePath("/_matrix/client/r0", "/login")); } GetLoginFlowsJob::GetLoginFlowsJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetLoginFlowsJob"), - QStringLiteral("/_matrix/client/r0") % "/login", false) + makePath("/_matrix/client/r0", "/login"), false) {} LoginJob::LoginJob(const QString& type, @@ -26,7 +23,7 @@ LoginJob::LoginJob(const QString& type, const QString& deviceId, const QString& initialDeviceDisplayName) : BaseJob(HttpVerb::Post, QStringLiteral("LoginJob"), - QStringLiteral("/_matrix/client/r0") % "/login", false) + makePath("/_matrix/client/r0", "/login"), false) { QJsonObject _data; addParam<>(_data, QStringLiteral("type"), type); diff --git a/lib/csapi/logout.cpp b/lib/csapi/logout.cpp index 9583b8ec..e8083e31 100644 --- a/lib/csapi/logout.cpp +++ b/lib/csapi/logout.cpp @@ -4,30 +4,26 @@ #include "logout.h" -#include - using namespace Quotient; QUrl LogoutJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/logout"); + makePath("/_matrix/client/r0", "/logout")); } LogoutJob::LogoutJob() : BaseJob(HttpVerb::Post, QStringLiteral("LogoutJob"), - QStringLiteral("/_matrix/client/r0") % "/logout") + makePath("/_matrix/client/r0", "/logout")) {} QUrl LogoutAllJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/logout/all"); + return BaseJob::makeRequestUrl( + std::move(baseUrl), makePath("/_matrix/client/r0", "/logout/all")); } LogoutAllJob::LogoutAllJob() : BaseJob(HttpVerb::Post, QStringLiteral("LogoutAllJob"), - QStringLiteral("/_matrix/client/r0") % "/logout/all") + makePath("/_matrix/client/r0", "/logout/all")) {} diff --git a/lib/csapi/message_pagination.cpp b/lib/csapi/message_pagination.cpp index 441e4dea..1a93b75b 100644 --- a/lib/csapi/message_pagination.cpp +++ b/lib/csapi/message_pagination.cpp @@ -4,8 +4,6 @@ #include "message_pagination.h" -#include - using namespace Quotient; auto queryToGetRoomEvents(const QString& from, const QString& to, @@ -28,7 +26,7 @@ QUrl GetRoomEventsJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, { return BaseJob::makeRequestUrl( std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/messages", + makePath("/_matrix/client/r0", "/rooms/", roomId, "/messages"), queryToGetRoomEvents(from, to, dir, limit, filter)); } @@ -36,7 +34,6 @@ GetRoomEventsJob::GetRoomEventsJob(const QString& roomId, const QString& from, const QString& dir, const QString& to, Omittable limit, const QString& filter) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomEventsJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/messages", + makePath("/_matrix/client/r0", "/rooms/", roomId, "/messages"), queryToGetRoomEvents(from, to, dir, limit, filter)) {} diff --git a/lib/csapi/notifications.cpp b/lib/csapi/notifications.cpp index a38e46f5..1e523c6f 100644 --- a/lib/csapi/notifications.cpp +++ b/lib/csapi/notifications.cpp @@ -4,8 +4,6 @@ #include "notifications.h" -#include - using namespace Quotient; auto queryToGetNotifications(const QString& from, Omittable limit, @@ -23,8 +21,8 @@ QUrl GetNotificationsJob::makeRequestUrl(QUrl baseUrl, const QString& from, const QString& only) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/notifications", + makePath("/_matrix/client/r0", + "/notifications"), queryToGetNotifications(from, limit, only)); } @@ -32,7 +30,7 @@ GetNotificationsJob::GetNotificationsJob(const QString& from, Omittable limit, const QString& only) : BaseJob(HttpVerb::Get, QStringLiteral("GetNotificationsJob"), - QStringLiteral("/_matrix/client/r0") % "/notifications", + makePath("/_matrix/client/r0", "/notifications"), queryToGetNotifications(from, limit, only)) { addExpectedKey("notifications"); diff --git a/lib/csapi/openid.cpp b/lib/csapi/openid.cpp index 0447db79..5c93a2d7 100644 --- a/lib/csapi/openid.cpp +++ b/lib/csapi/openid.cpp @@ -4,15 +4,13 @@ #include "openid.h" -#include - using namespace Quotient; RequestOpenIdTokenJob::RequestOpenIdTokenJob(const QString& userId, const QJsonObject& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestOpenIdTokenJob"), - QStringLiteral("/_matrix/client/r0") % "/user/" % userId - % "/openid/request_token") + makePath("/_matrix/client/r0", "/user/", userId, + "/openid/request_token")) { setRequestData(RequestData(toJson(body))); } diff --git a/lib/csapi/peeking_events.cpp b/lib/csapi/peeking_events.cpp index ad2f9afe..eb5d22fa 100644 --- a/lib/csapi/peeking_events.cpp +++ b/lib/csapi/peeking_events.cpp @@ -4,8 +4,6 @@ #include "peeking_events.h" -#include - using namespace Quotient; auto queryToPeekEvents(const QString& from, Omittable timeout, @@ -22,14 +20,13 @@ QUrl PeekEventsJob::makeRequestUrl(QUrl baseUrl, const QString& from, Omittable timeout, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/events", + makePath("/_matrix/client/r0", "/events"), queryToPeekEvents(from, timeout, roomId)); } PeekEventsJob::PeekEventsJob(const QString& from, Omittable timeout, const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("PeekEventsJob"), - QStringLiteral("/_matrix/client/r0") % "/events", + makePath("/_matrix/client/r0", "/events"), queryToPeekEvents(from, timeout, roomId)) {} diff --git a/lib/csapi/presence.cpp b/lib/csapi/presence.cpp index 58d0d157..4f77c466 100644 --- a/lib/csapi/presence.cpp +++ b/lib/csapi/presence.cpp @@ -4,15 +4,12 @@ #include "presence.h" -#include - using namespace Quotient; SetPresenceJob::SetPresenceJob(const QString& userId, const QString& presence, const QString& statusMsg) : BaseJob(HttpVerb::Put, QStringLiteral("SetPresenceJob"), - QStringLiteral("/_matrix/client/r0") % "/presence/" % userId - % "/status") + makePath("/_matrix/client/r0", "/presence/", userId, "/status")) { QJsonObject _data; addParam<>(_data, QStringLiteral("presence"), presence); @@ -23,14 +20,13 @@ SetPresenceJob::SetPresenceJob(const QString& userId, const QString& presence, QUrl GetPresenceJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/presence/" % userId % "/status"); + makePath("/_matrix/client/r0", "/presence/", + userId, "/status")); } GetPresenceJob::GetPresenceJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetPresenceJob"), - QStringLiteral("/_matrix/client/r0") % "/presence/" % userId - % "/status") + makePath("/_matrix/client/r0", "/presence/", userId, "/status")) { addExpectedKey("presence"); } diff --git a/lib/csapi/profile.cpp b/lib/csapi/profile.cpp index 745fa488..64ac84ca 100644 --- a/lib/csapi/profile.cpp +++ b/lib/csapi/profile.cpp @@ -4,15 +4,12 @@ #include "profile.h" -#include - using namespace Quotient; SetDisplayNameJob::SetDisplayNameJob(const QString& userId, const QString& displayname) : BaseJob(HttpVerb::Put, QStringLiteral("SetDisplayNameJob"), - QStringLiteral("/_matrix/client/r0") % "/profile/" % userId - % "/displayname") + makePath("/_matrix/client/r0", "/profile/", userId, "/displayname")) { QJsonObject _data; addParam<>(_data, QStringLiteral("displayname"), displayname); @@ -22,21 +19,19 @@ SetDisplayNameJob::SetDisplayNameJob(const QString& userId, QUrl GetDisplayNameJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/profile/" % userId % "/displayname"); + makePath("/_matrix/client/r0", "/profile/", + userId, "/displayname")); } GetDisplayNameJob::GetDisplayNameJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetDisplayNameJob"), - QStringLiteral("/_matrix/client/r0") % "/profile/" % userId - % "/displayname", + makePath("/_matrix/client/r0", "/profile/", userId, "/displayname"), false) {} SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QUrl& avatarUrl) : BaseJob(HttpVerb::Put, QStringLiteral("SetAvatarUrlJob"), - QStringLiteral("/_matrix/client/r0") % "/profile/" % userId - % "/avatar_url") + makePath("/_matrix/client/r0", "/profile/", userId, "/avatar_url")) { QJsonObject _data; addParam<>(_data, QStringLiteral("avatar_url"), avatarUrl); @@ -46,25 +41,24 @@ SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QUrl& avatarUrl) QUrl GetAvatarUrlJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/profile/" % userId % "/avatar_url"); + makePath("/_matrix/client/r0", "/profile/", + userId, "/avatar_url")); } GetAvatarUrlJob::GetAvatarUrlJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetAvatarUrlJob"), - QStringLiteral("/_matrix/client/r0") % "/profile/" % userId - % "/avatar_url", + makePath("/_matrix/client/r0", "/profile/", userId, "/avatar_url"), false) {} QUrl GetUserProfileJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/profile/" % userId); + makePath("/_matrix/client/r0", "/profile/", + userId)); } GetUserProfileJob::GetUserProfileJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetUserProfileJob"), - QStringLiteral("/_matrix/client/r0") % "/profile/" % userId, false) + makePath("/_matrix/client/r0", "/profile/", userId), false) {} diff --git a/lib/csapi/pusher.cpp b/lib/csapi/pusher.cpp index 028022c5..ef4b3767 100644 --- a/lib/csapi/pusher.cpp +++ b/lib/csapi/pusher.cpp @@ -4,20 +4,17 @@ #include "pusher.h" -#include - using namespace Quotient; QUrl GetPushersJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/pushers"); + makePath("/_matrix/client/r0", "/pushers")); } GetPushersJob::GetPushersJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetPushersJob"), - QStringLiteral("/_matrix/client/r0") % "/pushers") + makePath("/_matrix/client/r0", "/pushers")) {} PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind, @@ -26,7 +23,7 @@ PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind, const QString& lang, const PusherData& data, const QString& profileTag, Omittable append) : BaseJob(HttpVerb::Post, QStringLiteral("PostPusherJob"), - QStringLiteral("/_matrix/client/r0") % "/pushers/set") + makePath("/_matrix/client/r0", "/pushers/set")) { QJsonObject _data; addParam<>(_data, QStringLiteral("pushkey"), pushkey); diff --git a/lib/csapi/pushrules.cpp b/lib/csapi/pushrules.cpp index ab7d0038..0d840788 100644 --- a/lib/csapi/pushrules.cpp +++ b/lib/csapi/pushrules.cpp @@ -4,20 +4,17 @@ #include "pushrules.h" -#include - using namespace Quotient; QUrl GetPushRulesJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/pushrules"); + return BaseJob::makeRequestUrl( + std::move(baseUrl), makePath("/_matrix/client/r0", "/pushrules")); } GetPushRulesJob::GetPushRulesJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetPushRulesJob"), - QStringLiteral("/_matrix/client/r0") % "/pushrules") + makePath("/_matrix/client/r0", "/pushrules")) { addExpectedKey("global"); } @@ -26,16 +23,15 @@ QUrl GetPushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/pushrules/" % scope % "/" % kind - % "/" % ruleId); + makePath("/_matrix/client/r0", "/pushrules/", + scope, "/", kind, "/", ruleId)); } GetPushRuleJob::GetPushRuleJob(const QString& scope, const QString& kind, const QString& ruleId) : BaseJob(HttpVerb::Get, QStringLiteral("GetPushRuleJob"), - QStringLiteral("/_matrix/client/r0") % "/pushrules/" % scope % "/" - % kind % "/" % ruleId) + makePath("/_matrix/client/r0", "/pushrules/", scope, "/", kind, + "/", ruleId)) {} QUrl DeletePushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope, @@ -43,16 +39,15 @@ QUrl DeletePushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& ruleId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/pushrules/" % scope % "/" % kind - % "/" % ruleId); + makePath("/_matrix/client/r0", "/pushrules/", + scope, "/", kind, "/", ruleId)); } DeletePushRuleJob::DeletePushRuleJob(const QString& scope, const QString& kind, const QString& ruleId) : BaseJob(HttpVerb::Delete, QStringLiteral("DeletePushRuleJob"), - QStringLiteral("/_matrix/client/r0") % "/pushrules/" % scope % "/" - % kind % "/" % ruleId) + makePath("/_matrix/client/r0", "/pushrules/", scope, "/", kind, + "/", ruleId)) {} auto queryToSetPushRule(const QString& before, const QString& after) @@ -70,8 +65,8 @@ SetPushRuleJob::SetPushRuleJob(const QString& scope, const QString& kind, const QVector& conditions, const QString& pattern) : BaseJob(HttpVerb::Put, QStringLiteral("SetPushRuleJob"), - QStringLiteral("/_matrix/client/r0") % "/pushrules/" % scope % "/" - % kind % "/" % ruleId, + makePath("/_matrix/client/r0", "/pushrules/", scope, "/", kind, + "/", ruleId), queryToSetPushRule(before, after)) { QJsonObject _data; @@ -86,17 +81,17 @@ QUrl IsPushRuleEnabledJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& ruleId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/pushrules/" % scope % "/" % kind - % "/" % ruleId % "/enabled"); + makePath("/_matrix/client/r0", "/pushrules/", + scope, "/", kind, "/", ruleId, + "/enabled")); } IsPushRuleEnabledJob::IsPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId) : BaseJob(HttpVerb::Get, QStringLiteral("IsPushRuleEnabledJob"), - QStringLiteral("/_matrix/client/r0") % "/pushrules/" % scope % "/" - % kind % "/" % ruleId % "/enabled") + makePath("/_matrix/client/r0", "/pushrules/", scope, "/", kind, + "/", ruleId, "/enabled")) { addExpectedKey("enabled"); } @@ -105,8 +100,8 @@ SetPushRuleEnabledJob::SetPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId, bool enabled) : BaseJob(HttpVerb::Put, QStringLiteral("SetPushRuleEnabledJob"), - QStringLiteral("/_matrix/client/r0") % "/pushrules/" % scope % "/" - % kind % "/" % ruleId % "/enabled") + makePath("/_matrix/client/r0", "/pushrules/", scope, "/", kind, + "/", ruleId, "/enabled")) { QJsonObject _data; addParam<>(_data, QStringLiteral("enabled"), enabled); @@ -118,17 +113,17 @@ QUrl GetPushRuleActionsJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& ruleId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/pushrules/" % scope % "/" % kind - % "/" % ruleId % "/actions"); + makePath("/_matrix/client/r0", "/pushrules/", + scope, "/", kind, "/", ruleId, + "/actions")); } GetPushRuleActionsJob::GetPushRuleActionsJob(const QString& scope, const QString& kind, const QString& ruleId) : BaseJob(HttpVerb::Get, QStringLiteral("GetPushRuleActionsJob"), - QStringLiteral("/_matrix/client/r0") % "/pushrules/" % scope % "/" - % kind % "/" % ruleId % "/actions") + makePath("/_matrix/client/r0", "/pushrules/", scope, "/", kind, + "/", ruleId, "/actions")) { addExpectedKey("actions"); } @@ -138,8 +133,8 @@ SetPushRuleActionsJob::SetPushRuleActionsJob(const QString& scope, const QString& ruleId, const QVector& actions) : BaseJob(HttpVerb::Put, QStringLiteral("SetPushRuleActionsJob"), - QStringLiteral("/_matrix/client/r0") % "/pushrules/" % scope % "/" - % kind % "/" % ruleId % "/actions") + makePath("/_matrix/client/r0", "/pushrules/", scope, "/", kind, + "/", ruleId, "/actions")) { QJsonObject _data; addParam<>(_data, QStringLiteral("actions"), actions); diff --git a/lib/csapi/read_markers.cpp b/lib/csapi/read_markers.cpp index 39e4d148..f2edb71e 100644 --- a/lib/csapi/read_markers.cpp +++ b/lib/csapi/read_markers.cpp @@ -4,16 +4,13 @@ #include "read_markers.h" -#include - using namespace Quotient; SetReadMarkerJob::SetReadMarkerJob(const QString& roomId, const QString& mFullyRead, const QString& mRead) : BaseJob(HttpVerb::Post, QStringLiteral("SetReadMarkerJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/read_markers") + makePath("/_matrix/client/r0", "/rooms/", roomId, "/read_markers")) { QJsonObject _data; addParam<>(_data, QStringLiteral("m.fully_read"), mFullyRead); diff --git a/lib/csapi/receipts.cpp b/lib/csapi/receipts.cpp index 47b18174..401c3bfe 100644 --- a/lib/csapi/receipts.cpp +++ b/lib/csapi/receipts.cpp @@ -4,16 +4,14 @@ #include "receipts.h" -#include - using namespace Quotient; PostReceiptJob::PostReceiptJob(const QString& roomId, const QString& receiptType, const QString& eventId, const QJsonObject& receipt) : BaseJob(HttpVerb::Post, QStringLiteral("PostReceiptJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/receipt/" % receiptType % "/" % eventId) + makePath("/_matrix/client/r0", "/rooms/", roomId, "/receipt/", + receiptType, "/", eventId)) { setRequestData(RequestData(toJson(receipt))); } diff --git a/lib/csapi/redaction.cpp b/lib/csapi/redaction.cpp index 91497064..acf1b0e4 100644 --- a/lib/csapi/redaction.cpp +++ b/lib/csapi/redaction.cpp @@ -4,15 +4,13 @@ #include "redaction.h" -#include - using namespace Quotient; RedactEventJob::RedactEventJob(const QString& roomId, const QString& eventId, const QString& txnId, const QString& reason) : BaseJob(HttpVerb::Put, QStringLiteral("RedactEventJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/redact/" % eventId % "/" % txnId) + makePath("/_matrix/client/r0", "/rooms/", roomId, "/redact/", + eventId, "/", txnId)) { QJsonObject _data; addParam(_data, QStringLiteral("reason"), reason); diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index c3617bfc..153abcee 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -4,8 +4,6 @@ #include "registration.h" -#include - using namespace Quotient; auto queryToRegister(const QString& kind) @@ -22,7 +20,7 @@ RegisterJob::RegisterJob(const QString& kind, const QString& initialDeviceDisplayName, Omittable inhibitLogin) : BaseJob(HttpVerb::Post, QStringLiteral("RegisterJob"), - QStringLiteral("/_matrix/client/r0") % "/register", + makePath("/_matrix/client/r0", "/register"), queryToRegister(kind), {}, false) { QJsonObject _data; @@ -40,8 +38,7 @@ RegisterJob::RegisterJob(const QString& kind, RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( const EmailValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterEmailJob"), - QStringLiteral("/_matrix/client/r0") - % "/register/email/requestToken", + makePath("/_matrix/client/r0", "/register/email/requestToken"), false) { setRequestData(RequestData(toJson(body))); @@ -50,8 +47,7 @@ RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( const MsisdnValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterMSISDNJob"), - QStringLiteral("/_matrix/client/r0") - % "/register/msisdn/requestToken", + makePath("/_matrix/client/r0", "/register/msisdn/requestToken"), false) { setRequestData(RequestData(toJson(body))); @@ -61,7 +57,7 @@ ChangePasswordJob::ChangePasswordJob(const QString& newPassword, bool logoutDevices, const Omittable& auth) : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), - QStringLiteral("/_matrix/client/r0") % "/account/password") + makePath("/_matrix/client/r0", "/account/password")) { QJsonObject _data; addParam<>(_data, QStringLiteral("new_password"), newPassword); @@ -74,8 +70,8 @@ RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( const EmailValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToResetPasswordEmailJob"), - QStringLiteral("/_matrix/client/r0") - % "/account/password/email/requestToken", + makePath("/_matrix/client/r0", + "/account/password/email/requestToken"), false) { setRequestData(RequestData(toJson(body))); @@ -85,8 +81,8 @@ RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( const MsisdnValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToResetPasswordMSISDNJob"), - QStringLiteral("/_matrix/client/r0") - % "/account/password/msisdn/requestToken", + makePath("/_matrix/client/r0", + "/account/password/msisdn/requestToken"), false) { setRequestData(RequestData(toJson(body))); @@ -95,7 +91,7 @@ RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( DeactivateAccountJob::DeactivateAccountJob( const Omittable& auth, const QString& idServer) : BaseJob(HttpVerb::Post, QStringLiteral("DeactivateAccountJob"), - QStringLiteral("/_matrix/client/r0") % "/account/deactivate") + makePath("/_matrix/client/r0", "/account/deactivate")) { QJsonObject _data; addParam(_data, QStringLiteral("auth"), auth); @@ -115,13 +111,13 @@ QUrl CheckUsernameAvailabilityJob::makeRequestUrl(QUrl baseUrl, const QString& username) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/register/available", + makePath("/_matrix/client/r0", + "/register/available"), queryToCheckUsernameAvailability(username)); } CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob(const QString& username) : BaseJob(HttpVerb::Get, QStringLiteral("CheckUsernameAvailabilityJob"), - QStringLiteral("/_matrix/client/r0") % "/register/available", + makePath("/_matrix/client/r0", "/register/available"), queryToCheckUsernameAvailability(username), {}, false) {} diff --git a/lib/csapi/report_content.cpp b/lib/csapi/report_content.cpp index ea906380..0a76d5b8 100644 --- a/lib/csapi/report_content.cpp +++ b/lib/csapi/report_content.cpp @@ -4,15 +4,13 @@ #include "report_content.h" -#include - using namespace Quotient; ReportContentJob::ReportContentJob(const QString& roomId, const QString& eventId, Omittable score, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("ReportContentJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/report/" % eventId) + makePath("/_matrix/client/r0", "/rooms/", roomId, "/report/", + eventId)) { QJsonObject _data; addParam(_data, QStringLiteral("score"), score); diff --git a/lib/csapi/room_send.cpp b/lib/csapi/room_send.cpp index 9fd8cb96..f80f9300 100644 --- a/lib/csapi/room_send.cpp +++ b/lib/csapi/room_send.cpp @@ -4,15 +4,13 @@ #include "room_send.h" -#include - using namespace Quotient; SendMessageJob::SendMessageJob(const QString& roomId, const QString& eventType, const QString& txnId, const QJsonObject& body) : BaseJob(HttpVerb::Put, QStringLiteral("SendMessageJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/send/" % eventType % "/" % txnId) + makePath("/_matrix/client/r0", "/rooms/", roomId, "/send/", + eventType, "/", txnId)) { setRequestData(RequestData(toJson(body))); addExpectedKey("event_id"); diff --git a/lib/csapi/room_state.cpp b/lib/csapi/room_state.cpp index 37e897fa..f6d2e6ec 100644 --- a/lib/csapi/room_state.cpp +++ b/lib/csapi/room_state.cpp @@ -4,8 +4,6 @@ #include "room_state.h" -#include - using namespace Quotient; SetRoomStateWithKeyJob::SetRoomStateWithKeyJob(const QString& roomId, @@ -13,8 +11,8 @@ SetRoomStateWithKeyJob::SetRoomStateWithKeyJob(const QString& roomId, const QString& stateKey, const QJsonObject& body) : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomStateWithKeyJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/state/" % eventType % "/" % stateKey) + makePath("/_matrix/client/r0", "/rooms/", roomId, "/state/", + eventType, "/", stateKey)) { setRequestData(RequestData(toJson(body))); addExpectedKey("event_id"); diff --git a/lib/csapi/room_upgrades.cpp b/lib/csapi/room_upgrades.cpp index e3791b08..d4129cfb 100644 --- a/lib/csapi/room_upgrades.cpp +++ b/lib/csapi/room_upgrades.cpp @@ -4,14 +4,11 @@ #include "room_upgrades.h" -#include - using namespace Quotient; UpgradeRoomJob::UpgradeRoomJob(const QString& roomId, const QString& newVersion) : BaseJob(HttpVerb::Post, QStringLiteral("UpgradeRoomJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/upgrade") + makePath("/_matrix/client/r0", "/rooms/", roomId, "/upgrade")) { QJsonObject _data; addParam<>(_data, QStringLiteral("new_version"), newVersion); diff --git a/lib/csapi/rooms.cpp b/lib/csapi/rooms.cpp index 3dd87021..5310aa32 100644 --- a/lib/csapi/rooms.cpp +++ b/lib/csapi/rooms.cpp @@ -4,24 +4,21 @@ #include "rooms.h" -#include - using namespace Quotient; QUrl GetOneRoomEventJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/rooms/" % roomId % "/event/" - % eventId); + makePath("/_matrix/client/r0", "/rooms/", + roomId, "/event/", eventId)); } GetOneRoomEventJob::GetOneRoomEventJob(const QString& roomId, const QString& eventId) : BaseJob(HttpVerb::Get, QStringLiteral("GetOneRoomEventJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/event/" % eventId) + makePath("/_matrix/client/r0", "/rooms/", roomId, "/event/", + eventId)) {} QUrl GetRoomStateWithKeyJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, @@ -29,30 +26,29 @@ QUrl GetRoomStateWithKeyJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& stateKey) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/rooms/" % roomId % "/state/" - % eventType % "/" % stateKey); + makePath("/_matrix/client/r0", "/rooms/", + roomId, "/state/", eventType, "/", + stateKey)); } GetRoomStateWithKeyJob::GetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, const QString& stateKey) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateWithKeyJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/state/" % eventType % "/" % stateKey) + makePath("/_matrix/client/r0", "/rooms/", roomId, "/state/", + eventType, "/", stateKey)) {} QUrl GetRoomStateJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/rooms/" % roomId % "/state"); + makePath("/_matrix/client/r0", "/rooms/", + roomId, "/state")); } GetRoomStateJob::GetRoomStateJob(const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/state") + makePath("/_matrix/client/r0", "/rooms/", roomId, "/state")) {} auto queryToGetMembersByRoom(const QString& at, const QString& membership, @@ -72,7 +68,7 @@ QUrl GetMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, { return BaseJob::makeRequestUrl( std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/members", + makePath("/_matrix/client/r0", "/rooms/", roomId, "/members"), queryToGetMembersByRoom(at, membership, notMembership)); } @@ -81,8 +77,7 @@ GetMembersByRoomJob::GetMembersByRoomJob(const QString& roomId, const QString& membership, const QString& notMembership) : BaseJob(HttpVerb::Get, QStringLiteral("GetMembersByRoomJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/members", + makePath("/_matrix/client/r0", "/rooms/", roomId, "/members"), queryToGetMembersByRoom(at, membership, notMembership)) {} @@ -90,12 +85,12 @@ QUrl GetJoinedMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/rooms/" % roomId % "/joined_members"); + makePath("/_matrix/client/r0", "/rooms/", + roomId, "/joined_members")); } GetJoinedMembersByRoomJob::GetJoinedMembersByRoomJob(const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetJoinedMembersByRoomJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/joined_members") + makePath("/_matrix/client/r0", "/rooms/", roomId, + "/joined_members")) {} diff --git a/lib/csapi/search.cpp b/lib/csapi/search.cpp index 05ad871e..295dd1cc 100644 --- a/lib/csapi/search.cpp +++ b/lib/csapi/search.cpp @@ -4,8 +4,6 @@ #include "search.h" -#include - using namespace Quotient; auto queryToSearch(const QString& nextBatch) @@ -18,7 +16,7 @@ auto queryToSearch(const QString& nextBatch) SearchJob::SearchJob(const Categories& searchCategories, const QString& nextBatch) : BaseJob(HttpVerb::Post, QStringLiteral("SearchJob"), - QStringLiteral("/_matrix/client/r0") % "/search", + makePath("/_matrix/client/r0", "/search"), queryToSearch(nextBatch)) { QJsonObject _data; diff --git a/lib/csapi/sso_login_redirect.cpp b/lib/csapi/sso_login_redirect.cpp index 92601b4d..871d6ff6 100644 --- a/lib/csapi/sso_login_redirect.cpp +++ b/lib/csapi/sso_login_redirect.cpp @@ -4,8 +4,6 @@ #include "sso_login_redirect.h" -#include - using namespace Quotient; auto queryToRedirectToSSO(const QString& redirectUrl) @@ -18,14 +16,14 @@ auto queryToRedirectToSSO(const QString& redirectUrl) QUrl RedirectToSSOJob::makeRequestUrl(QUrl baseUrl, const QString& redirectUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/login/sso/redirect", + makePath("/_matrix/client/r0", + "/login/sso/redirect"), queryToRedirectToSSO(redirectUrl)); } RedirectToSSOJob::RedirectToSSOJob(const QString& redirectUrl) : BaseJob(HttpVerb::Get, QStringLiteral("RedirectToSSOJob"), - QStringLiteral("/_matrix/client/r0") % "/login/sso/redirect", + makePath("/_matrix/client/r0", "/login/sso/redirect"), queryToRedirectToSSO(redirectUrl), {}, false) {} @@ -40,15 +38,14 @@ QUrl RedirectToIdPJob::makeRequestUrl(QUrl baseUrl, const QString& idpId, const QString& redirectUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/login/sso/redirect/" % idpId, + makePath("/_matrix/client/r0", + "/login/sso/redirect/", idpId), queryToRedirectToIdP(redirectUrl)); } RedirectToIdPJob::RedirectToIdPJob(const QString& idpId, const QString& redirectUrl) : BaseJob(HttpVerb::Get, QStringLiteral("RedirectToIdPJob"), - QStringLiteral("/_matrix/client/r0") % "/login/sso/redirect/" - % idpId, + makePath("/_matrix/client/r0", "/login/sso/redirect/", idpId), queryToRedirectToIdP(redirectUrl), {}, false) {} diff --git a/lib/csapi/tags.cpp b/lib/csapi/tags.cpp index dc22dc18..f717de6e 100644 --- a/lib/csapi/tags.cpp +++ b/lib/csapi/tags.cpp @@ -4,30 +4,28 @@ #include "tags.h" -#include - using namespace Quotient; QUrl GetRoomTagsJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") % "/user/" - % userId % "/rooms/" % roomId % "/tags"); + makePath("/_matrix/client/r0", "/user/", + userId, "/rooms/", roomId, "/tags")); } GetRoomTagsJob::GetRoomTagsJob(const QString& userId, const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomTagsJob"), - QStringLiteral("/_matrix/client/r0") % "/user/" % userId - % "/rooms/" % roomId % "/tags") + makePath("/_matrix/client/r0", "/user/", userId, "/rooms/", + roomId, "/tags")) {} SetRoomTagJob::SetRoomTagJob(const QString& userId, const QString& roomId, const QString& tag, Omittable order, const QVariantHash& additionalProperties) : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomTagJob"), - QStringLiteral("/_matrix/client/r0") % "/user/" % userId - % "/rooms/" % roomId % "/tags/" % tag) + makePath("/_matrix/client/r0", "/user/", userId, "/rooms/", + roomId, "/tags/", tag)) { QJsonObject _data; fillJson(_data, additionalProperties); @@ -39,14 +37,14 @@ QUrl DeleteRoomTagJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId, const QString& tag) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/user/" % userId % "/rooms/" % roomId - % "/tags/" % tag); + makePath("/_matrix/client/r0", "/user/", + userId, "/rooms/", roomId, "/tags/", + tag)); } DeleteRoomTagJob::DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag) : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteRoomTagJob"), - QStringLiteral("/_matrix/client/r0") % "/user/" % userId - % "/rooms/" % roomId % "/tags/" % tag) + makePath("/_matrix/client/r0", "/user/", userId, "/rooms/", + roomId, "/tags/", tag)) {} diff --git a/lib/csapi/third_party_lookup.cpp b/lib/csapi/third_party_lookup.cpp index 93687a76..4c930668 100644 --- a/lib/csapi/third_party_lookup.cpp +++ b/lib/csapi/third_party_lookup.cpp @@ -4,34 +4,31 @@ #include "third_party_lookup.h" -#include - using namespace Quotient; QUrl GetProtocolsJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/thirdparty/protocols"); + makePath("/_matrix/client/r0", + "/thirdparty/protocols")); } GetProtocolsJob::GetProtocolsJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetProtocolsJob"), - QStringLiteral("/_matrix/client/r0") % "/thirdparty/protocols") + makePath("/_matrix/client/r0", "/thirdparty/protocols")) {} QUrl GetProtocolMetadataJob::makeRequestUrl(QUrl baseUrl, const QString& protocol) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/thirdparty/protocol/" % protocol); + makePath("/_matrix/client/r0", + "/thirdparty/protocol/", protocol)); } GetProtocolMetadataJob::GetProtocolMetadataJob(const QString& protocol) : BaseJob(HttpVerb::Get, QStringLiteral("GetProtocolMetadataJob"), - QStringLiteral("/_matrix/client/r0") % "/thirdparty/protocol/" - % protocol) + makePath("/_matrix/client/r0", "/thirdparty/protocol/", protocol)) {} auto queryToQueryLocationByProtocol(const QString& searchFields) @@ -46,16 +43,15 @@ QUrl QueryLocationByProtocolJob::makeRequestUrl(QUrl baseUrl, const QString& searchFields) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/thirdparty/location/" % protocol, + makePath("/_matrix/client/r0", + "/thirdparty/location/", protocol), queryToQueryLocationByProtocol(searchFields)); } QueryLocationByProtocolJob::QueryLocationByProtocolJob( const QString& protocol, const QString& searchFields) : BaseJob(HttpVerb::Get, QStringLiteral("QueryLocationByProtocolJob"), - QStringLiteral("/_matrix/client/r0") % "/thirdparty/location/" - % protocol, + makePath("/_matrix/client/r0", "/thirdparty/location/", protocol), queryToQueryLocationByProtocol(searchFields)) {} @@ -71,16 +67,15 @@ QUrl QueryUserByProtocolJob::makeRequestUrl(QUrl baseUrl, const QString& fields) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/thirdparty/user/" % protocol, + makePath("/_matrix/client/r0", + "/thirdparty/user/", protocol), queryToQueryUserByProtocol(fields)); } QueryUserByProtocolJob::QueryUserByProtocolJob(const QString& protocol, const QString& fields) : BaseJob(HttpVerb::Get, QStringLiteral("QueryUserByProtocolJob"), - QStringLiteral("/_matrix/client/r0") % "/thirdparty/user/" - % protocol, + makePath("/_matrix/client/r0", "/thirdparty/user/", protocol), queryToQueryUserByProtocol(fields)) {} @@ -94,14 +89,14 @@ auto queryToQueryLocationByAlias(const QString& alias) QUrl QueryLocationByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& alias) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/thirdparty/location", + makePath("/_matrix/client/r0", + "/thirdparty/location"), queryToQueryLocationByAlias(alias)); } QueryLocationByAliasJob::QueryLocationByAliasJob(const QString& alias) : BaseJob(HttpVerb::Get, QStringLiteral("QueryLocationByAliasJob"), - QStringLiteral("/_matrix/client/r0") % "/thirdparty/location", + makePath("/_matrix/client/r0", "/thirdparty/location"), queryToQueryLocationByAlias(alias)) {} @@ -115,13 +110,13 @@ auto queryToQueryUserByID(const QString& userid) QUrl QueryUserByIDJob::makeRequestUrl(QUrl baseUrl, const QString& userid) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/thirdparty/user", + makePath("/_matrix/client/r0", + "/thirdparty/user"), queryToQueryUserByID(userid)); } QueryUserByIDJob::QueryUserByIDJob(const QString& userid) : BaseJob(HttpVerb::Get, QStringLiteral("QueryUserByIDJob"), - QStringLiteral("/_matrix/client/r0") % "/thirdparty/user", + makePath("/_matrix/client/r0", "/thirdparty/user"), queryToQueryUserByID(userid)) {} diff --git a/lib/csapi/third_party_membership.cpp b/lib/csapi/third_party_membership.cpp index fda772d2..59275e41 100644 --- a/lib/csapi/third_party_membership.cpp +++ b/lib/csapi/third_party_membership.cpp @@ -4,16 +4,13 @@ #include "third_party_membership.h" -#include - using namespace Quotient; InviteBy3PIDJob::InviteBy3PIDJob(const QString& roomId, const QString& idServer, const QString& idAccessToken, const QString& medium, const QString& address) : BaseJob(HttpVerb::Post, QStringLiteral("InviteBy3PIDJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/invite") + makePath("/_matrix/client/r0", "/rooms/", roomId, "/invite")) { QJsonObject _data; addParam<>(_data, QStringLiteral("id_server"), idServer); diff --git a/lib/csapi/to_device.cpp b/lib/csapi/to_device.cpp index 3775174d..628e8314 100644 --- a/lib/csapi/to_device.cpp +++ b/lib/csapi/to_device.cpp @@ -4,16 +4,14 @@ #include "to_device.h" -#include - using namespace Quotient; SendToDeviceJob::SendToDeviceJob( const QString& eventType, const QString& txnId, const QHash>& messages) : BaseJob(HttpVerb::Put, QStringLiteral("SendToDeviceJob"), - QStringLiteral("/_matrix/client/r0") % "/sendToDevice/" - % eventType % "/" % txnId) + makePath("/_matrix/client/r0", "/sendToDevice/", eventType, "/", + txnId)) { QJsonObject _data; addParam<>(_data, QStringLiteral("messages"), messages); diff --git a/lib/csapi/typing.cpp b/lib/csapi/typing.cpp index 8e214053..c9673118 100644 --- a/lib/csapi/typing.cpp +++ b/lib/csapi/typing.cpp @@ -4,15 +4,13 @@ #include "typing.h" -#include - using namespace Quotient; SetTypingJob::SetTypingJob(const QString& userId, const QString& roomId, bool typing, Omittable timeout) : BaseJob(HttpVerb::Put, QStringLiteral("SetTypingJob"), - QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId - % "/typing/" % userId) + makePath("/_matrix/client/r0", "/rooms/", roomId, "/typing/", + userId)) { QJsonObject _data; addParam<>(_data, QStringLiteral("typing"), typing); diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index a0279d7e..48b727f0 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -4,14 +4,12 @@ #include "users.h" -#include - using namespace Quotient; SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, Omittable limit) : BaseJob(HttpVerb::Post, QStringLiteral("SearchUserDirectoryJob"), - QStringLiteral("/_matrix/client/r0") % "/user_directory/search") + makePath("/_matrix/client/r0", "/user_directory/search")) { QJsonObject _data; addParam<>(_data, QStringLiteral("search_term"), searchTerm); diff --git a/lib/csapi/versions.cpp b/lib/csapi/versions.cpp index 9003e27f..a1efc33e 100644 --- a/lib/csapi/versions.cpp +++ b/lib/csapi/versions.cpp @@ -4,20 +4,17 @@ #include "versions.h" -#include - using namespace Quotient; QUrl GetVersionsJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client") - % "/versions"); + makePath("/_matrix/client", "/versions")); } GetVersionsJob::GetVersionsJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetVersionsJob"), - QStringLiteral("/_matrix/client") % "/versions", false) + makePath("/_matrix/client", "/versions"), false) { addExpectedKey("versions"); } diff --git a/lib/csapi/voip.cpp b/lib/csapi/voip.cpp index 43170057..c748ad94 100644 --- a/lib/csapi/voip.cpp +++ b/lib/csapi/voip.cpp @@ -4,18 +4,15 @@ #include "voip.h" -#include - using namespace Quotient; QUrl GetTurnServerJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/voip/turnServer"); + return BaseJob::makeRequestUrl( + std::move(baseUrl), makePath("/_matrix/client/r0", "/voip/turnServer")); } GetTurnServerJob::GetTurnServerJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetTurnServerJob"), - QStringLiteral("/_matrix/client/r0") % "/voip/turnServer") + makePath("/_matrix/client/r0", "/voip/turnServer")) {} diff --git a/lib/csapi/wellknown.cpp b/lib/csapi/wellknown.cpp index 1aa0a90b..0b441279 100644 --- a/lib/csapi/wellknown.cpp +++ b/lib/csapi/wellknown.cpp @@ -4,18 +4,15 @@ #include "wellknown.h" -#include - using namespace Quotient; QUrl GetWellknownJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/.well-known") - % "/matrix/client"); + makePath("/.well-known", "/matrix/client")); } GetWellknownJob::GetWellknownJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetWellknownJob"), - QStringLiteral("/.well-known") % "/matrix/client", false) + makePath("/.well-known", "/matrix/client"), false) {} diff --git a/lib/csapi/whoami.cpp b/lib/csapi/whoami.cpp index 73f0298e..ed8a9817 100644 --- a/lib/csapi/whoami.cpp +++ b/lib/csapi/whoami.cpp @@ -4,20 +4,17 @@ #include "whoami.h" -#include - using namespace Quotient; QUrl GetTokenOwnerJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/account/whoami"); + return BaseJob::makeRequestUrl( + std::move(baseUrl), makePath("/_matrix/client/r0", "/account/whoami")); } GetTokenOwnerJob::GetTokenOwnerJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetTokenOwnerJob"), - QStringLiteral("/_matrix/client/r0") % "/account/whoami") + makePath("/_matrix/client/r0", "/account/whoami")) { addExpectedKey("user_id"); } -- cgit v1.2.3 From 952f8aa8ad19348b50a3b3545d98f7889bfdae76 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Wed, 29 Dec 2021 15:57:33 +0100 Subject: Regenerate CS API files --- lib/csapi/account-data.h | 8 ++++---- lib/csapi/admin.h | 2 +- lib/csapi/administrative_contact.h | 16 ++++++++-------- lib/csapi/appservice_room_directory.h | 3 ++- lib/csapi/banning.h | 4 ++-- lib/csapi/capabilities.h | 2 +- lib/csapi/content-repo.h | 12 ++++++------ lib/csapi/create_room.h | 2 +- lib/csapi/cross_signing.h | 4 ++-- lib/csapi/device_management.h | 10 +++++----- lib/csapi/directory.h | 8 ++++---- lib/csapi/event_context.h | 2 +- lib/csapi/filter.h | 4 ++-- lib/csapi/inviting.h | 2 +- lib/csapi/joining.h | 4 ++-- lib/csapi/keys.h | 8 ++++---- lib/csapi/kicking.h | 2 +- lib/csapi/knocking.h | 2 +- lib/csapi/leaving.h | 4 ++-- lib/csapi/list_joined_rooms.h | 2 +- lib/csapi/list_public_rooms.h | 8 ++++---- lib/csapi/login.h | 4 ++-- lib/csapi/logout.h | 4 ++-- lib/csapi/message_pagination.h | 2 +- lib/csapi/notifications.h | 2 +- lib/csapi/openid.h | 2 +- lib/csapi/peeking_events.h | 2 +- lib/csapi/presence.h | 4 ++-- lib/csapi/profile.h | 10 +++++----- lib/csapi/pusher.h | 4 ++-- lib/csapi/pushrules.h | 16 ++++++++-------- lib/csapi/read_markers.h | 2 +- lib/csapi/receipts.h | 2 +- lib/csapi/redaction.h | 2 +- lib/csapi/registration.h | 16 ++++++++-------- lib/csapi/report_content.h | 2 +- lib/csapi/room_send.h | 2 +- lib/csapi/room_state.h | 2 +- lib/csapi/room_upgrades.h | 2 +- lib/csapi/rooms.h | 10 +++++----- lib/csapi/search.h | 2 +- lib/csapi/sso_login_redirect.h | 4 ++-- lib/csapi/tags.h | 6 +++--- lib/csapi/third_party_lookup.h | 12 ++++++------ lib/csapi/third_party_membership.h | 2 +- lib/csapi/to_device.h | 2 +- lib/csapi/typing.h | 2 +- lib/csapi/users.h | 2 +- lib/csapi/versions.h | 2 +- lib/csapi/voip.h | 2 +- lib/csapi/wellknown.h | 2 +- lib/csapi/whoami.h | 2 +- 52 files changed, 120 insertions(+), 119 deletions(-) (limited to 'lib/csapi') diff --git a/lib/csapi/account-data.h b/lib/csapi/account-data.h index 0c760e80..5140d340 100644 --- a/lib/csapi/account-data.h +++ b/lib/csapi/account-data.h @@ -14,7 +14,7 @@ namespace Quotient { * that set the account_data. The config will be synced to clients in the * top-level `account_data`. */ -class SetAccountDataJob : public BaseJob { +class QUOTIENT_API SetAccountDataJob : public BaseJob { public: /*! \brief Set some account_data for the user. * @@ -38,7 +38,7 @@ public: * Get some account_data for the client. This config is only visible to the user * that set the account_data. */ -class GetAccountDataJob : public BaseJob { +class QUOTIENT_API GetAccountDataJob : public BaseJob { public: /*! \brief Get some account_data for the user. * @@ -67,7 +67,7 @@ public: * visible to the user that set the account_data. The config will be synced to * clients in the per-room `account_data`. */ -class SetAccountDataPerRoomJob : public BaseJob { +class QUOTIENT_API SetAccountDataPerRoomJob : public BaseJob { public: /*! \brief Set some account_data for the user. * @@ -95,7 +95,7 @@ public: * Get some account_data for the client on a given room. This config is only * visible to the user that set the account_data. */ -class GetAccountDataPerRoomJob : public BaseJob { +class QUOTIENT_API GetAccountDataPerRoomJob : public BaseJob { public: /*! \brief Get some account_data for the user. * diff --git a/lib/csapi/admin.h b/lib/csapi/admin.h index 570bf24a..c53ddd7e 100644 --- a/lib/csapi/admin.h +++ b/lib/csapi/admin.h @@ -16,7 +16,7 @@ namespace Quotient { * up, or by a server admin. Server-local administrator privileges are not * specified in this document. */ -class GetWhoIsJob : public BaseJob { +class QUOTIENT_API GetWhoIsJob : public BaseJob { public: // Inner data structures diff --git a/lib/csapi/administrative_contact.h b/lib/csapi/administrative_contact.h index e436971d..e636b12a 100644 --- a/lib/csapi/administrative_contact.h +++ b/lib/csapi/administrative_contact.h @@ -24,7 +24,7 @@ namespace Quotient { * Identifiers in this list may be used by the homeserver as, for example, * identifiers that it will accept to reset the user's account password. */ -class GetAccount3PIDsJob : public BaseJob { +class QUOTIENT_API GetAccount3PIDsJob : public BaseJob { public: // Inner data structures @@ -102,7 +102,7 @@ struct JsonObjectConverter { * This results in this endpoint being an equivalent to `/3pid/bind` rather * than dual-purpose. */ -class Post3PIDsJob : public BaseJob { +class QUOTIENT_API Post3PIDsJob : public BaseJob { public: // Inner data structures @@ -154,7 +154,7 @@ struct JsonObjectConverter { * Homeservers should prevent the caller from adding a 3PID to their account if * it has already been added to another user's account on the homeserver. */ -class Add3PIDJob : public BaseJob { +class QUOTIENT_API Add3PIDJob : public BaseJob { public: /*! \brief Adds contact information to the user's account. * @@ -182,7 +182,7 @@ public: * * Homeservers should track successful binds so they can be unbound later. */ -class Bind3PIDJob : public BaseJob { +class QUOTIENT_API Bind3PIDJob : public BaseJob { public: /*! \brief Binds a 3PID to the user's account through an Identity Service. * @@ -211,7 +211,7 @@ public: * parameter because the homeserver is expected to sign the request to the * identity server instead. */ -class Delete3pidFromAccountJob : public BaseJob { +class QUOTIENT_API Delete3pidFromAccountJob : public BaseJob { public: /*! \brief Deletes a third party identifier from the user's account * @@ -254,7 +254,7 @@ public: * parameter because the homeserver is expected to sign the request to the * identity server instead. */ -class Unbind3pidFromAccountJob : public BaseJob { +class QUOTIENT_API Unbind3pidFromAccountJob : public BaseJob { public: /*! \brief Removes a user's third party identifier from an identity server. * @@ -300,7 +300,7 @@ public: * the email itself, either by sending a validation email itself or by using * a service it has control over. */ -class RequestTokenTo3PIDEmailJob : public BaseJob { +class QUOTIENT_API RequestTokenTo3PIDEmailJob : public BaseJob { public: /*! \brief Begins the validation process for an email address for * association with the user's account. @@ -342,7 +342,7 @@ public: * the phone number itself, either by sending a validation message itself or by * using a service it has control over. */ -class RequestTokenTo3PIDMSISDNJob : public BaseJob { +class QUOTIENT_API RequestTokenTo3PIDMSISDNJob : public BaseJob { public: /*! \brief Begins the validation process for a phone number for association * with the user's account. diff --git a/lib/csapi/appservice_room_directory.h b/lib/csapi/appservice_room_directory.h index 56a69592..6b2801ca 100644 --- a/lib/csapi/appservice_room_directory.h +++ b/lib/csapi/appservice_room_directory.h @@ -21,7 +21,8 @@ namespace Quotient { * instead of a typical client's access_token. This API cannot be invoked by * users who are not identified as application services. */ -class UpdateAppserviceRoomDirectoryVisibilityJob : public BaseJob { +class QUOTIENT_API UpdateAppserviceRoomDirectoryVisibilityJob + : public BaseJob { public: /*! \brief Updates a room's visibility in the application service's room * directory. diff --git a/lib/csapi/banning.h b/lib/csapi/banning.h index 7a9697d3..e4c60ce3 100644 --- a/lib/csapi/banning.h +++ b/lib/csapi/banning.h @@ -18,7 +18,7 @@ namespace Quotient { * The caller must have the required power level in order to perform this * operation. */ -class BanJob : public BaseJob { +class QUOTIENT_API BanJob : public BaseJob { public: /*! \brief Ban a user in the room. * @@ -46,7 +46,7 @@ public: * The caller must have the required power level in order to perform this * operation. */ -class UnbanJob : public BaseJob { +class QUOTIENT_API UnbanJob : public BaseJob { public: /*! \brief Unban a user from the room. * diff --git a/lib/csapi/capabilities.h b/lib/csapi/capabilities.h index da50c8c1..81b47cd4 100644 --- a/lib/csapi/capabilities.h +++ b/lib/csapi/capabilities.h @@ -13,7 +13,7 @@ namespace Quotient { * Gets information about the server's supported feature set * and other relevant capabilities. */ -class GetCapabilitiesJob : public BaseJob { +class QUOTIENT_API GetCapabilitiesJob : public BaseJob { public: // Inner data structures diff --git a/lib/csapi/content-repo.h b/lib/csapi/content-repo.h index 28409f5c..511db985 100644 --- a/lib/csapi/content-repo.h +++ b/lib/csapi/content-repo.h @@ -14,7 +14,7 @@ namespace Quotient { /*! \brief Upload some content to the content repository. * */ -class UploadContentJob : public BaseJob { +class QUOTIENT_API UploadContentJob : public BaseJob { public: /*! \brief Upload some content to the content repository. * @@ -40,7 +40,7 @@ public: /*! \brief Download content from the content repository. * */ -class GetContentJob : public BaseJob { +class QUOTIENT_API GetContentJob : public BaseJob { public: /*! \brief Download content from the content repository. * @@ -87,7 +87,7 @@ public: * the previous endpoint) but replace the target file name with the one * provided by the caller. */ -class GetContentOverrideNameJob : public BaseJob { +class QUOTIENT_API GetContentOverrideNameJob : public BaseJob { public: /*! \brief Download content from the content repository overriding the file * name @@ -142,7 +142,7 @@ public: * See the [Thumbnails](/client-server-api/#thumbnails) section for more * information. */ -class GetContentThumbnailJob : public BaseJob { +class QUOTIENT_API GetContentThumbnailJob : public BaseJob { public: /*! \brief Download a thumbnail of content from the content repository * @@ -204,7 +204,7 @@ public: * do not want to share with the homeserver, and this can mean that the URLs * being shared should also not be shared with the homeserver. */ -class GetUrlPreviewJob : public BaseJob { +class QUOTIENT_API GetUrlPreviewJob : public BaseJob { public: /*! \brief Get information about a URL for a client * @@ -252,7 +252,7 @@ public: * content repository APIs, for example, proxies may enforce a lower upload size * limit than is advertised by the server on this endpoint. */ -class GetConfigJob : public BaseJob { +class QUOTIENT_API GetConfigJob : public BaseJob { public: /// Get the configuration for the content repository. explicit GetConfigJob(); diff --git a/lib/csapi/create_room.h b/lib/csapi/create_room.h index 81dfbffc..7d566057 100644 --- a/lib/csapi/create_room.h +++ b/lib/csapi/create_room.h @@ -53,7 +53,7 @@ namespace Quotient { * requesting user as the creator, alongside other keys provided in the * `creation_content`. */ -class CreateRoomJob : public BaseJob { +class QUOTIENT_API CreateRoomJob : public BaseJob { public: // Inner data structures diff --git a/lib/csapi/cross_signing.h b/lib/csapi/cross_signing.h index 2ab65e06..617b61d1 100644 --- a/lib/csapi/cross_signing.h +++ b/lib/csapi/cross_signing.h @@ -17,7 +17,7 @@ namespace Quotient { * This API endpoint uses the [User-Interactive Authentication * API](/client-server-api/#user-interactive-authentication-api). */ -class UploadCrossSigningKeysJob : public BaseJob { +class QUOTIENT_API UploadCrossSigningKeysJob : public BaseJob { public: /*! \brief Upload cross-signing keys. * @@ -47,7 +47,7 @@ public: * Publishes cross-signing signatures for the user. The request body is a * map from user ID to key ID to signed JSON object. */ -class UploadCrossSigningSignaturesJob : public BaseJob { +class QUOTIENT_API UploadCrossSigningSignaturesJob : public BaseJob { public: /*! \brief Upload cross-signing signatures. * diff --git a/lib/csapi/device_management.h b/lib/csapi/device_management.h index 7fb69873..430d2132 100644 --- a/lib/csapi/device_management.h +++ b/lib/csapi/device_management.h @@ -15,7 +15,7 @@ namespace Quotient { * * Gets information about all devices for the current user. */ -class GetDevicesJob : public BaseJob { +class QUOTIENT_API GetDevicesJob : public BaseJob { public: /// List registered devices for the current user explicit GetDevicesJob(); @@ -40,7 +40,7 @@ public: * * Gets information on a single device, by device id. */ -class GetDeviceJob : public BaseJob { +class QUOTIENT_API GetDeviceJob : public BaseJob { public: /*! \brief Get a single device * @@ -66,7 +66,7 @@ public: * * Updates the metadata on the given device. */ -class UpdateDeviceJob : public BaseJob { +class QUOTIENT_API UpdateDeviceJob : public BaseJob { public: /*! \brief Update a device * @@ -88,7 +88,7 @@ public: * * Deletes the given device, and invalidates any access token associated with it. */ -class DeleteDeviceJob : public BaseJob { +class QUOTIENT_API DeleteDeviceJob : public BaseJob { public: /*! \brief Delete a device * @@ -111,7 +111,7 @@ public: * Deletes the given devices, and invalidates any access token associated with * them. */ -class DeleteDevicesJob : public BaseJob { +class QUOTIENT_API DeleteDevicesJob : public BaseJob { public: /*! \brief Bulk deletion of devices * diff --git a/lib/csapi/directory.h b/lib/csapi/directory.h index 93a31595..0bd13a76 100644 --- a/lib/csapi/directory.h +++ b/lib/csapi/directory.h @@ -11,7 +11,7 @@ namespace Quotient { /*! \brief Create a new mapping from room alias to room ID. * */ -class SetRoomAliasJob : public BaseJob { +class QUOTIENT_API SetRoomAliasJob : public BaseJob { public: /*! \brief Create a new mapping from room alias to room ID. * @@ -32,7 +32,7 @@ public: * domain part of the alias does not correspond to the server's own * domain. */ -class GetRoomIdByAliasJob : public BaseJob { +class QUOTIENT_API GetRoomIdByAliasJob : public BaseJob { public: /*! \brief Get the room ID corresponding to this room alias. * @@ -76,7 +76,7 @@ public: * return a successful response even if the user does not have permission to * update the `m.room.canonical_alias` event. */ -class DeleteRoomAliasJob : public BaseJob { +class QUOTIENT_API DeleteRoomAliasJob : public BaseJob { public: /*! \brief Remove a mapping of room alias to room ID. * @@ -112,7 +112,7 @@ public: * as they are not curated, unlike those listed in the `m.room.canonical_alias` * state event. */ -class GetLocalAliasesJob : public BaseJob { +class QUOTIENT_API GetLocalAliasesJob : public BaseJob { public: /*! \brief Get a list of local aliases on a given room. * diff --git a/lib/csapi/event_context.h b/lib/csapi/event_context.h index 4e50edf3..662b976b 100644 --- a/lib/csapi/event_context.h +++ b/lib/csapi/event_context.h @@ -19,7 +19,7 @@ namespace Quotient { * [Lazy-loading room members](/client-server-api/#lazy-loading-room-members) * for more information. */ -class GetEventContextJob : public BaseJob { +class QUOTIENT_API GetEventContextJob : public BaseJob { public: /*! \brief Get events and state around the specified event. * diff --git a/lib/csapi/filter.h b/lib/csapi/filter.h index 01bec36b..9518a461 100644 --- a/lib/csapi/filter.h +++ b/lib/csapi/filter.h @@ -16,7 +16,7 @@ namespace Quotient { * Returns a filter ID that may be used in future requests to * restrict which events are returned to the client. */ -class DefineFilterJob : public BaseJob { +class QUOTIENT_API DefineFilterJob : public BaseJob { public: /*! \brief Upload a new filter. * @@ -41,7 +41,7 @@ public: /*! \brief Download a filter * */ -class GetFilterJob : public BaseJob { +class QUOTIENT_API GetFilterJob : public BaseJob { public: /*! \brief Download a filter * diff --git a/lib/csapi/inviting.h b/lib/csapi/inviting.h index eb13cc95..21e6cb74 100644 --- a/lib/csapi/inviting.h +++ b/lib/csapi/inviting.h @@ -26,7 +26,7 @@ namespace Quotient { * If the user was invited to the room, the homeserver will append a * `m.room.member` event to the room. */ -class InviteUserJob : public BaseJob { +class QUOTIENT_API InviteUserJob : public BaseJob { public: /*! \brief Invite a user to participate in a particular room. * diff --git a/lib/csapi/joining.h b/lib/csapi/joining.h index d0199b11..f64152f7 100644 --- a/lib/csapi/joining.h +++ b/lib/csapi/joining.h @@ -25,7 +25,7 @@ namespace Quotient { * [`/initialSync`](/client-server-api/#get_matrixclientr0initialsync) and * [`/sync`](/client-server-api/#get_matrixclientr0sync) APIs. */ -class JoinRoomByIdJob : public BaseJob { +class QUOTIENT_API JoinRoomByIdJob : public BaseJob { public: /*! \brief Start the requesting user participating in a particular room. * @@ -67,7 +67,7 @@ public: * [`/initialSync`](/client-server-api/#get_matrixclientr0initialsync) and * [`/sync`](/client-server-api/#get_matrixclientr0sync) APIs. */ -class JoinRoomJob : public BaseJob { +class QUOTIENT_API JoinRoomJob : public BaseJob { public: /*! \brief Start the requesting user participating in a particular room. * diff --git a/lib/csapi/keys.h b/lib/csapi/keys.h index 7db09e8d..ce1ca9ed 100644 --- a/lib/csapi/keys.h +++ b/lib/csapi/keys.h @@ -15,7 +15,7 @@ namespace Quotient { * * Publishes end-to-end encryption keys for the device. */ -class UploadKeysJob : public BaseJob { +class QUOTIENT_API UploadKeysJob : public BaseJob { public: /*! \brief Upload end-to-end encryption keys. * @@ -48,7 +48,7 @@ public: * * Returns the current devices and identity keys for the given users. */ -class QueryKeysJob : public BaseJob { +class QUOTIENT_API QueryKeysJob : public BaseJob { public: // Inner data structures @@ -172,7 +172,7 @@ struct JsonObjectConverter { * * Claims one-time keys for use in pre-key messages. */ -class ClaimKeysJob : public BaseJob { +class QUOTIENT_API ClaimKeysJob : public BaseJob { public: /*! \brief Claim one-time encryption keys. * @@ -226,7 +226,7 @@ public: * * added new device identity keys or removed an existing device with * identity keys, between `from` and `to`. */ -class GetKeysChangesJob : public BaseJob { +class QUOTIENT_API GetKeysChangesJob : public BaseJob { public: /*! \brief Query users with recent device key updates. * diff --git a/lib/csapi/kicking.h b/lib/csapi/kicking.h index 11018368..6ac106e2 100644 --- a/lib/csapi/kicking.h +++ b/lib/csapi/kicking.h @@ -20,7 +20,7 @@ namespace Quotient { * directly adjust the target member's state by making a request to * `/rooms//state/m.room.member/`. */ -class KickJob : public BaseJob { +class QUOTIENT_API KickJob : public BaseJob { public: /*! \brief Kick a user from the room. * diff --git a/lib/csapi/knocking.h b/lib/csapi/knocking.h index 1108cb64..e3645b59 100644 --- a/lib/csapi/knocking.h +++ b/lib/csapi/knocking.h @@ -27,7 +27,7 @@ namespace Quotient { * The knock will appear as an entry in the response of the * [`/sync`](/client-server-api/#get_matrixclientr0sync) API. */ -class KnockRoomJob : public BaseJob { +class QUOTIENT_API KnockRoomJob : public BaseJob { public: /*! \brief Knock on a room, requesting permission to join. * diff --git a/lib/csapi/leaving.h b/lib/csapi/leaving.h index 2e402d16..19cac3f0 100644 --- a/lib/csapi/leaving.h +++ b/lib/csapi/leaving.h @@ -22,7 +22,7 @@ namespace Quotient { * The user will still be allowed to retrieve history from the room which * they were previously allowed to see. */ -class LeaveRoomJob : public BaseJob { +class QUOTIENT_API LeaveRoomJob : public BaseJob { public: /*! \brief Stop the requesting user participating in a particular room. * @@ -48,7 +48,7 @@ public: * If the user is currently joined to the room, they must leave the room * before calling this API. */ -class ForgetRoomJob : public BaseJob { +class QUOTIENT_API ForgetRoomJob : public BaseJob { public: /*! \brief Stop the requesting user remembering about a particular room. * diff --git a/lib/csapi/list_joined_rooms.h b/lib/csapi/list_joined_rooms.h index 59a24a49..aea68afd 100644 --- a/lib/csapi/list_joined_rooms.h +++ b/lib/csapi/list_joined_rooms.h @@ -12,7 +12,7 @@ namespace Quotient { * * This API returns a list of the user's current rooms. */ -class GetJoinedRoomsJob : public BaseJob { +class QUOTIENT_API GetJoinedRoomsJob : public BaseJob { public: /// Lists the user's current rooms. explicit GetJoinedRoomsJob(); diff --git a/lib/csapi/list_public_rooms.h b/lib/csapi/list_public_rooms.h index 963c8b56..e1f03db7 100644 --- a/lib/csapi/list_public_rooms.h +++ b/lib/csapi/list_public_rooms.h @@ -14,7 +14,7 @@ namespace Quotient { * * Gets the visibility of a given room on the server's public room directory. */ -class GetRoomVisibilityOnDirectoryJob : public BaseJob { +class QUOTIENT_API GetRoomVisibilityOnDirectoryJob : public BaseJob { public: /*! \brief Gets the visibility of a room in the directory * @@ -48,7 +48,7 @@ public: * here, for instance that room visibility can only be changed by * the room creator or a server administrator. */ -class SetRoomVisibilityOnDirectoryJob : public BaseJob { +class QUOTIENT_API SetRoomVisibilityOnDirectoryJob : public BaseJob { public: /*! \brief Sets the visibility of a room in the room directory * @@ -70,7 +70,7 @@ public: * This API returns paginated responses. The rooms are ordered by the number * of joined members, with the largest rooms first. */ -class GetPublicRoomsJob : public BaseJob { +class QUOTIENT_API GetPublicRoomsJob : public BaseJob { public: /*! \brief Lists the public rooms on the server. * @@ -133,7 +133,7 @@ public: * This API returns paginated responses. The rooms are ordered by the number * of joined members, with the largest rooms first. */ -class QueryPublicRoomsJob : public BaseJob { +class QUOTIENT_API QueryPublicRoomsJob : public BaseJob { public: // Inner data structures diff --git a/lib/csapi/login.h b/lib/csapi/login.h index b35db1eb..ce6951eb 100644 --- a/lib/csapi/login.h +++ b/lib/csapi/login.h @@ -16,7 +16,7 @@ namespace Quotient { * Gets the homeserver's supported login types to authenticate users. Clients * should pick one of these and supply it as the `type` when logging in. */ -class GetLoginFlowsJob : public BaseJob { +class QUOTIENT_API GetLoginFlowsJob : public BaseJob { public: // Inner data structures @@ -73,7 +73,7 @@ struct JsonObjectConverter { * [Relationship between access tokens and * devices](/client-server-api/#relationship-between-access-tokens-and-devices). */ -class LoginJob : public BaseJob { +class QUOTIENT_API LoginJob : public BaseJob { public: /*! \brief Authenticates the user. * diff --git a/lib/csapi/logout.h b/lib/csapi/logout.h index 2e4c2692..3f1ac7fa 100644 --- a/lib/csapi/logout.h +++ b/lib/csapi/logout.h @@ -15,7 +15,7 @@ namespace Quotient { * [Device keys](/client-server-api/#device-keys) for the device are deleted * alongside the device. */ -class LogoutJob : public BaseJob { +class QUOTIENT_API LogoutJob : public BaseJob { public: /// Invalidates a user access token explicit LogoutJob(); @@ -44,7 +44,7 @@ public: * used in the request, and therefore the attacker is unable to take over the * account in this way. */ -class LogoutAllJob : public BaseJob { +class QUOTIENT_API LogoutAllJob : public BaseJob { public: /// Invalidates all access tokens for a user explicit LogoutAllJob(); diff --git a/lib/csapi/message_pagination.h b/lib/csapi/message_pagination.h index 363e4d99..8c18f104 100644 --- a/lib/csapi/message_pagination.h +++ b/lib/csapi/message_pagination.h @@ -18,7 +18,7 @@ namespace Quotient { * [Lazy-loading room members](/client-server-api/#lazy-loading-room-members) * for more information. */ -class GetRoomEventsJob : public BaseJob { +class QUOTIENT_API GetRoomEventsJob : public BaseJob { public: /*! \brief Get a list of events for this room * diff --git a/lib/csapi/notifications.h b/lib/csapi/notifications.h index 0c38fe6b..23211758 100644 --- a/lib/csapi/notifications.h +++ b/lib/csapi/notifications.h @@ -14,7 +14,7 @@ namespace Quotient { * This API is used to paginate through the list of events that the * user has been, or would have been notified about. */ -class GetNotificationsJob : public BaseJob { +class QUOTIENT_API GetNotificationsJob : public BaseJob { public: // Inner data structures diff --git a/lib/csapi/openid.h b/lib/csapi/openid.h index 0be39c8c..773b6011 100644 --- a/lib/csapi/openid.h +++ b/lib/csapi/openid.h @@ -21,7 +21,7 @@ namespace Quotient { * be used to request another OpenID access token or call `/sync`, for * example. */ -class RequestOpenIdTokenJob : public BaseJob { +class QUOTIENT_API RequestOpenIdTokenJob : public BaseJob { public: /*! \brief Get an OpenID token object to verify the requester's identity. * diff --git a/lib/csapi/peeking_events.h b/lib/csapi/peeking_events.h index 885ff340..14cb6f0b 100644 --- a/lib/csapi/peeking_events.h +++ b/lib/csapi/peeking_events.h @@ -22,7 +22,7 @@ namespace Quotient { * API will also be deprecated at some point, but its replacement is not * yet known. */ -class PeekEventsJob : public BaseJob { +class QUOTIENT_API PeekEventsJob : public BaseJob { public: /*! \brief Listen on the event stream. * diff --git a/lib/csapi/presence.h b/lib/csapi/presence.h index 4ab50e25..52445205 100644 --- a/lib/csapi/presence.h +++ b/lib/csapi/presence.h @@ -15,7 +15,7 @@ namespace Quotient { * not need to specify the `last_active_ago` field. You cannot set the * presence state of another user. */ -class SetPresenceJob : public BaseJob { +class QUOTIENT_API SetPresenceJob : public BaseJob { public: /*! \brief Update this user's presence state. * @@ -36,7 +36,7 @@ public: * * Get the given user's presence state. */ -class GetPresenceJob : public BaseJob { +class QUOTIENT_API GetPresenceJob : public BaseJob { public: /*! \brief Get this user's presence state. * diff --git a/lib/csapi/profile.h b/lib/csapi/profile.h index 7f9c9e95..b00c944b 100644 --- a/lib/csapi/profile.h +++ b/lib/csapi/profile.h @@ -13,7 +13,7 @@ namespace Quotient { * This API sets the given user's display name. You must have permission to * set this user's display name, e.g. you need to have their `access_token`. */ -class SetDisplayNameJob : public BaseJob { +class QUOTIENT_API SetDisplayNameJob : public BaseJob { public: /*! \brief Set the user's display name. * @@ -33,7 +33,7 @@ public: * own displayname or to query the name of other users; either locally or * on remote homeservers. */ -class GetDisplayNameJob : public BaseJob { +class QUOTIENT_API GetDisplayNameJob : public BaseJob { public: /*! \brief Get the user's display name. * @@ -63,7 +63,7 @@ public: * This API sets the given user's avatar URL. You must have permission to * set this user's avatar URL, e.g. you need to have their `access_token`. */ -class SetAvatarUrlJob : public BaseJob { +class QUOTIENT_API SetAvatarUrlJob : public BaseJob { public: /*! \brief Set the user's avatar URL. * @@ -82,7 +82,7 @@ public: * own avatar URL or to query the URL of other users; either locally or * on remote homeservers. */ -class GetAvatarUrlJob : public BaseJob { +class QUOTIENT_API GetAvatarUrlJob : public BaseJob { public: /*! \brief Get the user's avatar URL. * @@ -111,7 +111,7 @@ public: * locally or on remote homeservers. This API may return keys which are not * limited to `displayname` or `avatar_url`. */ -class GetUserProfileJob : public BaseJob { +class QUOTIENT_API GetUserProfileJob : public BaseJob { public: /*! \brief Get this user's profile information. * diff --git a/lib/csapi/pusher.h b/lib/csapi/pusher.h index 622b0df6..d859ffc4 100644 --- a/lib/csapi/pusher.h +++ b/lib/csapi/pusher.h @@ -12,7 +12,7 @@ namespace Quotient { * * Gets all currently active pushers for the authenticated user. */ -class GetPushersJob : public BaseJob { +class QUOTIENT_API GetPushersJob : public BaseJob { public: // Inner data structures @@ -108,7 +108,7 @@ struct JsonObjectConverter { * [pushers](/client-server-api/#push-notifications) for this user ID. The * behaviour of this endpoint varies depending on the values in the JSON body. */ -class PostPusherJob : public BaseJob { +class QUOTIENT_API PostPusherJob : public BaseJob { public: // Inner data structures diff --git a/lib/csapi/pushrules.h b/lib/csapi/pushrules.h index a5eb48f0..d6c57efd 100644 --- a/lib/csapi/pushrules.h +++ b/lib/csapi/pushrules.h @@ -19,7 +19,7 @@ namespace Quotient { * `/pushrules/global/`. This will return a subset of this data under the * specified key e.g. the `global` key. */ -class GetPushRulesJob : public BaseJob { +class QUOTIENT_API GetPushRulesJob : public BaseJob { public: /// Retrieve all push rulesets. explicit GetPushRulesJob(); @@ -44,7 +44,7 @@ public: * * Retrieve a single specified push rule. */ -class GetPushRuleJob : public BaseJob { +class QUOTIENT_API GetPushRuleJob : public BaseJob { public: /*! \brief Retrieve a push rule. * @@ -79,7 +79,7 @@ public: * * This endpoint removes the push rule defined in the path. */ -class DeletePushRuleJob : public BaseJob { +class QUOTIENT_API DeletePushRuleJob : public BaseJob { public: /*! \brief Delete a push rule. * @@ -112,7 +112,7 @@ public: * * When creating push rules, they MUST be enabled by default. */ -class SetPushRuleJob : public BaseJob { +class QUOTIENT_API SetPushRuleJob : public BaseJob { public: /*! \brief Add or change a push rule. * @@ -160,7 +160,7 @@ public: * * This endpoint gets whether the specified push rule is enabled. */ -class IsPushRuleEnabledJob : public BaseJob { +class QUOTIENT_API IsPushRuleEnabledJob : public BaseJob { public: /*! \brief Get whether a push rule is enabled * @@ -195,7 +195,7 @@ public: * * This endpoint allows clients to enable or disable the specified push rule. */ -class SetPushRuleEnabledJob : public BaseJob { +class QUOTIENT_API SetPushRuleEnabledJob : public BaseJob { public: /*! \brief Enable or disable a push rule. * @@ -219,7 +219,7 @@ public: * * This endpoint get the actions for the specified push rule. */ -class GetPushRuleActionsJob : public BaseJob { +class QUOTIENT_API GetPushRuleActionsJob : public BaseJob { public: /*! \brief The actions for a push rule * @@ -258,7 +258,7 @@ public: * This endpoint allows clients to change the actions of a push rule. * This can be used to change the actions of builtin rules. */ -class SetPushRuleActionsJob : public BaseJob { +class QUOTIENT_API SetPushRuleActionsJob : public BaseJob { public: /*! \brief Set the actions for a push rule. * diff --git a/lib/csapi/read_markers.h b/lib/csapi/read_markers.h index 00a2aa0d..d13fa4fc 100644 --- a/lib/csapi/read_markers.h +++ b/lib/csapi/read_markers.h @@ -13,7 +13,7 @@ namespace Quotient { * Sets the position of the read marker for a given room, and optionally * the read receipt's location. */ -class SetReadMarkerJob : public BaseJob { +class QUOTIENT_API SetReadMarkerJob : public BaseJob { public: /*! \brief Set the position of the read marker for a room. * diff --git a/lib/csapi/receipts.h b/lib/csapi/receipts.h index 7ac093cd..e29e7b29 100644 --- a/lib/csapi/receipts.h +++ b/lib/csapi/receipts.h @@ -13,7 +13,7 @@ namespace Quotient { * This API updates the marker for the given receipt type to the event ID * specified. */ -class PostReceiptJob : public BaseJob { +class QUOTIENT_API PostReceiptJob : public BaseJob { public: /*! \brief Send a receipt for the given event ID. * diff --git a/lib/csapi/redaction.h b/lib/csapi/redaction.h index f0db9f9f..29d9c5d5 100644 --- a/lib/csapi/redaction.h +++ b/lib/csapi/redaction.h @@ -22,7 +22,7 @@ namespace Quotient { * * Server administrators may redact events sent by users on their server. */ -class RedactEventJob : public BaseJob { +class QUOTIENT_API RedactEventJob : public BaseJob { public: /*! \brief Strips all non-integrity-critical information out of an event. * diff --git a/lib/csapi/registration.h b/lib/csapi/registration.h index c1614f20..10375971 100644 --- a/lib/csapi/registration.h +++ b/lib/csapi/registration.h @@ -59,7 +59,7 @@ namespace Quotient { * Any user ID returned by this API must conform to the grammar given in the * [Matrix specification](/appendices/#user-identifiers). */ -class RegisterJob : public BaseJob { +class QUOTIENT_API RegisterJob : public BaseJob { public: /*! \brief Register for an account on this homeserver. * @@ -143,7 +143,7 @@ public: * should validate the email itself, either by sending a validation email * itself or by using a service it has control over. */ -class RequestTokenToRegisterEmailJob : public BaseJob { +class QUOTIENT_API RequestTokenToRegisterEmailJob : public BaseJob { public: /*! \brief Begins the validation process for an email to be used during * registration. @@ -175,7 +175,7 @@ public: * should validate the phone number itself, either by sending a validation * message itself or by using a service it has control over. */ -class RequestTokenToRegisterMSISDNJob : public BaseJob { +class QUOTIENT_API RequestTokenToRegisterMSISDNJob : public BaseJob { public: /*! \brief Requests a validation token be sent to the given phone number for * the purpose of registering an account @@ -215,7 +215,7 @@ public: * access token provided in the request. Whether other access tokens for * the user are revoked depends on the request parameters. */ -class ChangePasswordJob : public BaseJob { +class QUOTIENT_API ChangePasswordJob : public BaseJob { public: /*! \brief Changes a user's password. * @@ -257,7 +257,7 @@ public: * The homeserver should validate the email itself, either by sending a * validation email itself or by using a service it has control over. */ -class RequestTokenToResetPasswordEmailJob : public BaseJob { +class QUOTIENT_API RequestTokenToResetPasswordEmailJob : public BaseJob { public: /*! \brief Requests a validation token be sent to the given email address * for the purpose of resetting a user's password @@ -309,7 +309,7 @@ public: * The homeserver should validate the phone number itself, either by sending a * validation message itself or by using a service it has control over. */ -class RequestTokenToResetPasswordMSISDNJob : public BaseJob { +class QUOTIENT_API RequestTokenToResetPasswordMSISDNJob : public BaseJob { public: /*! \brief Requests a validation token be sent to the given phone number for * the purpose of resetting a user's password. @@ -361,7 +361,7 @@ public: * parameter because the homeserver is expected to sign the request to the * identity server instead. */ -class DeactivateAccountJob : public BaseJob { +class QUOTIENT_API DeactivateAccountJob : public BaseJob { public: /*! \brief Deactivate a user's account. * @@ -411,7 +411,7 @@ public: * reserve the username. This can mean that the username becomes unavailable * between checking its availability and attempting to register it. */ -class CheckUsernameAvailabilityJob : public BaseJob { +class QUOTIENT_API CheckUsernameAvailabilityJob : public BaseJob { public: /*! \brief Checks to see if a username is available on the server. * diff --git a/lib/csapi/report_content.h b/lib/csapi/report_content.h index e401c2e1..8c533c19 100644 --- a/lib/csapi/report_content.h +++ b/lib/csapi/report_content.h @@ -13,7 +13,7 @@ namespace Quotient { * Reports an event as inappropriate to the server, which may then notify * the appropriate people. */ -class ReportContentJob : public BaseJob { +class QUOTIENT_API ReportContentJob : public BaseJob { public: /*! \brief Reports an event as inappropriate. * diff --git a/lib/csapi/room_send.h b/lib/csapi/room_send.h index 96f5beca..fea3d59d 100644 --- a/lib/csapi/room_send.h +++ b/lib/csapi/room_send.h @@ -18,7 +18,7 @@ namespace Quotient { * fields in this object will vary depending on the type of event. See * [Room Events](/client-server-api/#room-events) for the m. event specification. */ -class SendMessageJob : public BaseJob { +class QUOTIENT_API SendMessageJob : public BaseJob { public: /*! \brief Send a message event to the given room. * diff --git a/lib/csapi/room_state.h b/lib/csapi/room_state.h index f95af223..a00b0947 100644 --- a/lib/csapi/room_state.h +++ b/lib/csapi/room_state.h @@ -29,7 +29,7 @@ namespace Quotient { * state event is to be sent. Servers do not validate aliases which are * being removed or are already present in the state event. */ -class SetRoomStateWithKeyJob : public BaseJob { +class QUOTIENT_API SetRoomStateWithKeyJob : public BaseJob { public: /*! \brief Send a state event to the given room. * diff --git a/lib/csapi/room_upgrades.h b/lib/csapi/room_upgrades.h index 58327587..0432f667 100644 --- a/lib/csapi/room_upgrades.h +++ b/lib/csapi/room_upgrades.h @@ -12,7 +12,7 @@ namespace Quotient { * * Upgrades the given room to a particular room version. */ -class UpgradeRoomJob : public BaseJob { +class QUOTIENT_API UpgradeRoomJob : public BaseJob { public: /*! \brief Upgrades a room to a new room version. * diff --git a/lib/csapi/rooms.h b/lib/csapi/rooms.h index 2620582b..f0815109 100644 --- a/lib/csapi/rooms.h +++ b/lib/csapi/rooms.h @@ -15,7 +15,7 @@ namespace Quotient { * Get a single event based on `roomId/eventId`. You must have permission to * retrieve this event e.g. by being a member in the room for this event. */ -class GetOneRoomEventJob : public BaseJob { +class QUOTIENT_API GetOneRoomEventJob : public BaseJob { public: /*! \brief Get a single event by event ID. * @@ -48,7 +48,7 @@ public: * state of the room. If the user has left the room then the state is * taken from the state of the room when they left. */ -class GetRoomStateWithKeyJob : public BaseJob { +class QUOTIENT_API GetRoomStateWithKeyJob : public BaseJob { public: /*! \brief Get the state identified by the type and key. * @@ -80,7 +80,7 @@ public: * * Get the state events for the current state of a room. */ -class GetRoomStateJob : public BaseJob { +class QUOTIENT_API GetRoomStateJob : public BaseJob { public: /*! \brief Get all state events in the current state of a room. * @@ -106,7 +106,7 @@ public: * * Get the list of members for this room. */ -class GetMembersByRoomJob : public BaseJob { +class QUOTIENT_API GetMembersByRoomJob : public BaseJob { public: /*! \brief Get the m.room.member events for the room. * @@ -161,7 +161,7 @@ public: * respond than `/members` as it can be implemented more efficiently on the * server. */ -class GetJoinedMembersByRoomJob : public BaseJob { +class QUOTIENT_API GetJoinedMembersByRoomJob : public BaseJob { public: // Inner data structures diff --git a/lib/csapi/search.h b/lib/csapi/search.h index 3d02752a..8683413d 100644 --- a/lib/csapi/search.h +++ b/lib/csapi/search.h @@ -15,7 +15,7 @@ namespace Quotient { * * Performs a full text search across different categories. */ -class SearchJob : public BaseJob { +class QUOTIENT_API SearchJob : public BaseJob { public: // Inner data structures diff --git a/lib/csapi/sso_login_redirect.h b/lib/csapi/sso_login_redirect.h index ade1eb7d..f4f81c1e 100644 --- a/lib/csapi/sso_login_redirect.h +++ b/lib/csapi/sso_login_redirect.h @@ -17,7 +17,7 @@ namespace Quotient { * or present a page which lets the user select an IdP to continue * with in the event multiple are supported by the server. */ -class RedirectToSSOJob : public BaseJob { +class QUOTIENT_API RedirectToSSOJob : public BaseJob { public: /*! \brief Redirect the user's browser to the SSO interface. * @@ -44,7 +44,7 @@ public: * The server MUST respond with an HTTP redirect to the SSO interface * for that IdP. */ -class RedirectToIdPJob : public BaseJob { +class QUOTIENT_API RedirectToIdPJob : public BaseJob { public: /*! \brief Redirect the user's browser to the SSO interface for an IdP. * diff --git a/lib/csapi/tags.h b/lib/csapi/tags.h index a854531a..f4250674 100644 --- a/lib/csapi/tags.h +++ b/lib/csapi/tags.h @@ -12,7 +12,7 @@ namespace Quotient { * * List the tags set by a user on a room. */ -class GetRoomTagsJob : public BaseJob { +class QUOTIENT_API GetRoomTagsJob : public BaseJob { public: // Inner data structures @@ -68,7 +68,7 @@ struct JsonObjectConverter { * * Add a tag to the room. */ -class SetRoomTagJob : public BaseJob { +class QUOTIENT_API SetRoomTagJob : public BaseJob { public: /*! \brief Add a tag to a room. * @@ -98,7 +98,7 @@ public: * * Remove a tag from the room. */ -class DeleteRoomTagJob : public BaseJob { +class QUOTIENT_API DeleteRoomTagJob : public BaseJob { public: /*! \brief Remove a tag from the room. * diff --git a/lib/csapi/third_party_lookup.h b/lib/csapi/third_party_lookup.h index 969e767c..30c5346e 100644 --- a/lib/csapi/third_party_lookup.h +++ b/lib/csapi/third_party_lookup.h @@ -18,7 +18,7 @@ namespace Quotient { * homeserver. Includes both the available protocols and all fields * required for queries against each protocol. */ -class GetProtocolsJob : public BaseJob { +class QUOTIENT_API GetProtocolsJob : public BaseJob { public: /// Retrieve metadata about all protocols that a homeserver supports. explicit GetProtocolsJob(); @@ -45,7 +45,7 @@ public: * Fetches the metadata from the homeserver about a particular third party * protocol. */ -class GetProtocolMetadataJob : public BaseJob { +class QUOTIENT_API GetProtocolMetadataJob : public BaseJob { public: /*! \brief Retrieve metadata about a specific protocol that the homeserver * supports. @@ -82,7 +82,7 @@ public: * identifier. It should attempt to canonicalise the identifier as much * as reasonably possible given the network type. */ -class QueryLocationByProtocolJob : public BaseJob { +class QUOTIENT_API QueryLocationByProtocolJob : public BaseJob { public: /*! \brief Retrieve Matrix-side portals rooms leading to a third party * location. @@ -119,7 +119,7 @@ public: * Retrieve a Matrix User ID linked to a user on the third party service, given * a set of user parameters. */ -class QueryUserByProtocolJob : public BaseJob { +class QUOTIENT_API QueryUserByProtocolJob : public BaseJob { public: /*! \brief Retrieve the Matrix User ID of a corresponding third party user. * @@ -155,7 +155,7 @@ public: * Retrieve an array of third party network locations from a Matrix room * alias. */ -class QueryLocationByAliasJob : public BaseJob { +class QUOTIENT_API QueryLocationByAliasJob : public BaseJob { public: /*! \brief Reverse-lookup third party locations given a Matrix room alias. * @@ -184,7 +184,7 @@ public: * * Retrieve an array of third party users from a Matrix User ID. */ -class QueryUserByIDJob : public BaseJob { +class QUOTIENT_API QueryUserByIDJob : public BaseJob { public: /*! \brief Reverse-lookup third party users given a Matrix User ID. * diff --git a/lib/csapi/third_party_membership.h b/lib/csapi/third_party_membership.h index a424678f..1edb969e 100644 --- a/lib/csapi/third_party_membership.h +++ b/lib/csapi/third_party_membership.h @@ -52,7 +52,7 @@ namespace Quotient { * If a token is requested from the identity server, the homeserver will * append a `m.room.third_party_invite` event to the room. */ -class InviteBy3PIDJob : public BaseJob { +class QUOTIENT_API InviteBy3PIDJob : public BaseJob { public: /*! \brief Invite a user to participate in a particular room. * diff --git a/lib/csapi/to_device.h b/lib/csapi/to_device.h index 7a237195..5b6e0bfb 100644 --- a/lib/csapi/to_device.h +++ b/lib/csapi/to_device.h @@ -13,7 +13,7 @@ namespace Quotient { * This endpoint is used to send send-to-device events to a set of * client devices. */ -class SendToDeviceJob : public BaseJob { +class QUOTIENT_API SendToDeviceJob : public BaseJob { public: /*! \brief Send an event to a given set of devices. * diff --git a/lib/csapi/typing.h b/lib/csapi/typing.h index 64a310d0..234e91b0 100644 --- a/lib/csapi/typing.h +++ b/lib/csapi/typing.h @@ -15,7 +15,7 @@ namespace Quotient { * Alternatively, if `typing` is `false`, it tells the server that the * user has stopped typing. */ -class SetTypingJob : public BaseJob { +class QUOTIENT_API SetTypingJob : public BaseJob { public: /*! \brief Informs the server that the user has started or stopped typing. * diff --git a/lib/csapi/users.h b/lib/csapi/users.h index ec186592..3c99758b 100644 --- a/lib/csapi/users.h +++ b/lib/csapi/users.h @@ -21,7 +21,7 @@ namespace Quotient { * names preferably using a collation determined based upon the * `Accept-Language` header provided in the request, if present. */ -class SearchUserDirectoryJob : public BaseJob { +class QUOTIENT_API SearchUserDirectoryJob : public BaseJob { public: // Inner data structures diff --git a/lib/csapi/versions.h b/lib/csapi/versions.h index 896e2ea9..4445dbd2 100644 --- a/lib/csapi/versions.h +++ b/lib/csapi/versions.h @@ -31,7 +31,7 @@ namespace Quotient { * upgrade appropriately. Additionally, clients should avoid using unstable * features in their stable releases. */ -class GetVersionsJob : public BaseJob { +class QUOTIENT_API GetVersionsJob : public BaseJob { public: /// Gets the versions of the specification supported by the server. explicit GetVersionsJob(); diff --git a/lib/csapi/voip.h b/lib/csapi/voip.h index 087ebbbd..38904f60 100644 --- a/lib/csapi/voip.h +++ b/lib/csapi/voip.h @@ -13,7 +13,7 @@ namespace Quotient { * This API provides credentials for the client to use when initiating * calls. */ -class GetTurnServerJob : public BaseJob { +class QUOTIENT_API GetTurnServerJob : public BaseJob { public: /// Obtain TURN server credentials. explicit GetTurnServerJob(); diff --git a/lib/csapi/wellknown.h b/lib/csapi/wellknown.h index c707d232..8615191c 100644 --- a/lib/csapi/wellknown.h +++ b/lib/csapi/wellknown.h @@ -21,7 +21,7 @@ namespace Quotient { * Note that this endpoint is not necessarily handled by the homeserver, * but by another webserver, to be used for discovering the homeserver URL. */ -class GetWellknownJob : public BaseJob { +class QUOTIENT_API GetWellknownJob : public BaseJob { public: /// Gets Matrix server discovery information about the domain. explicit GetWellknownJob(); diff --git a/lib/csapi/whoami.h b/lib/csapi/whoami.h index 319f82c5..fba099f6 100644 --- a/lib/csapi/whoami.h +++ b/lib/csapi/whoami.h @@ -19,7 +19,7 @@ namespace Quotient { * is registered by the appservice, and return it in the response * body. */ -class GetTokenOwnerJob : public BaseJob { +class QUOTIENT_API GetTokenOwnerJob : public BaseJob { public: /// Gets information about the owner of an access token. explicit GetTokenOwnerJob(); -- cgit v1.2.3 From 42811660094c88a4a1bfa8bd8ace5f4b148c246a Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 31 May 2022 18:24:53 +0200 Subject: Regenerate API files (FTBFS; see the next commit) --- .../schema/core-event-schema/stripped_state.h | 44 +++++++++++ lib/csapi/account-data.cpp | 12 +-- lib/csapi/admin.cpp | 4 +- lib/csapi/administrative_contact.cpp | 18 ++--- lib/csapi/administrative_contact.h | 26 +++++-- lib/csapi/appservice_room_directory.cpp | 8 +- lib/csapi/appservice_room_directory.h | 3 +- lib/csapi/banning.cpp | 4 +- lib/csapi/capabilities.cpp | 4 +- lib/csapi/content-repo.cpp | 27 +++---- lib/csapi/content-repo.h | 3 +- lib/csapi/create_room.cpp | 2 +- lib/csapi/create_room.h | 46 ++++++----- lib/csapi/cross_signing.cpp | 8 +- lib/csapi/cross_signing.h | 10 ++- lib/csapi/definitions/auth_data.h | 7 +- lib/csapi/definitions/openid_token.h | 8 +- lib/csapi/definitions/public_rooms_chunk.h | 73 ++++++++++++++++++ lib/csapi/definitions/public_rooms_response.h | 74 +----------------- lib/csapi/definitions/push_condition.h | 4 +- lib/csapi/device_management.cpp | 14 ++-- lib/csapi/device_management.h | 3 +- lib/csapi/directory.cpp | 14 ++-- lib/csapi/event_context.cpp | 4 +- lib/csapi/filter.cpp | 6 +- lib/csapi/inviting.cpp | 2 +- lib/csapi/inviting.h | 2 +- lib/csapi/joining.cpp | 4 +- lib/csapi/joining.h | 8 +- lib/csapi/keys.cpp | 14 ++-- lib/csapi/keys.h | 33 ++++++-- lib/csapi/kicking.cpp | 2 +- lib/csapi/knocking.cpp | 2 +- lib/csapi/knocking.h | 2 +- lib/csapi/leaving.cpp | 6 +- lib/csapi/list_joined_rooms.cpp | 4 +- lib/csapi/list_public_rooms.cpp | 12 +-- lib/csapi/list_public_rooms.h | 10 +-- lib/csapi/login.cpp | 6 +- lib/csapi/logout.cpp | 8 +- lib/csapi/message_pagination.cpp | 17 +++-- lib/csapi/message_pagination.h | 55 +++++++++----- lib/csapi/notifications.cpp | 4 +- lib/csapi/notifications.h | 3 +- lib/csapi/openid.cpp | 2 +- lib/csapi/openid.h | 5 +- lib/csapi/peeking_events.cpp | 4 +- lib/csapi/peeking_events.h | 4 +- lib/csapi/presence.cpp | 6 +- lib/csapi/profile.cpp | 18 +++-- lib/csapi/pusher.cpp | 6 +- lib/csapi/pushrules.cpp | 26 +++---- lib/csapi/read_markers.cpp | 2 +- lib/csapi/receipts.cpp | 2 +- lib/csapi/redaction.cpp | 2 +- lib/csapi/registration.cpp | 21 +++--- lib/csapi/registration.h | 21 +++--- lib/csapi/registration_tokens.cpp | 33 ++++++++ lib/csapi/registration_tokens.h | 44 +++++++++++ lib/csapi/report_content.cpp | 2 +- lib/csapi/room_send.cpp | 2 +- lib/csapi/room_send.h | 3 +- lib/csapi/room_state.cpp | 2 +- lib/csapi/room_upgrades.cpp | 2 +- lib/csapi/rooms.cpp | 20 ++--- lib/csapi/rooms.h | 13 +--- lib/csapi/search.cpp | 2 +- lib/csapi/space_hierarchy.cpp | 43 +++++++++++ lib/csapi/space_hierarchy.h | 88 ++++++++++++++++++++++ lib/csapi/sso_login_redirect.cpp | 8 +- lib/csapi/tags.cpp | 10 +-- lib/csapi/third_party_lookup.cpp | 24 +++--- lib/csapi/third_party_membership.cpp | 2 +- lib/csapi/third_party_membership.h | 2 +- lib/csapi/to_device.cpp | 2 +- lib/csapi/typing.cpp | 2 +- lib/csapi/users.cpp | 2 +- lib/csapi/versions.h | 8 +- lib/csapi/voip.cpp | 4 +- lib/csapi/whoami.cpp | 4 +- lib/csapi/whoami.h | 8 ++ 81 files changed, 712 insertions(+), 357 deletions(-) create mode 100644 event-schemas/schema/core-event-schema/stripped_state.h create mode 100644 lib/csapi/definitions/public_rooms_chunk.h create mode 100644 lib/csapi/registration_tokens.cpp create mode 100644 lib/csapi/registration_tokens.h create mode 100644 lib/csapi/space_hierarchy.cpp create mode 100644 lib/csapi/space_hierarchy.h (limited to 'lib/csapi') diff --git a/event-schemas/schema/core-event-schema/stripped_state.h b/event-schemas/schema/core-event-schema/stripped_state.h new file mode 100644 index 00000000..742b0a56 --- /dev/null +++ b/event-schemas/schema/core-event-schema/stripped_state.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "converters.h" + +namespace Quotient { +/// A stripped down state event, with only the `type`, `state_key`, +/// `sender`, and `content` keys. +struct StrippedStateEvent { + /// The `content` for the event. + QJsonObject content; + + /// The `state_key` for the event. + QString stateKey; + + /// The `type` for the event. + QString type; + + /// The `sender` for the event. + QString sender; +}; + +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const StrippedStateEvent& pod) + { + addParam<>(jo, QStringLiteral("content"), pod.content); + addParam<>(jo, QStringLiteral("state_key"), pod.stateKey); + addParam<>(jo, QStringLiteral("type"), pod.type); + addParam<>(jo, QStringLiteral("sender"), pod.sender); + } + static void fillFrom(const QJsonObject& jo, StrippedStateEvent& pod) + { + fromJson(jo.value("content"_ls), pod.content); + fromJson(jo.value("state_key"_ls), pod.stateKey); + fromJson(jo.value("type"_ls), pod.type); + fromJson(jo.value("sender"_ls), pod.sender); + } +}; + +} // namespace Quotient diff --git a/lib/csapi/account-data.cpp b/lib/csapi/account-data.cpp index 09fc8d40..1343eb98 100644 --- a/lib/csapi/account-data.cpp +++ b/lib/csapi/account-data.cpp @@ -9,7 +9,7 @@ using namespace Quotient; SetAccountDataJob::SetAccountDataJob(const QString& userId, const QString& type, const QJsonObject& content) : BaseJob(HttpVerb::Put, QStringLiteral("SetAccountDataJob"), - makePath("/_matrix/client/r0", "/user/", userId, "/account_data/", + makePath("/_matrix/client/v3", "/user/", userId, "/account_data/", type)) { setRequestData(RequestData(toJson(content))); @@ -19,13 +19,13 @@ QUrl GetAccountDataJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& type) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/user/", + makePath("/_matrix/client/v3", "/user/", userId, "/account_data/", type)); } GetAccountDataJob::GetAccountDataJob(const QString& userId, const QString& type) : BaseJob(HttpVerb::Get, QStringLiteral("GetAccountDataJob"), - makePath("/_matrix/client/r0", "/user/", userId, "/account_data/", + makePath("/_matrix/client/v3", "/user/", userId, "/account_data/", type)) {} @@ -34,7 +34,7 @@ SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, const QString& type, const QJsonObject& content) : BaseJob(HttpVerb::Put, QStringLiteral("SetAccountDataPerRoomJob"), - makePath("/_matrix/client/r0", "/user/", userId, "/rooms/", + makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/account_data/", type)) { setRequestData(RequestData(toJson(content))); @@ -46,7 +46,7 @@ QUrl GetAccountDataPerRoomJob::makeRequestUrl(QUrl baseUrl, const QString& type) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/user/", + makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/account_data/", type)); } @@ -55,6 +55,6 @@ GetAccountDataPerRoomJob::GetAccountDataPerRoomJob(const QString& userId, const QString& roomId, const QString& type) : BaseJob(HttpVerb::Get, QStringLiteral("GetAccountDataPerRoomJob"), - makePath("/_matrix/client/r0", "/user/", userId, "/rooms/", + makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/account_data/", type)) {} diff --git a/lib/csapi/admin.cpp b/lib/csapi/admin.cpp index 81dd0624..322212db 100644 --- a/lib/csapi/admin.cpp +++ b/lib/csapi/admin.cpp @@ -9,11 +9,11 @@ using namespace Quotient; QUrl GetWhoIsJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/admin/whois/", userId)); } GetWhoIsJob::GetWhoIsJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetWhoIsJob"), - makePath("/_matrix/client/r0", "/admin/whois/", userId)) + makePath("/_matrix/client/v3", "/admin/whois/", userId)) {} diff --git a/lib/csapi/administrative_contact.cpp b/lib/csapi/administrative_contact.cpp index 589c9fc1..f52e2e1f 100644 --- a/lib/csapi/administrative_contact.cpp +++ b/lib/csapi/administrative_contact.cpp @@ -9,17 +9,17 @@ using namespace Quotient; QUrl GetAccount3PIDsJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl( - std::move(baseUrl), makePath("/_matrix/client/r0", "/account/3pid")); + std::move(baseUrl), makePath("/_matrix/client/v3", "/account/3pid")); } GetAccount3PIDsJob::GetAccount3PIDsJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetAccount3PIDsJob"), - makePath("/_matrix/client/r0", "/account/3pid")) + makePath("/_matrix/client/v3", "/account/3pid")) {} Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds) : BaseJob(HttpVerb::Post, QStringLiteral("Post3PIDsJob"), - makePath("/_matrix/client/r0", "/account/3pid")) + makePath("/_matrix/client/v3", "/account/3pid")) { QJsonObject _data; addParam<>(_data, QStringLiteral("three_pid_creds"), threePidCreds); @@ -29,7 +29,7 @@ Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds) Add3PIDJob::Add3PIDJob(const QString& clientSecret, const QString& sid, const Omittable& auth) : BaseJob(HttpVerb::Post, QStringLiteral("Add3PIDJob"), - makePath("/_matrix/client/r0", "/account/3pid/add")) + makePath("/_matrix/client/v3", "/account/3pid/add")) { QJsonObject _data; addParam(_data, QStringLiteral("auth"), auth); @@ -41,7 +41,7 @@ Add3PIDJob::Add3PIDJob(const QString& clientSecret, const QString& sid, Bind3PIDJob::Bind3PIDJob(const QString& clientSecret, const QString& idServer, const QString& idAccessToken, const QString& sid) : BaseJob(HttpVerb::Post, QStringLiteral("Bind3PIDJob"), - makePath("/_matrix/client/r0", "/account/3pid/bind")) + makePath("/_matrix/client/v3", "/account/3pid/bind")) { QJsonObject _data; addParam<>(_data, QStringLiteral("client_secret"), clientSecret); @@ -55,7 +55,7 @@ Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium, const QString& address, const QString& idServer) : BaseJob(HttpVerb::Post, QStringLiteral("Delete3pidFromAccountJob"), - makePath("/_matrix/client/r0", "/account/3pid/delete")) + makePath("/_matrix/client/v3", "/account/3pid/delete")) { QJsonObject _data; addParam(_data, QStringLiteral("id_server"), idServer); @@ -69,7 +69,7 @@ Unbind3pidFromAccountJob::Unbind3pidFromAccountJob(const QString& medium, const QString& address, const QString& idServer) : BaseJob(HttpVerb::Post, QStringLiteral("Unbind3pidFromAccountJob"), - makePath("/_matrix/client/r0", "/account/3pid/unbind")) + makePath("/_matrix/client/v3", "/account/3pid/unbind")) { QJsonObject _data; addParam(_data, QStringLiteral("id_server"), idServer); @@ -82,7 +82,7 @@ Unbind3pidFromAccountJob::Unbind3pidFromAccountJob(const QString& medium, RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob( const EmailValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenTo3PIDEmailJob"), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/account/3pid/email/requestToken"), false) { @@ -92,7 +92,7 @@ RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob( RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob( const MsisdnValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenTo3PIDMSISDNJob"), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/account/3pid/msisdn/requestToken"), false) { diff --git a/lib/csapi/administrative_contact.h b/lib/csapi/administrative_contact.h index e636b12a..27334850 100644 --- a/lib/csapi/administrative_contact.h +++ b/lib/csapi/administrative_contact.h @@ -128,6 +128,22 @@ public: * The third party credentials to associate with the account. */ explicit Post3PIDsJob(const ThreePidCredentials& threePidCreds); + + // Result properties + + /// An optional field containing a URL where the client must + /// submit the validation token to, with identical parameters + /// to the Identity Service API's `POST + /// /validate/email/submitToken` endpoint (without the requirement + /// for an access token). The homeserver must send this token to the + /// user (if applicable), who should then be prompted to provide it + /// to the client. + /// + /// If this field is not present, the client can assume that + /// verification will happen without the client's involvement + /// provided the homeserver advertises this specification version + /// in the `/versions` response (ie: r0.5.0). + QUrl submitUrl() const { return loadFromJson("submit_url"_ls); } }; template <> @@ -235,7 +251,7 @@ public: /// An indicator as to whether or not the homeserver was able to unbind /// the 3PID from the identity server. `success` indicates that the - /// indentity server has unbound the identifier whereas `no-support` + /// identity server has unbound the identifier whereas `no-support` /// indicates that the identity server refuses to support the request /// or the homeserver was not able to determine an identity server to /// unbind from. @@ -295,7 +311,7 @@ public: * be used to request validation tokens when adding an email address to an * account. This API's parameters and response are identical to that of * the - * [`/register/email/requestToken`](/client-server-api/#post_matrixclientr0registeremailrequesttoken) + * [`/register/email/requestToken`](/client-server-api/#post_matrixclientv3registeremailrequesttoken) * endpoint. The homeserver should validate * the email itself, either by sending a validation email itself or by using * a service it has control over. @@ -311,7 +327,7 @@ public: * be used to request validation tokens when adding an email address to an * account. This API's parameters and response are identical to that of * the - * [`/register/email/requestToken`](/client-server-api/#post_matrixclientr0registeremailrequesttoken) + * [`/register/email/requestToken`](/client-server-api/#post_matrixclientv3registeremailrequesttoken) * endpoint. The homeserver should validate * the email itself, either by sending a validation email itself or by * using a service it has control over. @@ -337,7 +353,7 @@ public: * be used to request validation tokens when adding a phone number to an * account. This API's parameters and response are identical to that of * the - * [`/register/msisdn/requestToken`](/client-server-api/#post_matrixclientr0registermsisdnrequesttoken) + * [`/register/msisdn/requestToken`](/client-server-api/#post_matrixclientv3registermsisdnrequesttoken) * endpoint. The homeserver should validate * the phone number itself, either by sending a validation message itself or by * using a service it has control over. @@ -353,7 +369,7 @@ public: * be used to request validation tokens when adding a phone number to an * account. This API's parameters and response are identical to that of * the - * [`/register/msisdn/requestToken`](/client-server-api/#post_matrixclientr0registermsisdnrequesttoken) + * [`/register/msisdn/requestToken`](/client-server-api/#post_matrixclientv3registermsisdnrequesttoken) * endpoint. The homeserver should validate * the phone number itself, either by sending a validation message itself * or by using a service it has control over. diff --git a/lib/csapi/appservice_room_directory.cpp b/lib/csapi/appservice_room_directory.cpp index 40d784c6..c989559f 100644 --- a/lib/csapi/appservice_room_directory.cpp +++ b/lib/csapi/appservice_room_directory.cpp @@ -6,11 +6,13 @@ using namespace Quotient; -UpdateAppserviceRoomDirectoryVisibilityJob::UpdateAppserviceRoomDirectoryVisibilityJob( - const QString& networkId, const QString& roomId, const QString& visibility) +UpdateAppserviceRoomDirectoryVisibilityJob:: + UpdateAppserviceRoomDirectoryVisibilityJob(const QString& networkId, + const QString& roomId, + const QString& visibility) : BaseJob(HttpVerb::Put, QStringLiteral("UpdateAppserviceRoomDirectoryVisibilityJob"), - makePath("/_matrix/client/r0", "/directory/list/appservice/", + makePath("/_matrix/client/v3", "/directory/list/appservice/", networkId, "/", roomId)) { QJsonObject _data; diff --git a/lib/csapi/appservice_room_directory.h b/lib/csapi/appservice_room_directory.h index 6b2801ca..d6268979 100644 --- a/lib/csapi/appservice_room_directory.h +++ b/lib/csapi/appservice_room_directory.h @@ -21,8 +21,7 @@ namespace Quotient { * instead of a typical client's access_token. This API cannot be invoked by * users who are not identified as application services. */ -class QUOTIENT_API UpdateAppserviceRoomDirectoryVisibilityJob - : public BaseJob { +class QUOTIENT_API UpdateAppserviceRoomDirectoryVisibilityJob : public BaseJob { public: /*! \brief Updates a room's visibility in the application service's room * directory. diff --git a/lib/csapi/banning.cpp b/lib/csapi/banning.cpp index 472128bb..77047e89 100644 --- a/lib/csapi/banning.cpp +++ b/lib/csapi/banning.cpp @@ -9,7 +9,7 @@ using namespace Quotient; BanJob::BanJob(const QString& roomId, const QString& userId, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("BanJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/ban")) + makePath("/_matrix/client/v3", "/rooms/", roomId, "/ban")) { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); @@ -20,7 +20,7 @@ BanJob::BanJob(const QString& roomId, const QString& userId, UnbanJob::UnbanJob(const QString& roomId, const QString& userId, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("UnbanJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/unban")) + makePath("/_matrix/client/v3", "/rooms/", roomId, "/unban")) { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); diff --git a/lib/csapi/capabilities.cpp b/lib/csapi/capabilities.cpp index bc21e462..ca2a543f 100644 --- a/lib/csapi/capabilities.cpp +++ b/lib/csapi/capabilities.cpp @@ -9,12 +9,12 @@ using namespace Quotient; QUrl GetCapabilitiesJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl( - std::move(baseUrl), makePath("/_matrix/client/r0", "/capabilities")); + std::move(baseUrl), makePath("/_matrix/client/v3", "/capabilities")); } GetCapabilitiesJob::GetCapabilitiesJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetCapabilitiesJob"), - makePath("/_matrix/client/r0", "/capabilities")) + makePath("/_matrix/client/v3", "/capabilities")) { addExpectedKey("capabilities"); } diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index 6d1e38b6..7d740cb7 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -16,7 +16,7 @@ auto queryToUploadContent(const QString& filename) UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, const QString& contentType) : BaseJob(HttpVerb::Post, QStringLiteral("UploadContentJob"), - makePath("/_matrix/media/r0", "/upload"), + makePath("/_matrix/media/v3", "/upload"), queryToUploadContent(filename)) { setRequestHeader("Content-Type", contentType.toLatin1()); @@ -35,7 +35,7 @@ QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, bool allowRemote) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/media/r0", "/download/", + makePath("/_matrix/media/v3", "/download/", serverName, "/", mediaId), queryToGetContent(allowRemote)); } @@ -43,7 +43,7 @@ QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId, bool allowRemote) : BaseJob(HttpVerb::Get, QStringLiteral("GetContentJob"), - makePath("/_matrix/media/r0", "/download/", serverName, "/", + makePath("/_matrix/media/v3", "/download/", serverName, "/", mediaId), queryToGetContent(allowRemote), {}, false) { @@ -64,7 +64,7 @@ QUrl GetContentOverrideNameJob::makeRequestUrl(QUrl baseUrl, bool allowRemote) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/media/r0", "/download/", + makePath("/_matrix/media/v3", "/download/", serverName, "/", mediaId, "/", fileName), queryToGetContentOverrideName(allowRemote)); @@ -75,7 +75,7 @@ GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, const QString& fileName, bool allowRemote) : BaseJob(HttpVerb::Get, QStringLiteral("GetContentOverrideNameJob"), - makePath("/_matrix/media/r0", "/download/", serverName, "/", + makePath("/_matrix/media/v3", "/download/", serverName, "/", mediaId, "/", fileName), queryToGetContentOverrideName(allowRemote), {}, false) { @@ -101,16 +101,17 @@ QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, { return BaseJob::makeRequestUrl( std::move(baseUrl), - makePath("/_matrix/media/r0", "/thumbnail/", serverName, "/", mediaId), + makePath("/_matrix/media/v3", "/thumbnail/", serverName, "/", mediaId), queryToGetContentThumbnail(width, height, method, allowRemote)); } GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, - const QString& mediaId, int width, - int height, const QString& method, + const QString& mediaId, + int width, int height, + const QString& method, bool allowRemote) : BaseJob(HttpVerb::Get, QStringLiteral("GetContentThumbnailJob"), - makePath("/_matrix/media/r0", "/thumbnail/", serverName, "/", + makePath("/_matrix/media/v3", "/thumbnail/", serverName, "/", mediaId), queryToGetContentThumbnail(width, height, method, allowRemote), {}, false) @@ -130,24 +131,24 @@ QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QUrl& url, Omittable ts) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/media/r0", + makePath("/_matrix/media/v3", "/preview_url"), queryToGetUrlPreview(url, ts)); } GetUrlPreviewJob::GetUrlPreviewJob(const QUrl& url, Omittable ts) : BaseJob(HttpVerb::Get, QStringLiteral("GetUrlPreviewJob"), - makePath("/_matrix/media/r0", "/preview_url"), + makePath("/_matrix/media/v3", "/preview_url"), queryToGetUrlPreview(url, ts)) {} QUrl GetConfigJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/media/r0", "/config")); + makePath("/_matrix/media/v3", "/config")); } GetConfigJob::GetConfigJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetConfigJob"), - makePath("/_matrix/media/r0", "/config")) + makePath("/_matrix/media/v3", "/config")) {} diff --git a/lib/csapi/content-repo.h b/lib/csapi/content-repo.h index 511db985..2ba66a35 100644 --- a/lib/csapi/content-repo.h +++ b/lib/csapi/content-repo.h @@ -162,7 +162,8 @@ public: * * \param method * The desired resizing method. See the - * [Thumbnails](/client-server-api/#thumbnails) section for more information. + * [Thumbnails](/client-server-api/#thumbnails) section for more + * information. * * \param allowRemote * Indicates to the server that it should not attempt to fetch diff --git a/lib/csapi/create_room.cpp b/lib/csapi/create_room.cpp index 9aaef87f..834d8c13 100644 --- a/lib/csapi/create_room.cpp +++ b/lib/csapi/create_room.cpp @@ -16,7 +16,7 @@ CreateRoomJob::CreateRoomJob(const QString& visibility, const QString& preset, Omittable isDirect, const QJsonObject& powerLevelContentOverride) : BaseJob(HttpVerb::Post, QStringLiteral("CreateRoomJob"), - makePath("/_matrix/client/r0", "/createRoom")) + makePath("/_matrix/client/v3", "/createRoom")) { QJsonObject _data; addParam(_data, QStringLiteral("visibility"), visibility); diff --git a/lib/csapi/create_room.h b/lib/csapi/create_room.h index 7d566057..336b9767 100644 --- a/lib/csapi/create_room.h +++ b/lib/csapi/create_room.h @@ -26,16 +26,18 @@ namespace Quotient { * (and not other members) permission to send state events. Overridden * by the `power_level_content_override` parameter. * - * 4. Events set by the `preset`. Currently these are the `m.room.join_rules`, + * 4. An `m.room.canonical_alias` event if `room_alias_name` is given. + * + * 5. Events set by the `preset`. Currently these are the `m.room.join_rules`, * `m.room.history_visibility`, and `m.room.guest_access` state events. * - * 5. Events listed in `initial_state`, in the order that they are + * 6. Events listed in `initial_state`, in the order that they are * listed. * - * 6. Events implied by `name` and `topic` (`m.room.name` and `m.room.topic` + * 7. Events implied by `name` and `topic` (`m.room.name` and `m.room.topic` * state events). * - * 7. Invite events implied by `invite` and `invite_3pid` (`m.room.member` with + * 8. Invite events implied by `invite` and `invite_3pid` (`m.room.member` with * `membership: invite` and `m.room.third_party_invite`). * * The available presets do the following with respect to room state: @@ -73,17 +75,20 @@ public: /// (and not other members) permission to send state events. Overridden /// by the `power_level_content_override` parameter. /// - /// 4. Events set by the `preset`. Currently these are the + /// 4. An `m.room.canonical_alias` event if `room_alias_name` is given. + /// + /// 5. Events set by the `preset`. Currently these are the /// `m.room.join_rules`, /// `m.room.history_visibility`, and `m.room.guest_access` state events. /// - /// 5. Events listed in `initial_state`, in the order that they are + /// 6. Events listed in `initial_state`, in the order that they are /// listed. /// - /// 6. Events implied by `name` and `topic` (`m.room.name` and `m.room.topic` + /// 7. Events implied by `name` and `topic` (`m.room.name` and + /// `m.room.topic` /// state events). /// - /// 7. Invite events implied by `invite` and `invite_3pid` (`m.room.member` + /// 8. Invite events implied by `invite` and `invite_3pid` (`m.room.member` /// with /// `membership: invite` and `m.room.third_party_invite`). /// @@ -132,17 +137,20 @@ public: /// (and not other members) permission to send state events. Overridden /// by the `power_level_content_override` parameter. /// - /// 4. Events set by the `preset`. Currently these are the + /// 4. An `m.room.canonical_alias` event if `room_alias_name` is given. + /// + /// 5. Events set by the `preset`. Currently these are the /// `m.room.join_rules`, /// `m.room.history_visibility`, and `m.room.guest_access` state events. /// - /// 5. Events listed in `initial_state`, in the order that they are + /// 6. Events listed in `initial_state`, in the order that they are /// listed. /// - /// 6. Events implied by `name` and `topic` (`m.room.name` and `m.room.topic` + /// 7. Events implied by `name` and `topic` (`m.room.name` and + /// `m.room.topic` /// state events). /// - /// 7. Invite events implied by `invite` and `invite_3pid` (`m.room.member` + /// 8. Invite events implied by `invite` and `invite_3pid` (`m.room.member` /// with /// `membership: invite` and `m.room.third_party_invite`). /// @@ -190,7 +198,8 @@ public: * would be `#foo:example.com`. * * The complete room alias will become the canonical alias for - * the room. + * the room and an `m.room.canonical_alias` event will be sent + * into the room. * * \param name * If this is included, an `m.room.name` event will be sent @@ -218,9 +227,10 @@ public: * * \param creationContent * Extra keys, such as `m.federate`, to be added to the content - * of the [`m.room.create`](client-server-api/#mroomcreate) event. The - * server will clobber the following keys: `creator`, `room_version`. Future - * versions of the specification may allow the server to clobber other keys. + * of the [`m.room.create`](/client-server-api/#mroomcreate) event. The + * server will overwrite the following keys: `creator`, `room_version`. + * Future versions of the specification may allow the server to overwrite + * other keys. * * \param initialState * A list of state events to set in the new room. This allows @@ -229,7 +239,7 @@ public: * with type, state_key and content keys set. * * Takes precedence over events set by `preset`, but gets - * overriden by `name` and `topic` keys. + * overridden by `name` and `topic` keys. * * \param preset * Convenience parameter for setting various default state events @@ -249,7 +259,7 @@ public: * \param powerLevelContentOverride * The power level content to override in the default power level * event. This object is applied on top of the generated - * [`m.room.power_levels`](client-server-api/#mroompower_levels) + * [`m.room.power_levels`](/client-server-api/#mroompower_levels) * event content prior to it being sent to the room. Defaults to * overriding nothing. */ diff --git a/lib/csapi/cross_signing.cpp b/lib/csapi/cross_signing.cpp index 1fa0e949..c6c34772 100644 --- a/lib/csapi/cross_signing.cpp +++ b/lib/csapi/cross_signing.cpp @@ -9,9 +9,10 @@ using namespace Quotient; UploadCrossSigningKeysJob::UploadCrossSigningKeysJob( const Omittable& masterKey, const Omittable& selfSigningKey, - const Omittable& userSigningKey) + const Omittable& userSigningKey, + const Omittable& auth) : BaseJob(HttpVerb::Post, QStringLiteral("UploadCrossSigningKeysJob"), - makePath("/_matrix/client/r0", "/keys/device_signing/upload")) + makePath("/_matrix/client/v3", "/keys/device_signing/upload")) { QJsonObject _data; addParam(_data, QStringLiteral("master_key"), masterKey); @@ -19,13 +20,14 @@ UploadCrossSigningKeysJob::UploadCrossSigningKeysJob( selfSigningKey); addParam(_data, QStringLiteral("user_signing_key"), userSigningKey); + addParam(_data, QStringLiteral("auth"), auth); setRequestData(std::move(_data)); } UploadCrossSigningSignaturesJob::UploadCrossSigningSignaturesJob( const QHash>& signatures) : BaseJob(HttpVerb::Post, QStringLiteral("UploadCrossSigningSignaturesJob"), - makePath("/_matrix/client/r0", "/keys/signatures/upload")) + makePath("/_matrix/client/v3", "/keys/signatures/upload")) { setRequestData(RequestData(toJson(signatures))); } diff --git a/lib/csapi/cross_signing.h b/lib/csapi/cross_signing.h index 617b61d1..6cea73e6 100644 --- a/lib/csapi/cross_signing.h +++ b/lib/csapi/cross_signing.h @@ -4,6 +4,7 @@ #pragma once +#include "csapi/definitions/auth_data.h" #include "csapi/definitions/cross_signing_key.h" #include "jobs/basejob.h" @@ -35,11 +36,16 @@ public: * the accompanying master key, or by the user\'s most recently * uploaded master key if no master key is included in the * request. + * + * \param auth + * Additional authentication information for the + * user-interactive authentication API. */ explicit UploadCrossSigningKeysJob( const Omittable& masterKey = none, const Omittable& selfSigningKey = none, - const Omittable& userSigningKey = none); + const Omittable& userSigningKey = none, + const Omittable& auth = none); }; /*! \brief Upload cross-signing signatures. @@ -55,7 +61,7 @@ public: * The signatures to be published. */ explicit UploadCrossSigningSignaturesJob( - const QHash>& signatures = {}); + const QHash>& signatures); // Result properties diff --git a/lib/csapi/definitions/auth_data.h b/lib/csapi/definitions/auth_data.h index e92596d0..a9972323 100644 --- a/lib/csapi/definitions/auth_data.h +++ b/lib/csapi/definitions/auth_data.h @@ -10,7 +10,10 @@ namespace Quotient { /// Used by clients to submit authentication information to the /// interactive-authentication API struct AuthenticationData { - /// The login type that the client is attempting to complete. + /// The authentication type that the client is attempting to complete. + /// May be omitted if `session` is given, and the client is reissuing a + /// request which it believes has been completed out-of-band (for example, + /// via the [fallback mechanism](#fallback)). QString type; /// The value of the session key given by the homeserver. @@ -25,7 +28,7 @@ struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const AuthenticationData& pod) { fillJson(jo, pod.authInfo); - addParam<>(jo, QStringLiteral("type"), pod.type); + addParam(jo, QStringLiteral("type"), pod.type); addParam(jo, QStringLiteral("session"), pod.session); } static void fillFrom(QJsonObject jo, AuthenticationData& pod) diff --git a/lib/csapi/definitions/openid_token.h b/lib/csapi/definitions/openid_token.h index 3c447321..9b026dea 100644 --- a/lib/csapi/definitions/openid_token.h +++ b/lib/csapi/definitions/openid_token.h @@ -8,7 +8,7 @@ namespace Quotient { -struct OpenidToken { +struct OpenIdCredentials { /// An access token the consumer may use to verify the identity of /// the person who generated the token. This is given to the federation /// API `GET /openid/userinfo` to verify the user's identity. @@ -27,8 +27,8 @@ struct OpenidToken { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const OpenidToken& pod) +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const OpenIdCredentials& pod) { addParam<>(jo, QStringLiteral("access_token"), pod.accessToken); addParam<>(jo, QStringLiteral("token_type"), pod.tokenType); @@ -36,7 +36,7 @@ struct JsonObjectConverter { pod.matrixServerName); addParam<>(jo, QStringLiteral("expires_in"), pod.expiresIn); } - static void fillFrom(const QJsonObject& jo, OpenidToken& pod) + static void fillFrom(const QJsonObject& jo, OpenIdCredentials& pod) { fromJson(jo.value("access_token"_ls), pod.accessToken); fromJson(jo.value("token_type"_ls), pod.tokenType); diff --git a/lib/csapi/definitions/public_rooms_chunk.h b/lib/csapi/definitions/public_rooms_chunk.h new file mode 100644 index 00000000..eac68213 --- /dev/null +++ b/lib/csapi/definitions/public_rooms_chunk.h @@ -0,0 +1,73 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "converters.h" + +namespace Quotient { + +struct PublicRoomsChunk { + /// The canonical alias of the room, if any. + QString canonicalAlias; + + /// The name of the room, if any. + QString name; + + /// The number of members joined to the room. + int numJoinedMembers; + + /// The ID of the room. + QString roomId; + + /// The topic of the room, if any. + QString topic; + + /// Whether the room may be viewed by guest users without joining. + bool worldReadable; + + /// Whether guest users may join the room and participate in it. + /// If they can, they will be subject to ordinary power level + /// rules like any other user. + bool guestCanJoin; + + /// The URL for the room's avatar, if one is set. + QUrl avatarUrl; + + /// The room's join rule. When not present, the room is assumed to + /// be `public`. + QString joinRule; +}; + +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const PublicRoomsChunk& pod) + { + addParam(jo, QStringLiteral("canonical_alias"), + pod.canonicalAlias); + addParam(jo, QStringLiteral("name"), pod.name); + addParam<>(jo, QStringLiteral("num_joined_members"), + pod.numJoinedMembers); + addParam<>(jo, QStringLiteral("room_id"), pod.roomId); + addParam(jo, QStringLiteral("topic"), pod.topic); + addParam<>(jo, QStringLiteral("world_readable"), pod.worldReadable); + addParam<>(jo, QStringLiteral("guest_can_join"), pod.guestCanJoin); + addParam(jo, QStringLiteral("avatar_url"), pod.avatarUrl); + addParam(jo, QStringLiteral("join_rule"), pod.joinRule); + } + static void fillFrom(const QJsonObject& jo, PublicRoomsChunk& pod) + { + fromJson(jo.value("canonical_alias"_ls), pod.canonicalAlias); + fromJson(jo.value("name"_ls), pod.name); + fromJson(jo.value("num_joined_members"_ls), pod.numJoinedMembers); + fromJson(jo.value("room_id"_ls), pod.roomId); + fromJson(jo.value("topic"_ls), pod.topic); + fromJson(jo.value("world_readable"_ls), pod.worldReadable); + fromJson(jo.value("guest_can_join"_ls), pod.guestCanJoin); + fromJson(jo.value("avatar_url"_ls), pod.avatarUrl); + fromJson(jo.value("join_rule"_ls), pod.joinRule); + } +}; + +} // namespace Quotient diff --git a/lib/csapi/definitions/public_rooms_response.h b/lib/csapi/definitions/public_rooms_response.h index 2938b4ec..ca512280 100644 --- a/lib/csapi/definitions/public_rooms_response.h +++ b/lib/csapi/definitions/public_rooms_response.h @@ -6,81 +6,13 @@ #include "converters.h" -namespace Quotient { - -struct PublicRoomsChunk { - /// Aliases of the room. May be empty. - QStringList aliases; - - /// The canonical alias of the room, if any. - QString canonicalAlias; - - /// The name of the room, if any. - QString name; - - /// The number of members joined to the room. - int numJoinedMembers; - - /// The ID of the room. - QString roomId; - - /// The topic of the room, if any. - QString topic; - - /// Whether the room may be viewed by guest users without joining. - bool worldReadable; - - /// Whether guest users may join the room and participate in it. - /// If they can, they will be subject to ordinary power level - /// rules like any other user. - bool guestCanJoin; - - /// The URL for the room's avatar, if one is set. - QUrl avatarUrl; - - /// The room's join rule. When not present, the room is assumed to - /// be `public`. Note that rooms with `invite` join rules are not - /// expected here, but rooms with `knock` rules are given their - /// near-public nature. - QString joinRule; -}; - -template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const PublicRoomsChunk& pod) - { - addParam(jo, QStringLiteral("aliases"), pod.aliases); - addParam(jo, QStringLiteral("canonical_alias"), - pod.canonicalAlias); - addParam(jo, QStringLiteral("name"), pod.name); - addParam<>(jo, QStringLiteral("num_joined_members"), - pod.numJoinedMembers); - addParam<>(jo, QStringLiteral("room_id"), pod.roomId); - addParam(jo, QStringLiteral("topic"), pod.topic); - addParam<>(jo, QStringLiteral("world_readable"), pod.worldReadable); - addParam<>(jo, QStringLiteral("guest_can_join"), pod.guestCanJoin); - addParam(jo, QStringLiteral("avatar_url"), pod.avatarUrl); - addParam(jo, QStringLiteral("join_rule"), pod.joinRule); - } - static void fillFrom(const QJsonObject& jo, PublicRoomsChunk& pod) - { - fromJson(jo.value("aliases"_ls), pod.aliases); - fromJson(jo.value("canonical_alias"_ls), pod.canonicalAlias); - fromJson(jo.value("name"_ls), pod.name); - fromJson(jo.value("num_joined_members"_ls), pod.numJoinedMembers); - fromJson(jo.value("room_id"_ls), pod.roomId); - fromJson(jo.value("topic"_ls), pod.topic); - fromJson(jo.value("world_readable"_ls), pod.worldReadable); - fromJson(jo.value("guest_can_join"_ls), pod.guestCanJoin); - fromJson(jo.value("avatar_url"_ls), pod.avatarUrl); - fromJson(jo.value("join_rule"_ls), pod.joinRule); - } -}; +#include "csapi/definitions/public_rooms_chunk.h" +namespace Quotient { /// A list of the rooms on the server. struct PublicRoomsResponse { /// A paginated chunk of public rooms. - QVector chunk; + QVector chunk; /// A pagination token for the response. The absence of this token /// means there are no more results to fetch and the client should diff --git a/lib/csapi/definitions/push_condition.h b/lib/csapi/definitions/push_condition.h index ce66d075..6a048ba8 100644 --- a/lib/csapi/definitions/push_condition.h +++ b/lib/csapi/definitions/push_condition.h @@ -24,9 +24,7 @@ struct PushCondition { QString key; /// Required for `event_match` conditions. The glob-style pattern to - /// match against. Patterns with no special glob characters should be - /// treated as having asterisks prepended and appended when testing the - /// condition. + /// match against. QString pattern; /// Required for `room_member_count` conditions. A decimal integer diff --git a/lib/csapi/device_management.cpp b/lib/csapi/device_management.cpp index da6dbc76..fb58633c 100644 --- a/lib/csapi/device_management.cpp +++ b/lib/csapi/device_management.cpp @@ -9,30 +9,30 @@ using namespace Quotient; QUrl GetDevicesJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/devices")); + makePath("/_matrix/client/v3", "/devices")); } GetDevicesJob::GetDevicesJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetDevicesJob"), - makePath("/_matrix/client/r0", "/devices")) + makePath("/_matrix/client/v3", "/devices")) {} QUrl GetDeviceJob::makeRequestUrl(QUrl baseUrl, const QString& deviceId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/devices/", + makePath("/_matrix/client/v3", "/devices/", deviceId)); } GetDeviceJob::GetDeviceJob(const QString& deviceId) : BaseJob(HttpVerb::Get, QStringLiteral("GetDeviceJob"), - makePath("/_matrix/client/r0", "/devices/", deviceId)) + makePath("/_matrix/client/v3", "/devices/", deviceId)) {} UpdateDeviceJob::UpdateDeviceJob(const QString& deviceId, const QString& displayName) : BaseJob(HttpVerb::Put, QStringLiteral("UpdateDeviceJob"), - makePath("/_matrix/client/r0", "/devices/", deviceId)) + makePath("/_matrix/client/v3", "/devices/", deviceId)) { QJsonObject _data; addParam(_data, QStringLiteral("display_name"), displayName); @@ -42,7 +42,7 @@ UpdateDeviceJob::UpdateDeviceJob(const QString& deviceId, DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, const Omittable& auth) : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteDeviceJob"), - makePath("/_matrix/client/r0", "/devices/", deviceId)) + makePath("/_matrix/client/v3", "/devices/", deviceId)) { QJsonObject _data; addParam(_data, QStringLiteral("auth"), auth); @@ -52,7 +52,7 @@ DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, DeleteDevicesJob::DeleteDevicesJob(const QStringList& devices, const Omittable& auth) : BaseJob(HttpVerb::Post, QStringLiteral("DeleteDevicesJob"), - makePath("/_matrix/client/r0", "/delete_devices")) + makePath("/_matrix/client/v3", "/delete_devices")) { QJsonObject _data; addParam<>(_data, QStringLiteral("devices"), devices); diff --git a/lib/csapi/device_management.h b/lib/csapi/device_management.h index 430d2132..c10389b3 100644 --- a/lib/csapi/device_management.h +++ b/lib/csapi/device_management.h @@ -86,7 +86,8 @@ public: * This API endpoint uses the [User-Interactive Authentication * API](/client-server-api/#user-interactive-authentication-api). * - * Deletes the given device, and invalidates any access token associated with it. + * Deletes the given device, and invalidates any access token associated with + * it. */ class QUOTIENT_API DeleteDeviceJob : public BaseJob { public: diff --git a/lib/csapi/directory.cpp b/lib/csapi/directory.cpp index b351b4ef..86b14f3a 100644 --- a/lib/csapi/directory.cpp +++ b/lib/csapi/directory.cpp @@ -8,7 +8,7 @@ using namespace Quotient; SetRoomAliasJob::SetRoomAliasJob(const QString& roomAlias, const QString& roomId) : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomAliasJob"), - makePath("/_matrix/client/r0", "/directory/room/", roomAlias)) + makePath("/_matrix/client/v3", "/directory/room/", roomAlias)) { QJsonObject _data; addParam<>(_data, QStringLiteral("room_id"), roomId); @@ -18,38 +18,38 @@ SetRoomAliasJob::SetRoomAliasJob(const QString& roomAlias, const QString& roomId QUrl GetRoomIdByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/directory/room/", roomAlias)); } GetRoomIdByAliasJob::GetRoomIdByAliasJob(const QString& roomAlias) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomIdByAliasJob"), - makePath("/_matrix/client/r0", "/directory/room/", roomAlias), + makePath("/_matrix/client/v3", "/directory/room/", roomAlias), false) {} QUrl DeleteRoomAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/directory/room/", roomAlias)); } DeleteRoomAliasJob::DeleteRoomAliasJob(const QString& roomAlias) : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteRoomAliasJob"), - makePath("/_matrix/client/r0", "/directory/room/", roomAlias)) + makePath("/_matrix/client/v3", "/directory/room/", roomAlias)) {} QUrl GetLocalAliasesJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/rooms/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/aliases")); } GetLocalAliasesJob::GetLocalAliasesJob(const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetLocalAliasesJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/aliases")) + makePath("/_matrix/client/v3", "/rooms/", roomId, "/aliases")) { addExpectedKey("aliases"); } diff --git a/lib/csapi/event_context.cpp b/lib/csapi/event_context.cpp index 877838e2..4ebbbf98 100644 --- a/lib/csapi/event_context.cpp +++ b/lib/csapi/event_context.cpp @@ -20,7 +20,7 @@ QUrl GetEventContextJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& filter) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/rooms/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/context/", eventId), queryToGetEventContext(limit, filter)); } @@ -30,7 +30,7 @@ GetEventContextJob::GetEventContextJob(const QString& roomId, Omittable limit, const QString& filter) : BaseJob(HttpVerb::Get, QStringLiteral("GetEventContextJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/context/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/context/", eventId), queryToGetEventContext(limit, filter)) {} diff --git a/lib/csapi/filter.cpp b/lib/csapi/filter.cpp index 38c68be7..57cb1271 100644 --- a/lib/csapi/filter.cpp +++ b/lib/csapi/filter.cpp @@ -8,7 +8,7 @@ using namespace Quotient; DefineFilterJob::DefineFilterJob(const QString& userId, const Filter& filter) : BaseJob(HttpVerb::Post, QStringLiteral("DefineFilterJob"), - makePath("/_matrix/client/r0", "/user/", userId, "/filter")) + makePath("/_matrix/client/v3", "/user/", userId, "/filter")) { setRequestData(RequestData(toJson(filter))); addExpectedKey("filter_id"); @@ -18,12 +18,12 @@ QUrl GetFilterJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& filterId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/user/", + makePath("/_matrix/client/v3", "/user/", userId, "/filter/", filterId)); } GetFilterJob::GetFilterJob(const QString& userId, const QString& filterId) : BaseJob(HttpVerb::Get, QStringLiteral("GetFilterJob"), - makePath("/_matrix/client/r0", "/user/", userId, "/filter/", + makePath("/_matrix/client/v3", "/user/", userId, "/filter/", filterId)) {} diff --git a/lib/csapi/inviting.cpp b/lib/csapi/inviting.cpp index 39d24611..bc1863ce 100644 --- a/lib/csapi/inviting.cpp +++ b/lib/csapi/inviting.cpp @@ -9,7 +9,7 @@ using namespace Quotient; InviteUserJob::InviteUserJob(const QString& roomId, const QString& userId, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("InviteUserJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/invite")) + makePath("/_matrix/client/v3", "/rooms/", roomId, "/invite")) { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); diff --git a/lib/csapi/inviting.h b/lib/csapi/inviting.h index 21e6cb74..cb9d052b 100644 --- a/lib/csapi/inviting.h +++ b/lib/csapi/inviting.h @@ -14,7 +14,7 @@ namespace Quotient { * This version of the API requires that the inviter knows the Matrix * identifier of the invitee. The other is documented in the* * [third party invites - * section](/client-server-api/#post_matrixclientr0roomsroomidinvite-1). + * section](/client-server-api/#post_matrixclientv3roomsroomidinvite-1). * * This API invites a user to participate in a particular room. * They do not start participating in the room until they actually join the diff --git a/lib/csapi/joining.cpp b/lib/csapi/joining.cpp index 373c1c6a..b05bd964 100644 --- a/lib/csapi/joining.cpp +++ b/lib/csapi/joining.cpp @@ -10,7 +10,7 @@ JoinRoomByIdJob::JoinRoomByIdJob( const QString& roomId, const Omittable& thirdPartySigned, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("JoinRoomByIdJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/join")) + makePath("/_matrix/client/v3", "/rooms/", roomId, "/join")) { QJsonObject _data; addParam(_data, QStringLiteral("third_party_signed"), @@ -32,7 +32,7 @@ JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, const Omittable& thirdPartySigned, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("JoinRoomJob"), - makePath("/_matrix/client/r0", "/join/", roomIdOrAlias), + makePath("/_matrix/client/v3", "/join/", roomIdOrAlias), queryToJoinRoom(serverName)) { QJsonObject _data; diff --git a/lib/csapi/joining.h b/lib/csapi/joining.h index f64152f7..233537bb 100644 --- a/lib/csapi/joining.h +++ b/lib/csapi/joining.h @@ -22,8 +22,8 @@ namespace Quotient { * * After a user has joined a room, the room will appear as an entry in the * response of the - * [`/initialSync`](/client-server-api/#get_matrixclientr0initialsync) and - * [`/sync`](/client-server-api/#get_matrixclientr0sync) APIs. + * [`/initialSync`](/client-server-api/#get_matrixclientv3initialsync) and + * [`/sync`](/client-server-api/#get_matrixclientv3sync) APIs. */ class QUOTIENT_API JoinRoomByIdJob : public BaseJob { public: @@ -64,8 +64,8 @@ public: * * After a user has joined a room, the room will appear as an entry in the * response of the - * [`/initialSync`](/client-server-api/#get_matrixclientr0initialsync) and - * [`/sync`](/client-server-api/#get_matrixclientr0sync) APIs. + * [`/initialSync`](/client-server-api/#get_matrixclientv3initialsync) and + * [`/sync`](/client-server-api/#get_matrixclientv3sync) APIs. */ class QUOTIENT_API JoinRoomJob : public BaseJob { public: diff --git a/lib/csapi/keys.cpp b/lib/csapi/keys.cpp index d6bd2fab..d4996664 100644 --- a/lib/csapi/keys.cpp +++ b/lib/csapi/keys.cpp @@ -7,13 +7,15 @@ using namespace Quotient; UploadKeysJob::UploadKeysJob(const Omittable& deviceKeys, - const QHash& oneTimeKeys) + const OneTimeKeys& oneTimeKeys, + const OneTimeKeys& fallbackKeys) : BaseJob(HttpVerb::Post, QStringLiteral("UploadKeysJob"), - makePath("/_matrix/client/r0", "/keys/upload")) + makePath("/_matrix/client/v3", "/keys/upload")) { QJsonObject _data; addParam(_data, QStringLiteral("device_keys"), deviceKeys); addParam(_data, QStringLiteral("one_time_keys"), oneTimeKeys); + addParam(_data, QStringLiteral("fallback_keys"), fallbackKeys); setRequestData(std::move(_data)); addExpectedKey("one_time_key_counts"); } @@ -21,7 +23,7 @@ UploadKeysJob::UploadKeysJob(const Omittable& deviceKeys, QueryKeysJob::QueryKeysJob(const QHash& deviceKeys, Omittable timeout, const QString& token) : BaseJob(HttpVerb::Post, QStringLiteral("QueryKeysJob"), - makePath("/_matrix/client/r0", "/keys/query")) + makePath("/_matrix/client/v3", "/keys/query")) { QJsonObject _data; addParam(_data, QStringLiteral("timeout"), timeout); @@ -34,7 +36,7 @@ ClaimKeysJob::ClaimKeysJob( const QHash>& oneTimeKeys, Omittable timeout) : BaseJob(HttpVerb::Post, QStringLiteral("ClaimKeysJob"), - makePath("/_matrix/client/r0", "/keys/claim")) + makePath("/_matrix/client/v3", "/keys/claim")) { QJsonObject _data; addParam(_data, QStringLiteral("timeout"), timeout); @@ -55,13 +57,13 @@ QUrl GetKeysChangesJob::makeRequestUrl(QUrl baseUrl, const QString& from, const QString& to) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/keys/changes"), queryToGetKeysChanges(from, to)); } GetKeysChangesJob::GetKeysChangesJob(const QString& from, const QString& to) : BaseJob(HttpVerb::Get, QStringLiteral("GetKeysChangesJob"), - makePath("/_matrix/client/r0", "/keys/changes"), + makePath("/_matrix/client/v3", "/keys/changes"), queryToGetKeysChanges(from, to)) {} diff --git a/lib/csapi/keys.h b/lib/csapi/keys.h index ce1ca9ed..2f2ebc6d 100644 --- a/lib/csapi/keys.h +++ b/lib/csapi/keys.h @@ -4,6 +4,8 @@ #pragma once +#include "e2ee/e2ee.h" + #include "csapi/definitions/cross_signing_key.h" #include "csapi/definitions/device_keys.h" @@ -30,14 +32,32 @@ public: * by the [key algorithm](/client-server-api/#key-algorithms). * * May be absent if no new one-time keys are required. + * + * \param fallbackKeys + * The public key which should be used if the device's one-time keys + * are exhausted. The fallback key is not deleted once used, but should + * be replaced when additional one-time keys are being uploaded. The + * server will notify the client of the fallback key being used through + * `/sync`. + * + * There can only be at most one key per algorithm uploaded, and the + * server will only persist one key per algorithm. + * + * When uploading a signed key, an additional `fallback: true` key should + * be included to denote that the key is a fallback key. + * + * May be absent if a new fallback key is not required. */ explicit UploadKeysJob(const Omittable& deviceKeys = none, - const QHash& oneTimeKeys = {}); + const OneTimeKeys& oneTimeKeys = {}, + const OneTimeKeys& fallbackKeys = {}); // Result properties /// For each key algorithm, the number of unclaimed one-time keys /// of that type currently held on the server for this device. + /// If an algorithm is not listed, the count for that algorithm + /// is to be assumed zero. QHash oneTimeKeyCounts() const { return loadFromJson>("one_time_key_counts"_ls); @@ -207,9 +227,12 @@ public: /// /// See the [key algorithms](/client-server-api/#key-algorithms) section for /// information on the Key Object format. - QHash> oneTimeKeys() const + /// + /// If necessary, the claimed key might be a fallback key. Fallback + /// keys are re-used by the server until replaced by the device. + QHash> oneTimeKeys() const { - return loadFromJson>>( + return loadFromJson>>( "one_time_keys"_ls); } }; @@ -233,7 +256,7 @@ public: * \param from * The desired start point of the list. Should be the `next_batch` field * from a response to an earlier call to - * [`/sync`](/client-server-api/#get_matrixclientr0sync). Users who have not + * [`/sync`](/client-server-api/#get_matrixclientv3sync). Users who have not * uploaded new device identity keys since this point, nor deleted * existing devices with identity keys since then, will be excluded * from the results. @@ -241,7 +264,7 @@ public: * \param to * The desired end point of the list. Should be the `next_batch` * field from a recent call to - * [`/sync`](/client-server-api/#get_matrixclientr0sync) - typically the + * [`/sync`](/client-server-api/#get_matrixclientv3sync) - typically the * most recent such call. This may be used by the server as a hint to check * its caches are up to date. */ diff --git a/lib/csapi/kicking.cpp b/lib/csapi/kicking.cpp index 433e592c..3bedcb34 100644 --- a/lib/csapi/kicking.cpp +++ b/lib/csapi/kicking.cpp @@ -9,7 +9,7 @@ using namespace Quotient; KickJob::KickJob(const QString& roomId, const QString& userId, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("KickJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/kick")) + makePath("/_matrix/client/v3", "/rooms/", roomId, "/kick")) { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); diff --git a/lib/csapi/knocking.cpp b/lib/csapi/knocking.cpp index 73e13e6e..ba541643 100644 --- a/lib/csapi/knocking.cpp +++ b/lib/csapi/knocking.cpp @@ -16,7 +16,7 @@ auto queryToKnockRoom(const QStringList& serverName) KnockRoomJob::KnockRoomJob(const QString& roomIdOrAlias, const QStringList& serverName, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("KnockRoomJob"), - makePath("/_matrix/client/r0", "/knock/", roomIdOrAlias), + makePath("/_matrix/client/v3", "/knock/", roomIdOrAlias), queryToKnockRoom(serverName)) { QJsonObject _data; diff --git a/lib/csapi/knocking.h b/lib/csapi/knocking.h index e3645b59..f43033a8 100644 --- a/lib/csapi/knocking.h +++ b/lib/csapi/knocking.h @@ -25,7 +25,7 @@ namespace Quotient { * history visibility to the user. * * The knock will appear as an entry in the response of the - * [`/sync`](/client-server-api/#get_matrixclientr0sync) API. + * [`/sync`](/client-server-api/#get_matrixclientv3sync) API. */ class QUOTIENT_API KnockRoomJob : public BaseJob { public: diff --git a/lib/csapi/leaving.cpp b/lib/csapi/leaving.cpp index 0e5386be..84340b94 100644 --- a/lib/csapi/leaving.cpp +++ b/lib/csapi/leaving.cpp @@ -8,7 +8,7 @@ using namespace Quotient; LeaveRoomJob::LeaveRoomJob(const QString& roomId, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("LeaveRoomJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/leave")) + makePath("/_matrix/client/v3", "/rooms/", roomId, "/leave")) { QJsonObject _data; addParam(_data, QStringLiteral("reason"), reason); @@ -18,11 +18,11 @@ LeaveRoomJob::LeaveRoomJob(const QString& roomId, const QString& reason) QUrl ForgetRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/rooms/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/forget")); } ForgetRoomJob::ForgetRoomJob(const QString& roomId) : BaseJob(HttpVerb::Post, QStringLiteral("ForgetRoomJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/forget")) + makePath("/_matrix/client/v3", "/rooms/", roomId, "/forget")) {} diff --git a/lib/csapi/list_joined_rooms.cpp b/lib/csapi/list_joined_rooms.cpp index 22ba04da..cdcf3eb2 100644 --- a/lib/csapi/list_joined_rooms.cpp +++ b/lib/csapi/list_joined_rooms.cpp @@ -9,12 +9,12 @@ using namespace Quotient; QUrl GetJoinedRoomsJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl( - std::move(baseUrl), makePath("/_matrix/client/r0", "/joined_rooms")); + std::move(baseUrl), makePath("/_matrix/client/v3", "/joined_rooms")); } GetJoinedRoomsJob::GetJoinedRoomsJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetJoinedRoomsJob"), - makePath("/_matrix/client/r0", "/joined_rooms")) + makePath("/_matrix/client/v3", "/joined_rooms")) { addExpectedKey("joined_rooms"); } diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp index 25f8da5c..417e50b3 100644 --- a/lib/csapi/list_public_rooms.cpp +++ b/lib/csapi/list_public_rooms.cpp @@ -10,21 +10,21 @@ QUrl GetRoomVisibilityOnDirectoryJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/directory/list/room/", roomId)); } GetRoomVisibilityOnDirectoryJob::GetRoomVisibilityOnDirectoryJob( const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomVisibilityOnDirectoryJob"), - makePath("/_matrix/client/r0", "/directory/list/room/", roomId), + makePath("/_matrix/client/v3", "/directory/list/room/", roomId), false) {} SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob( const QString& roomId, const QString& visibility) : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomVisibilityOnDirectoryJob"), - makePath("/_matrix/client/r0", "/directory/list/room/", roomId)) + makePath("/_matrix/client/v3", "/directory/list/room/", roomId)) { QJsonObject _data; addParam(_data, QStringLiteral("visibility"), visibility); @@ -46,7 +46,7 @@ QUrl GetPublicRoomsJob::makeRequestUrl(QUrl baseUrl, Omittable limit, const QString& server) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/publicRooms"), queryToGetPublicRooms(limit, since, server)); } @@ -54,7 +54,7 @@ QUrl GetPublicRoomsJob::makeRequestUrl(QUrl baseUrl, Omittable limit, GetPublicRoomsJob::GetPublicRoomsJob(Omittable limit, const QString& since, const QString& server) : BaseJob(HttpVerb::Get, QStringLiteral("GetPublicRoomsJob"), - makePath("/_matrix/client/r0", "/publicRooms"), + makePath("/_matrix/client/v3", "/publicRooms"), queryToGetPublicRooms(limit, since, server), {}, false) { addExpectedKey("chunk"); @@ -74,7 +74,7 @@ QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, Omittable includeAllNetworks, const QString& thirdPartyInstanceId) : BaseJob(HttpVerb::Post, QStringLiteral("QueryPublicRoomsJob"), - makePath("/_matrix/client/r0", "/publicRooms"), + makePath("/_matrix/client/v3", "/publicRooms"), queryToQueryPublicRooms(server)) { QJsonObject _data; diff --git a/lib/csapi/list_public_rooms.h b/lib/csapi/list_public_rooms.h index e1f03db7..701a74f6 100644 --- a/lib/csapi/list_public_rooms.h +++ b/lib/csapi/list_public_rooms.h @@ -4,7 +4,7 @@ #pragma once -#include "csapi/definitions/public_rooms_response.h" +#include "csapi/definitions/public_rooms_chunk.h" #include "jobs/basejob.h" @@ -103,9 +103,9 @@ public: // Result properties /// A paginated chunk of public rooms. - QVector chunk() const + QVector chunk() const { - return loadFromJson>("chunk"_ls); + return loadFromJson>("chunk"_ls); } /// A pagination token for the response. The absence of this token @@ -182,9 +182,9 @@ public: // Result properties /// A paginated chunk of public rooms. - QVector chunk() const + QVector chunk() const { - return loadFromJson>("chunk"_ls); + return loadFromJson>("chunk"_ls); } /// A pagination token for the response. The absence of this token diff --git a/lib/csapi/login.cpp b/lib/csapi/login.cpp index 71fd93c5..b2175a05 100644 --- a/lib/csapi/login.cpp +++ b/lib/csapi/login.cpp @@ -9,12 +9,12 @@ using namespace Quotient; QUrl GetLoginFlowsJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/login")); + makePath("/_matrix/client/v3", "/login")); } GetLoginFlowsJob::GetLoginFlowsJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetLoginFlowsJob"), - makePath("/_matrix/client/r0", "/login"), false) + makePath("/_matrix/client/v3", "/login"), false) {} LoginJob::LoginJob(const QString& type, @@ -23,7 +23,7 @@ LoginJob::LoginJob(const QString& type, const QString& deviceId, const QString& initialDeviceDisplayName) : BaseJob(HttpVerb::Post, QStringLiteral("LoginJob"), - makePath("/_matrix/client/r0", "/login"), false) + makePath("/_matrix/client/v3", "/login"), false) { QJsonObject _data; addParam<>(_data, QStringLiteral("type"), type); diff --git a/lib/csapi/logout.cpp b/lib/csapi/logout.cpp index e8083e31..9ec54c71 100644 --- a/lib/csapi/logout.cpp +++ b/lib/csapi/logout.cpp @@ -9,21 +9,21 @@ using namespace Quotient; QUrl LogoutJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/logout")); + makePath("/_matrix/client/v3", "/logout")); } LogoutJob::LogoutJob() : BaseJob(HttpVerb::Post, QStringLiteral("LogoutJob"), - makePath("/_matrix/client/r0", "/logout")) + makePath("/_matrix/client/v3", "/logout")) {} QUrl LogoutAllJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl( - std::move(baseUrl), makePath("/_matrix/client/r0", "/logout/all")); + std::move(baseUrl), makePath("/_matrix/client/v3", "/logout/all")); } LogoutAllJob::LogoutAllJob() : BaseJob(HttpVerb::Post, QStringLiteral("LogoutAllJob"), - makePath("/_matrix/client/r0", "/logout/all")) + makePath("/_matrix/client/v3", "/logout/all")) {} diff --git a/lib/csapi/message_pagination.cpp b/lib/csapi/message_pagination.cpp index 1a93b75b..0b2c99ce 100644 --- a/lib/csapi/message_pagination.cpp +++ b/lib/csapi/message_pagination.cpp @@ -11,7 +11,7 @@ auto queryToGetRoomEvents(const QString& from, const QString& to, const QString& filter) { QUrlQuery _q; - addParam<>(_q, QStringLiteral("from"), from); + addParam(_q, QStringLiteral("from"), from); addParam(_q, QStringLiteral("to"), to); addParam<>(_q, QStringLiteral("dir"), dir); addParam(_q, QStringLiteral("limit"), limit); @@ -20,20 +20,23 @@ auto queryToGetRoomEvents(const QString& from, const QString& to, } QUrl GetRoomEventsJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, - const QString& from, const QString& dir, + const QString& dir, const QString& from, const QString& to, Omittable limit, const QString& filter) { return BaseJob::makeRequestUrl( std::move(baseUrl), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/messages"), + makePath("/_matrix/client/v3", "/rooms/", roomId, "/messages"), queryToGetRoomEvents(from, to, dir, limit, filter)); } -GetRoomEventsJob::GetRoomEventsJob(const QString& roomId, const QString& from, - const QString& dir, const QString& to, +GetRoomEventsJob::GetRoomEventsJob(const QString& roomId, const QString& dir, + const QString& from, const QString& to, Omittable limit, const QString& filter) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomEventsJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/messages"), + makePath("/_matrix/client/v3", "/rooms/", roomId, "/messages"), queryToGetRoomEvents(from, to, dir, limit, filter)) -{} +{ + addExpectedKey("start"); + addExpectedKey("chunk"); +} diff --git a/lib/csapi/message_pagination.h b/lib/csapi/message_pagination.h index 8c18f104..9831ae2d 100644 --- a/lib/csapi/message_pagination.h +++ b/lib/csapi/message_pagination.h @@ -25,20 +25,30 @@ public: * \param roomId * The room to get events from. * + * \param dir + * The direction to return events from. If this is set to `f`, events + * will be returned in chronological order starting at `from`. If it + * is set to `b`, events will be returned in *reverse* chronological + * order, again starting at `from`. + * * \param from * The token to start returning events from. This token can be obtained - * from a `prev_batch` token returned for each room by the sync API, - * or from a `start` or `end` token returned by a previous request - * to this endpoint. + * from a `prev_batch` or `next_batch` token returned by the `/sync` + * endpoint, or from an `end` token returned by a previous request to this + * endpoint. * - * \param dir - * The direction to return events from. + * This endpoint can also accept a value returned as a `start` token + * by a previous request to this endpoint, though servers are not + * required to support this. Clients should not rely on the behaviour. + * + * If it is not provided, the homeserver shall return a list of messages + * from the first or last (per the value of the `dir` parameter) visible + * event in the room history for the requesting user. * * \param to * The token to stop returning events at. This token can be obtained from - * a `prev_batch` token returned for each room by the sync endpoint, - * or from a `start` or `end` token returned by a previous request to - * this endpoint. + * a `prev_batch` or `next_batch` token returned by the `/sync` endpoint, + * or from an `end` token returned by a previous request to this endpoint. * * \param limit * The maximum number of events to return. Default: 10. @@ -46,8 +56,8 @@ public: * \param filter * A JSON RoomEventFilter to filter returned events with. */ - explicit GetRoomEventsJob(const QString& roomId, const QString& from, - const QString& dir, const QString& to = {}, + explicit GetRoomEventsJob(const QString& roomId, const QString& dir, + const QString& from = {}, const QString& to = {}, Omittable limit = none, const QString& filter = {}); @@ -57,25 +67,34 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, - const QString& from, const QString& dir, + const QString& dir, const QString& from = {}, const QString& to = {}, Omittable limit = none, const QString& filter = {}); // Result properties - /// The token the pagination starts from. If `dir=b` this will be - /// the token supplied in `from`. + /// A token corresponding to the start of `chunk`. This will be the same as + /// the value given in `from`. QString begin() const { return loadFromJson("start"_ls); } - /// The token the pagination ends at. If `dir=b` this token should - /// be used again to request even earlier events. + /// A token corresponding to the end of `chunk`. This token can be passed + /// back to this endpoint to request further events. + /// + /// If no further events are available (either because we have + /// reached the start of the timeline, or because the user does + /// not have permission to see any more events), this property + /// is omitted from the response. QString end() const { return loadFromJson("end"_ls); } /// A list of room events. The order depends on the `dir` parameter. /// For `dir=b` events will be in reverse-chronological order, - /// for `dir=f` in chronological order, so that events start - /// at the `from` point. + /// for `dir=f` in chronological order. (The exact definition of + /// `chronological` is dependent on the server implementation.) + /// + /// Note that an empty `chunk` does not *necessarily* imply that no more + /// events are available. Clients should continue to paginate until no `end` + /// property is returned. RoomEvents chunk() { return takeFromJson("chunk"_ls); } /// A list of state events relevant to showing the `chunk`. For example, if @@ -86,7 +105,7 @@ public: /// may remove membership events which would have already been /// sent to the client in prior calls to this endpoint, assuming /// the membership of those members has not changed. - StateEvents state() { return takeFromJson("state"_ls); } + RoomEvents state() { return takeFromJson("state"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/notifications.cpp b/lib/csapi/notifications.cpp index 1e523c6f..38aed174 100644 --- a/lib/csapi/notifications.cpp +++ b/lib/csapi/notifications.cpp @@ -21,7 +21,7 @@ QUrl GetNotificationsJob::makeRequestUrl(QUrl baseUrl, const QString& from, const QString& only) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/notifications"), queryToGetNotifications(from, limit, only)); } @@ -30,7 +30,7 @@ GetNotificationsJob::GetNotificationsJob(const QString& from, Omittable limit, const QString& only) : BaseJob(HttpVerb::Get, QStringLiteral("GetNotificationsJob"), - makePath("/_matrix/client/r0", "/notifications"), + makePath("/_matrix/client/v3", "/notifications"), queryToGetNotifications(from, limit, only)) { addExpectedKey("notifications"); diff --git a/lib/csapi/notifications.h b/lib/csapi/notifications.h index 23211758..48167877 100644 --- a/lib/csapi/notifications.h +++ b/lib/csapi/notifications.h @@ -43,7 +43,8 @@ public: /*! \brief Gets a list of events that the user has been notified about * * \param from - * Pagination token given to retrieve the next set of events. + * Pagination token to continue from. This should be the `next_token` + * returned from an earlier call to this endpoint. * * \param limit * Limit on the number of events to return in this request. diff --git a/lib/csapi/openid.cpp b/lib/csapi/openid.cpp index 5c93a2d7..8349e6db 100644 --- a/lib/csapi/openid.cpp +++ b/lib/csapi/openid.cpp @@ -9,7 +9,7 @@ using namespace Quotient; RequestOpenIdTokenJob::RequestOpenIdTokenJob(const QString& userId, const QJsonObject& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestOpenIdTokenJob"), - makePath("/_matrix/client/r0", "/user/", userId, + makePath("/_matrix/client/v3", "/user/", userId, "/openid/request_token")) { setRequestData(RequestData(toJson(body))); diff --git a/lib/csapi/openid.h b/lib/csapi/openid.h index 773b6011..b3f72a25 100644 --- a/lib/csapi/openid.h +++ b/lib/csapi/openid.h @@ -43,7 +43,10 @@ public: /// Specification](http://openid.net/specs/openid-connect-core-1_0.html#TokenResponse) /// with the only difference being the lack of an `id_token`. Instead, /// the Matrix homeserver's name is provided. - OpenidToken tokenData() const { return fromJson(jsonData()); } + OpenIdCredentials tokenData() const + { + return fromJson(jsonData()); + } }; } // namespace Quotient diff --git a/lib/csapi/peeking_events.cpp b/lib/csapi/peeking_events.cpp index eb5d22fa..9dd1445e 100644 --- a/lib/csapi/peeking_events.cpp +++ b/lib/csapi/peeking_events.cpp @@ -20,13 +20,13 @@ QUrl PeekEventsJob::makeRequestUrl(QUrl baseUrl, const QString& from, Omittable timeout, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/events"), + makePath("/_matrix/client/v3", "/events"), queryToPeekEvents(from, timeout, roomId)); } PeekEventsJob::PeekEventsJob(const QString& from, Omittable timeout, const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("PeekEventsJob"), - makePath("/_matrix/client/r0", "/events"), + makePath("/_matrix/client/v3", "/events"), queryToPeekEvents(from, timeout, roomId)) {} diff --git a/lib/csapi/peeking_events.h b/lib/csapi/peeking_events.h index 14cb6f0b..ff688c49 100644 --- a/lib/csapi/peeking_events.h +++ b/lib/csapi/peeking_events.h @@ -9,7 +9,7 @@ namespace Quotient { -/*! \brief Listen on the event stream. +/*! \brief Listen on the event stream of a particular room. * * This will listen for new events related to a particular room and return * them to the caller. This will block until an event is received, or until @@ -24,7 +24,7 @@ namespace Quotient { */ class QUOTIENT_API PeekEventsJob : public BaseJob { public: - /*! \brief Listen on the event stream. + /*! \brief Listen on the event stream of a particular room. * * \param from * The token to stream from. This token is either from a previous diff --git a/lib/csapi/presence.cpp b/lib/csapi/presence.cpp index 4f77c466..6d154ebd 100644 --- a/lib/csapi/presence.cpp +++ b/lib/csapi/presence.cpp @@ -9,7 +9,7 @@ using namespace Quotient; SetPresenceJob::SetPresenceJob(const QString& userId, const QString& presence, const QString& statusMsg) : BaseJob(HttpVerb::Put, QStringLiteral("SetPresenceJob"), - makePath("/_matrix/client/r0", "/presence/", userId, "/status")) + makePath("/_matrix/client/v3", "/presence/", userId, "/status")) { QJsonObject _data; addParam<>(_data, QStringLiteral("presence"), presence); @@ -20,13 +20,13 @@ SetPresenceJob::SetPresenceJob(const QString& userId, const QString& presence, QUrl GetPresenceJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/presence/", + makePath("/_matrix/client/v3", "/presence/", userId, "/status")); } GetPresenceJob::GetPresenceJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetPresenceJob"), - makePath("/_matrix/client/r0", "/presence/", userId, "/status")) + makePath("/_matrix/client/v3", "/presence/", userId, "/status")) { addExpectedKey("presence"); } diff --git a/lib/csapi/profile.cpp b/lib/csapi/profile.cpp index 64ac84ca..7621d828 100644 --- a/lib/csapi/profile.cpp +++ b/lib/csapi/profile.cpp @@ -9,7 +9,8 @@ using namespace Quotient; SetDisplayNameJob::SetDisplayNameJob(const QString& userId, const QString& displayname) : BaseJob(HttpVerb::Put, QStringLiteral("SetDisplayNameJob"), - makePath("/_matrix/client/r0", "/profile/", userId, "/displayname")) + makePath("/_matrix/client/v3", "/profile/", userId, + "/displayname")) { QJsonObject _data; addParam<>(_data, QStringLiteral("displayname"), displayname); @@ -19,19 +20,20 @@ SetDisplayNameJob::SetDisplayNameJob(const QString& userId, QUrl GetDisplayNameJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/profile/", + makePath("/_matrix/client/v3", "/profile/", userId, "/displayname")); } GetDisplayNameJob::GetDisplayNameJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetDisplayNameJob"), - makePath("/_matrix/client/r0", "/profile/", userId, "/displayname"), + makePath("/_matrix/client/v3", "/profile/", userId, + "/displayname"), false) {} SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QUrl& avatarUrl) : BaseJob(HttpVerb::Put, QStringLiteral("SetAvatarUrlJob"), - makePath("/_matrix/client/r0", "/profile/", userId, "/avatar_url")) + makePath("/_matrix/client/v3", "/profile/", userId, "/avatar_url")) { QJsonObject _data; addParam<>(_data, QStringLiteral("avatar_url"), avatarUrl); @@ -41,24 +43,24 @@ SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QUrl& avatarUrl) QUrl GetAvatarUrlJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/profile/", + makePath("/_matrix/client/v3", "/profile/", userId, "/avatar_url")); } GetAvatarUrlJob::GetAvatarUrlJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetAvatarUrlJob"), - makePath("/_matrix/client/r0", "/profile/", userId, "/avatar_url"), + makePath("/_matrix/client/v3", "/profile/", userId, "/avatar_url"), false) {} QUrl GetUserProfileJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/profile/", + makePath("/_matrix/client/v3", "/profile/", userId)); } GetUserProfileJob::GetUserProfileJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetUserProfileJob"), - makePath("/_matrix/client/r0", "/profile/", userId), false) + makePath("/_matrix/client/v3", "/profile/", userId), false) {} diff --git a/lib/csapi/pusher.cpp b/lib/csapi/pusher.cpp index ef4b3767..498be3ee 100644 --- a/lib/csapi/pusher.cpp +++ b/lib/csapi/pusher.cpp @@ -9,12 +9,12 @@ using namespace Quotient; QUrl GetPushersJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/pushers")); + makePath("/_matrix/client/v3", "/pushers")); } GetPushersJob::GetPushersJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetPushersJob"), - makePath("/_matrix/client/r0", "/pushers")) + makePath("/_matrix/client/v3", "/pushers")) {} PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind, @@ -23,7 +23,7 @@ PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind, const QString& lang, const PusherData& data, const QString& profileTag, Omittable append) : BaseJob(HttpVerb::Post, QStringLiteral("PostPusherJob"), - makePath("/_matrix/client/r0", "/pushers/set")) + makePath("/_matrix/client/v3", "/pushers/set")) { QJsonObject _data; addParam<>(_data, QStringLiteral("pushkey"), pushkey); diff --git a/lib/csapi/pushrules.cpp b/lib/csapi/pushrules.cpp index 0d840788..6b0effd4 100644 --- a/lib/csapi/pushrules.cpp +++ b/lib/csapi/pushrules.cpp @@ -9,12 +9,12 @@ using namespace Quotient; QUrl GetPushRulesJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl( - std::move(baseUrl), makePath("/_matrix/client/r0", "/pushrules")); + std::move(baseUrl), makePath("/_matrix/client/v3", "/pushrules")); } GetPushRulesJob::GetPushRulesJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetPushRulesJob"), - makePath("/_matrix/client/r0", "/pushrules")) + makePath("/_matrix/client/v3", "/pushrules")) { addExpectedKey("global"); } @@ -23,14 +23,14 @@ QUrl GetPushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/pushrules/", + makePath("/_matrix/client/v3", "/pushrules/", scope, "/", kind, "/", ruleId)); } GetPushRuleJob::GetPushRuleJob(const QString& scope, const QString& kind, const QString& ruleId) : BaseJob(HttpVerb::Get, QStringLiteral("GetPushRuleJob"), - makePath("/_matrix/client/r0", "/pushrules/", scope, "/", kind, + makePath("/_matrix/client/v3", "/pushrules/", scope, "/", kind, "/", ruleId)) {} @@ -39,14 +39,14 @@ QUrl DeletePushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& ruleId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/pushrules/", + makePath("/_matrix/client/v3", "/pushrules/", scope, "/", kind, "/", ruleId)); } DeletePushRuleJob::DeletePushRuleJob(const QString& scope, const QString& kind, const QString& ruleId) : BaseJob(HttpVerb::Delete, QStringLiteral("DeletePushRuleJob"), - makePath("/_matrix/client/r0", "/pushrules/", scope, "/", kind, + makePath("/_matrix/client/v3", "/pushrules/", scope, "/", kind, "/", ruleId)) {} @@ -65,7 +65,7 @@ SetPushRuleJob::SetPushRuleJob(const QString& scope, const QString& kind, const QVector& conditions, const QString& pattern) : BaseJob(HttpVerb::Put, QStringLiteral("SetPushRuleJob"), - makePath("/_matrix/client/r0", "/pushrules/", scope, "/", kind, + makePath("/_matrix/client/v3", "/pushrules/", scope, "/", kind, "/", ruleId), queryToSetPushRule(before, after)) { @@ -81,7 +81,7 @@ QUrl IsPushRuleEnabledJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& ruleId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/pushrules/", + makePath("/_matrix/client/v3", "/pushrules/", scope, "/", kind, "/", ruleId, "/enabled")); } @@ -90,7 +90,7 @@ IsPushRuleEnabledJob::IsPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId) : BaseJob(HttpVerb::Get, QStringLiteral("IsPushRuleEnabledJob"), - makePath("/_matrix/client/r0", "/pushrules/", scope, "/", kind, + makePath("/_matrix/client/v3", "/pushrules/", scope, "/", kind, "/", ruleId, "/enabled")) { addExpectedKey("enabled"); @@ -100,7 +100,7 @@ SetPushRuleEnabledJob::SetPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId, bool enabled) : BaseJob(HttpVerb::Put, QStringLiteral("SetPushRuleEnabledJob"), - makePath("/_matrix/client/r0", "/pushrules/", scope, "/", kind, + makePath("/_matrix/client/v3", "/pushrules/", scope, "/", kind, "/", ruleId, "/enabled")) { QJsonObject _data; @@ -113,7 +113,7 @@ QUrl GetPushRuleActionsJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& ruleId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/pushrules/", + makePath("/_matrix/client/v3", "/pushrules/", scope, "/", kind, "/", ruleId, "/actions")); } @@ -122,7 +122,7 @@ GetPushRuleActionsJob::GetPushRuleActionsJob(const QString& scope, const QString& kind, const QString& ruleId) : BaseJob(HttpVerb::Get, QStringLiteral("GetPushRuleActionsJob"), - makePath("/_matrix/client/r0", "/pushrules/", scope, "/", kind, + makePath("/_matrix/client/v3", "/pushrules/", scope, "/", kind, "/", ruleId, "/actions")) { addExpectedKey("actions"); @@ -133,7 +133,7 @@ SetPushRuleActionsJob::SetPushRuleActionsJob(const QString& scope, const QString& ruleId, const QVector& actions) : BaseJob(HttpVerb::Put, QStringLiteral("SetPushRuleActionsJob"), - makePath("/_matrix/client/r0", "/pushrules/", scope, "/", kind, + makePath("/_matrix/client/v3", "/pushrules/", scope, "/", kind, "/", ruleId, "/actions")) { QJsonObject _data; diff --git a/lib/csapi/read_markers.cpp b/lib/csapi/read_markers.cpp index f2edb71e..dc84f887 100644 --- a/lib/csapi/read_markers.cpp +++ b/lib/csapi/read_markers.cpp @@ -10,7 +10,7 @@ SetReadMarkerJob::SetReadMarkerJob(const QString& roomId, const QString& mFullyRead, const QString& mRead) : BaseJob(HttpVerb::Post, QStringLiteral("SetReadMarkerJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/read_markers")) + makePath("/_matrix/client/v3", "/rooms/", roomId, "/read_markers")) { QJsonObject _data; addParam<>(_data, QStringLiteral("m.fully_read"), mFullyRead); diff --git a/lib/csapi/receipts.cpp b/lib/csapi/receipts.cpp index 401c3bfe..8feab986 100644 --- a/lib/csapi/receipts.cpp +++ b/lib/csapi/receipts.cpp @@ -10,7 +10,7 @@ PostReceiptJob::PostReceiptJob(const QString& roomId, const QString& receiptType const QString& eventId, const QJsonObject& receipt) : BaseJob(HttpVerb::Post, QStringLiteral("PostReceiptJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/receipt/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/receipt/", receiptType, "/", eventId)) { setRequestData(RequestData(toJson(receipt))); diff --git a/lib/csapi/redaction.cpp b/lib/csapi/redaction.cpp index acf1b0e4..d67cb37b 100644 --- a/lib/csapi/redaction.cpp +++ b/lib/csapi/redaction.cpp @@ -9,7 +9,7 @@ using namespace Quotient; RedactEventJob::RedactEventJob(const QString& roomId, const QString& eventId, const QString& txnId, const QString& reason) : BaseJob(HttpVerb::Put, QStringLiteral("RedactEventJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/redact/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/redact/", eventId, "/", txnId)) { QJsonObject _data; diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 153abcee..aa4b4fad 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -20,7 +20,7 @@ RegisterJob::RegisterJob(const QString& kind, const QString& initialDeviceDisplayName, Omittable inhibitLogin) : BaseJob(HttpVerb::Post, QStringLiteral("RegisterJob"), - makePath("/_matrix/client/r0", "/register"), + makePath("/_matrix/client/v3", "/register"), queryToRegister(kind), {}, false) { QJsonObject _data; @@ -38,7 +38,7 @@ RegisterJob::RegisterJob(const QString& kind, RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( const EmailValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterEmailJob"), - makePath("/_matrix/client/r0", "/register/email/requestToken"), + makePath("/_matrix/client/v3", "/register/email/requestToken"), false) { setRequestData(RequestData(toJson(body))); @@ -47,7 +47,7 @@ RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( const MsisdnValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterMSISDNJob"), - makePath("/_matrix/client/r0", "/register/msisdn/requestToken"), + makePath("/_matrix/client/v3", "/register/msisdn/requestToken"), false) { setRequestData(RequestData(toJson(body))); @@ -57,7 +57,7 @@ ChangePasswordJob::ChangePasswordJob(const QString& newPassword, bool logoutDevices, const Omittable& auth) : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), - makePath("/_matrix/client/r0", "/account/password")) + makePath("/_matrix/client/v3", "/account/password")) { QJsonObject _data; addParam<>(_data, QStringLiteral("new_password"), newPassword); @@ -70,7 +70,7 @@ RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( const EmailValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToResetPasswordEmailJob"), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/account/password/email/requestToken"), false) { @@ -81,7 +81,7 @@ RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( const MsisdnValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToResetPasswordMSISDNJob"), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/account/password/msisdn/requestToken"), false) { @@ -91,7 +91,7 @@ RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( DeactivateAccountJob::DeactivateAccountJob( const Omittable& auth, const QString& idServer) : BaseJob(HttpVerb::Post, QStringLiteral("DeactivateAccountJob"), - makePath("/_matrix/client/r0", "/account/deactivate")) + makePath("/_matrix/client/v3", "/account/deactivate")) { QJsonObject _data; addParam(_data, QStringLiteral("auth"), auth); @@ -111,13 +111,14 @@ QUrl CheckUsernameAvailabilityJob::makeRequestUrl(QUrl baseUrl, const QString& username) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/register/available"), queryToCheckUsernameAvailability(username)); } -CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob(const QString& username) +CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob( + const QString& username) : BaseJob(HttpVerb::Get, QStringLiteral("CheckUsernameAvailabilityJob"), - makePath("/_matrix/client/r0", "/register/available"), + makePath("/_matrix/client/v3", "/register/available"), queryToCheckUsernameAvailability(username), {}, false) {} diff --git a/lib/csapi/registration.h b/lib/csapi/registration.h index 10375971..39840008 100644 --- a/lib/csapi/registration.h +++ b/lib/csapi/registration.h @@ -227,7 +227,8 @@ public: * should be revoked if the request succeeds. * * When `false`, the server can still take advantage of the [soft logout - * method](/client-server-api/#soft-logout) for the user's remaining devices. + * method](/client-server-api/#soft-logout) for the user's remaining + * devices. * * \param auth * Additional authentication information for the user-interactive @@ -247,7 +248,7 @@ public: * `/account/password` endpoint. * * This API's parameters and response are identical to that of the - * [`/register/email/requestToken`](/client-server-api/#post_matrixclientr0registeremailrequesttoken) + * [`/register/email/requestToken`](/client-server-api/#post_matrixclientv3registeremailrequesttoken) * endpoint, except that * `M_THREEPID_NOT_FOUND` may be returned if no account matching the * given email address could be found. The server may instead send an @@ -269,7 +270,7 @@ public: * `/account/password` endpoint. * * This API's parameters and response are identical to that of the - * [`/register/email/requestToken`](/client-server-api/#post_matrixclientr0registeremailrequesttoken) + * [`/register/email/requestToken`](/client-server-api/#post_matrixclientv3registeremailrequesttoken) * endpoint, except that * `M_THREEPID_NOT_FOUND` may be returned if no account matching the * given email address could be found. The server may instead send an @@ -299,7 +300,7 @@ public: * `/account/password` endpoint. * * This API's parameters and response are identical to that of the - * [`/register/msisdn/requestToken`](/client-server-api/#post_matrixclientr0registermsisdnrequesttoken) + * [`/register/msisdn/requestToken`](/client-server-api/#post_matrixclientv3registermsisdnrequesttoken) * endpoint, except that * `M_THREEPID_NOT_FOUND` may be returned if no account matching the * given phone number could be found. The server may instead send the SMS @@ -321,15 +322,16 @@ public: * `/account/password` endpoint. * * This API's parameters and response are identical to that of the - * [`/register/msisdn/requestToken`](/client-server-api/#post_matrixclientr0registermsisdnrequesttoken) + * [`/register/msisdn/requestToken`](/client-server-api/#post_matrixclientv3registermsisdnrequesttoken) * endpoint, except that * `M_THREEPID_NOT_FOUND` may be returned if no account matching the * given phone number could be found. The server may instead send the SMS * to the given phone number prompting the user to create an account. * `M_THREEPID_IN_USE` may not be returned. * - * The homeserver should validate the phone number itself, either by sending - * a validation message itself or by using a service it has control over. + * The homeserver should validate the phone number itself, either by + * sending a validation message itself or by using a service it has control + * over. */ explicit RequestTokenToResetPasswordMSISDNJob( const MsisdnValidationData& body); @@ -377,8 +379,9 @@ public: * it must return an `id_server_unbind_result` of * `no-support`. */ - explicit DeactivateAccountJob(const Omittable& auth = none, - const QString& idServer = {}); + explicit DeactivateAccountJob( + const Omittable& auth = none, + const QString& idServer = {}); // Result properties diff --git a/lib/csapi/registration_tokens.cpp b/lib/csapi/registration_tokens.cpp new file mode 100644 index 00000000..9c1f0587 --- /dev/null +++ b/lib/csapi/registration_tokens.cpp @@ -0,0 +1,33 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "registration_tokens.h" + +using namespace Quotient; + +auto queryToRegistrationTokenValidity(const QString& token) +{ + QUrlQuery _q; + addParam<>(_q, QStringLiteral("token"), token); + return _q; +} + +QUrl RegistrationTokenValidityJob::makeRequestUrl(QUrl baseUrl, + const QString& token) +{ + return BaseJob::makeRequestUrl( + std::move(baseUrl), + makePath("/_matrix/client/v1", + "/register/m.login.registration_token/validity"), + queryToRegistrationTokenValidity(token)); +} + +RegistrationTokenValidityJob::RegistrationTokenValidityJob(const QString& token) + : BaseJob(HttpVerb::Get, QStringLiteral("RegistrationTokenValidityJob"), + makePath("/_matrix/client/v1", + "/register/m.login.registration_token/validity"), + queryToRegistrationTokenValidity(token), {}, false) +{ + addExpectedKey("valid"); +} diff --git a/lib/csapi/registration_tokens.h b/lib/csapi/registration_tokens.h new file mode 100644 index 00000000..e3008dd4 --- /dev/null +++ b/lib/csapi/registration_tokens.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "jobs/basejob.h" + +namespace Quotient { + +/*! \brief Query if a given registration token is still valid. + * + * Queries the server to determine if a given registration token is still + * valid at the time of request. This is a point-in-time check where the + * token might still expire by the time it is used. + * + * Servers should be sure to rate limit this endpoint to avoid brute force + * attacks. + */ +class QUOTIENT_API RegistrationTokenValidityJob : public BaseJob { +public: + /*! \brief Query if a given registration token is still valid. + * + * \param token + * The token to check validity of. + */ + explicit RegistrationTokenValidityJob(const QString& token); + + /*! \brief Construct a URL without creating a full-fledged job object + * + * This function can be used when a URL for RegistrationTokenValidityJob + * is necessary but the job itself isn't. + */ + static QUrl makeRequestUrl(QUrl baseUrl, const QString& token); + + // Result properties + + /// True if the token is still valid, false otherwise. This should + /// additionally be false if the token is not a recognised token by + /// the server. + bool valid() const { return loadFromJson("valid"_ls); } +}; + +} // namespace Quotient diff --git a/lib/csapi/report_content.cpp b/lib/csapi/report_content.cpp index 0a76d5b8..b8e9a8d1 100644 --- a/lib/csapi/report_content.cpp +++ b/lib/csapi/report_content.cpp @@ -9,7 +9,7 @@ using namespace Quotient; ReportContentJob::ReportContentJob(const QString& roomId, const QString& eventId, Omittable score, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("ReportContentJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/report/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/report/", eventId)) { QJsonObject _data; diff --git a/lib/csapi/room_send.cpp b/lib/csapi/room_send.cpp index f80f9300..93ab04d2 100644 --- a/lib/csapi/room_send.cpp +++ b/lib/csapi/room_send.cpp @@ -9,7 +9,7 @@ using namespace Quotient; SendMessageJob::SendMessageJob(const QString& roomId, const QString& eventType, const QString& txnId, const QJsonObject& body) : BaseJob(HttpVerb::Put, QStringLiteral("SendMessageJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/send/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/send/", eventType, "/", txnId)) { setRequestData(RequestData(toJson(body))); diff --git a/lib/csapi/room_send.h b/lib/csapi/room_send.h index fea3d59d..fcb6b24f 100644 --- a/lib/csapi/room_send.h +++ b/lib/csapi/room_send.h @@ -16,7 +16,8 @@ namespace Quotient { * * The body of the request should be the content object of the event; the * fields in this object will vary depending on the type of event. See - * [Room Events](/client-server-api/#room-events) for the m. event specification. + * [Room Events](/client-server-api/#room-events) for the m. event + * specification. */ class QUOTIENT_API SendMessageJob : public BaseJob { public: diff --git a/lib/csapi/room_state.cpp b/lib/csapi/room_state.cpp index f6d2e6ec..2253863a 100644 --- a/lib/csapi/room_state.cpp +++ b/lib/csapi/room_state.cpp @@ -11,7 +11,7 @@ SetRoomStateWithKeyJob::SetRoomStateWithKeyJob(const QString& roomId, const QString& stateKey, const QJsonObject& body) : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomStateWithKeyJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/state/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/state/", eventType, "/", stateKey)) { setRequestData(RequestData(toJson(body))); diff --git a/lib/csapi/room_upgrades.cpp b/lib/csapi/room_upgrades.cpp index d4129cfb..3f67234d 100644 --- a/lib/csapi/room_upgrades.cpp +++ b/lib/csapi/room_upgrades.cpp @@ -8,7 +8,7 @@ using namespace Quotient; UpgradeRoomJob::UpgradeRoomJob(const QString& roomId, const QString& newVersion) : BaseJob(HttpVerb::Post, QStringLiteral("UpgradeRoomJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/upgrade")) + makePath("/_matrix/client/v3", "/rooms/", roomId, "/upgrade")) { QJsonObject _data; addParam<>(_data, QStringLiteral("new_version"), newVersion); diff --git a/lib/csapi/rooms.cpp b/lib/csapi/rooms.cpp index 5310aa32..563f4fa5 100644 --- a/lib/csapi/rooms.cpp +++ b/lib/csapi/rooms.cpp @@ -10,14 +10,14 @@ QUrl GetOneRoomEventJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/rooms/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/event/", eventId)); } GetOneRoomEventJob::GetOneRoomEventJob(const QString& roomId, const QString& eventId) : BaseJob(HttpVerb::Get, QStringLiteral("GetOneRoomEventJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/event/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/event/", eventId)) {} @@ -26,7 +26,7 @@ QUrl GetRoomStateWithKeyJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& stateKey) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/rooms/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/state/", eventType, "/", stateKey)); } @@ -35,20 +35,20 @@ GetRoomStateWithKeyJob::GetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, const QString& stateKey) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateWithKeyJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/state/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/state/", eventType, "/", stateKey)) {} QUrl GetRoomStateJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/rooms/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/state")); } GetRoomStateJob::GetRoomStateJob(const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/state")) + makePath("/_matrix/client/v3", "/rooms/", roomId, "/state")) {} auto queryToGetMembersByRoom(const QString& at, const QString& membership, @@ -68,7 +68,7 @@ QUrl GetMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, { return BaseJob::makeRequestUrl( std::move(baseUrl), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/members"), + makePath("/_matrix/client/v3", "/rooms/", roomId, "/members"), queryToGetMembersByRoom(at, membership, notMembership)); } @@ -77,7 +77,7 @@ GetMembersByRoomJob::GetMembersByRoomJob(const QString& roomId, const QString& membership, const QString& notMembership) : BaseJob(HttpVerb::Get, QStringLiteral("GetMembersByRoomJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/members"), + makePath("/_matrix/client/v3", "/rooms/", roomId, "/members"), queryToGetMembersByRoom(at, membership, notMembership)) {} @@ -85,12 +85,12 @@ QUrl GetJoinedMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/rooms/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/joined_members")); } GetJoinedMembersByRoomJob::GetJoinedMembersByRoomJob(const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetJoinedMembersByRoomJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, + makePath("/_matrix/client/v3", "/rooms/", roomId, "/joined_members")) {} diff --git a/lib/csapi/rooms.h b/lib/csapi/rooms.h index f0815109..247fb13f 100644 --- a/lib/csapi/rooms.h +++ b/lib/csapi/rooms.h @@ -5,7 +5,6 @@ #pragma once #include "events/eventloader.h" -#include "events/roommemberevent.h" #include "jobs/basejob.h" namespace Quotient { @@ -38,7 +37,7 @@ public: // Result properties /// The full event. - EventPtr event() { return fromJson(jsonData()); } + RoomEventPtr event() { return fromJson(jsonData()); } }; /*! \brief Get the state identified by the type and key. @@ -146,10 +145,7 @@ public: // Result properties /// Get the list of members for this room. - EventsArray chunk() - { - return takeFromJson>("chunk"_ls); - } + StateEvents chunk() { return takeFromJson("chunk"_ls); } }; /*! \brief Gets the list of currently joined users and their profile data. @@ -157,9 +153,8 @@ public: * This API returns a map of MXIDs to member info objects for members of the * room. The current user must be in the room for it to work, unless it is an * Application Service in which case any of the AS's users must be in the room. - * This API is primarily for Application Services and should be faster to - * respond than `/members` as it can be implemented more efficiently on the - * server. + * This API is primarily for Application Services and should be faster to respond + * than `/members` as it can be implemented more efficiently on the server. */ class QUOTIENT_API GetJoinedMembersByRoomJob : public BaseJob { public: diff --git a/lib/csapi/search.cpp b/lib/csapi/search.cpp index 295dd1cc..92300351 100644 --- a/lib/csapi/search.cpp +++ b/lib/csapi/search.cpp @@ -16,7 +16,7 @@ auto queryToSearch(const QString& nextBatch) SearchJob::SearchJob(const Categories& searchCategories, const QString& nextBatch) : BaseJob(HttpVerb::Post, QStringLiteral("SearchJob"), - makePath("/_matrix/client/r0", "/search"), + makePath("/_matrix/client/v3", "/search"), queryToSearch(nextBatch)) { QJsonObject _data; diff --git a/lib/csapi/space_hierarchy.cpp b/lib/csapi/space_hierarchy.cpp new file mode 100644 index 00000000..7c17ce8a --- /dev/null +++ b/lib/csapi/space_hierarchy.cpp @@ -0,0 +1,43 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "space_hierarchy.h" + +using namespace Quotient; + +auto queryToGetSpaceHierarchy(Omittable suggestedOnly, + Omittable limit, + Omittable maxDepth, const QString& from) +{ + QUrlQuery _q; + addParam(_q, QStringLiteral("suggested_only"), suggestedOnly); + addParam(_q, QStringLiteral("limit"), limit); + addParam(_q, QStringLiteral("max_depth"), maxDepth); + addParam(_q, QStringLiteral("from"), from); + return _q; +} + +QUrl GetSpaceHierarchyJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, + Omittable suggestedOnly, + Omittable limit, + Omittable maxDepth, + const QString& from) +{ + return BaseJob::makeRequestUrl( + std::move(baseUrl), + makePath("/_matrix/client/v1", "/rooms/", roomId, "/hierarchy"), + queryToGetSpaceHierarchy(suggestedOnly, limit, maxDepth, from)); +} + +GetSpaceHierarchyJob::GetSpaceHierarchyJob(const QString& roomId, + Omittable suggestedOnly, + Omittable limit, + Omittable maxDepth, + const QString& from) + : BaseJob(HttpVerb::Get, QStringLiteral("GetSpaceHierarchyJob"), + makePath("/_matrix/client/v1", "/rooms/", roomId, "/hierarchy"), + queryToGetSpaceHierarchy(suggestedOnly, limit, maxDepth, from)) +{ + addExpectedKey("rooms"); +} diff --git a/lib/csapi/space_hierarchy.h b/lib/csapi/space_hierarchy.h new file mode 100644 index 00000000..adffe2f8 --- /dev/null +++ b/lib/csapi/space_hierarchy.h @@ -0,0 +1,88 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "csapi/../../event-schemas/schema/core-event-schema/stripped_state.h" +#include "csapi/definitions/public_rooms_chunk.h" + +#include "jobs/basejob.h" + +namespace Quotient { + +/*! \brief Retrieve a portion of a space tree. + * + * Paginates over the space tree in a depth-first manner to locate child rooms + * of a given space. + * + * Where a child room is unknown to the local server, federation is used to fill + * in the details. The servers listed in the `via` array should be contacted to + * attempt to fill in missing rooms. + * + * Only [`m.space.child`](#mspacechild) state events of the room are considered. + * Invalid child rooms and parent events are not covered by this endpoint. + */ +class QUOTIENT_API GetSpaceHierarchyJob : public BaseJob { +public: + /*! \brief Retrieve a portion of a space tree. + * + * \param roomId + * The room ID of the space to get a hierarchy for. + * + * \param suggestedOnly + * Optional (default `false`) flag to indicate whether or not the server + * should only consider suggested rooms. Suggested rooms are annotated in + * their [`m.space.child`](#mspacechild) event contents. + * + * \param limit + * Optional limit for the maximum number of rooms to include per response. + * Must be an integer greater than zero. + * + * Servers should apply a default value, and impose a maximum value to + * avoid resource exhaustion. + * + * \param maxDepth + * Optional limit for how far to go into the space. Must be a non-negative + * integer. + * + * When reached, no further child rooms will be returned. + * + * Servers should apply a default value, and impose a maximum value to + * avoid resource exhaustion. + * + * \param from + * A pagination token from a previous result. If specified, `max_depth` + * and `suggested_only` cannot be changed from the first request. + */ + explicit GetSpaceHierarchyJob(const QString& roomId, + Omittable suggestedOnly = none, + Omittable limit = none, + Omittable maxDepth = none, + const QString& from = {}); + + /*! \brief Construct a URL without creating a full-fledged job object + * + * This function can be used when a URL for GetSpaceHierarchyJob + * is necessary but the job itself isn't. + */ + static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, + Omittable suggestedOnly = none, + Omittable limit = none, + Omittable maxDepth = none, + const QString& from = {}); + + // Result properties + + /// The rooms for the current page, with the current filters. + QVector rooms() const + { + return loadFromJson>("rooms"_ls); + } + + /// A token to supply to `from` to keep paginating the responses. Not + /// present when there are no further results. + QString nextBatch() const { return loadFromJson("next_batch"_ls); } +}; + +} // namespace Quotient diff --git a/lib/csapi/sso_login_redirect.cpp b/lib/csapi/sso_login_redirect.cpp index 871d6ff6..71f8147c 100644 --- a/lib/csapi/sso_login_redirect.cpp +++ b/lib/csapi/sso_login_redirect.cpp @@ -16,14 +16,14 @@ auto queryToRedirectToSSO(const QString& redirectUrl) QUrl RedirectToSSOJob::makeRequestUrl(QUrl baseUrl, const QString& redirectUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/login/sso/redirect"), queryToRedirectToSSO(redirectUrl)); } RedirectToSSOJob::RedirectToSSOJob(const QString& redirectUrl) : BaseJob(HttpVerb::Get, QStringLiteral("RedirectToSSOJob"), - makePath("/_matrix/client/r0", "/login/sso/redirect"), + makePath("/_matrix/client/v3", "/login/sso/redirect"), queryToRedirectToSSO(redirectUrl), {}, false) {} @@ -38,7 +38,7 @@ QUrl RedirectToIdPJob::makeRequestUrl(QUrl baseUrl, const QString& idpId, const QString& redirectUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/login/sso/redirect/", idpId), queryToRedirectToIdP(redirectUrl)); } @@ -46,6 +46,6 @@ QUrl RedirectToIdPJob::makeRequestUrl(QUrl baseUrl, const QString& idpId, RedirectToIdPJob::RedirectToIdPJob(const QString& idpId, const QString& redirectUrl) : BaseJob(HttpVerb::Get, QStringLiteral("RedirectToIdPJob"), - makePath("/_matrix/client/r0", "/login/sso/redirect/", idpId), + makePath("/_matrix/client/v3", "/login/sso/redirect/", idpId), queryToRedirectToIdP(redirectUrl), {}, false) {} diff --git a/lib/csapi/tags.cpp b/lib/csapi/tags.cpp index f717de6e..21cb18ed 100644 --- a/lib/csapi/tags.cpp +++ b/lib/csapi/tags.cpp @@ -10,13 +10,13 @@ QUrl GetRoomTagsJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/user/", + makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/tags")); } GetRoomTagsJob::GetRoomTagsJob(const QString& userId, const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomTagsJob"), - makePath("/_matrix/client/r0", "/user/", userId, "/rooms/", + makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/tags")) {} @@ -24,7 +24,7 @@ SetRoomTagJob::SetRoomTagJob(const QString& userId, const QString& roomId, const QString& tag, Omittable order, const QVariantHash& additionalProperties) : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomTagJob"), - makePath("/_matrix/client/r0", "/user/", userId, "/rooms/", + makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/tags/", tag)) { QJsonObject _data; @@ -37,7 +37,7 @@ QUrl DeleteRoomTagJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId, const QString& tag) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", "/user/", + makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/tags/", tag)); } @@ -45,6 +45,6 @@ QUrl DeleteRoomTagJob::makeRequestUrl(QUrl baseUrl, const QString& userId, DeleteRoomTagJob::DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag) : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteRoomTagJob"), - makePath("/_matrix/client/r0", "/user/", userId, "/rooms/", + makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/tags/", tag)) {} diff --git a/lib/csapi/third_party_lookup.cpp b/lib/csapi/third_party_lookup.cpp index 4c930668..1e5870ce 100644 --- a/lib/csapi/third_party_lookup.cpp +++ b/lib/csapi/third_party_lookup.cpp @@ -9,26 +9,26 @@ using namespace Quotient; QUrl GetProtocolsJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/thirdparty/protocols")); } GetProtocolsJob::GetProtocolsJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetProtocolsJob"), - makePath("/_matrix/client/r0", "/thirdparty/protocols")) + makePath("/_matrix/client/v3", "/thirdparty/protocols")) {} QUrl GetProtocolMetadataJob::makeRequestUrl(QUrl baseUrl, const QString& protocol) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/thirdparty/protocol/", protocol)); } GetProtocolMetadataJob::GetProtocolMetadataJob(const QString& protocol) : BaseJob(HttpVerb::Get, QStringLiteral("GetProtocolMetadataJob"), - makePath("/_matrix/client/r0", "/thirdparty/protocol/", protocol)) + makePath("/_matrix/client/v3", "/thirdparty/protocol/", protocol)) {} auto queryToQueryLocationByProtocol(const QString& searchFields) @@ -43,7 +43,7 @@ QUrl QueryLocationByProtocolJob::makeRequestUrl(QUrl baseUrl, const QString& searchFields) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/thirdparty/location/", protocol), queryToQueryLocationByProtocol(searchFields)); } @@ -51,7 +51,7 @@ QUrl QueryLocationByProtocolJob::makeRequestUrl(QUrl baseUrl, QueryLocationByProtocolJob::QueryLocationByProtocolJob( const QString& protocol, const QString& searchFields) : BaseJob(HttpVerb::Get, QStringLiteral("QueryLocationByProtocolJob"), - makePath("/_matrix/client/r0", "/thirdparty/location/", protocol), + makePath("/_matrix/client/v3", "/thirdparty/location/", protocol), queryToQueryLocationByProtocol(searchFields)) {} @@ -67,7 +67,7 @@ QUrl QueryUserByProtocolJob::makeRequestUrl(QUrl baseUrl, const QString& fields) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/thirdparty/user/", protocol), queryToQueryUserByProtocol(fields)); } @@ -75,7 +75,7 @@ QUrl QueryUserByProtocolJob::makeRequestUrl(QUrl baseUrl, QueryUserByProtocolJob::QueryUserByProtocolJob(const QString& protocol, const QString& fields) : BaseJob(HttpVerb::Get, QStringLiteral("QueryUserByProtocolJob"), - makePath("/_matrix/client/r0", "/thirdparty/user/", protocol), + makePath("/_matrix/client/v3", "/thirdparty/user/", protocol), queryToQueryUserByProtocol(fields)) {} @@ -89,14 +89,14 @@ auto queryToQueryLocationByAlias(const QString& alias) QUrl QueryLocationByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& alias) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/thirdparty/location"), queryToQueryLocationByAlias(alias)); } QueryLocationByAliasJob::QueryLocationByAliasJob(const QString& alias) : BaseJob(HttpVerb::Get, QStringLiteral("QueryLocationByAliasJob"), - makePath("/_matrix/client/r0", "/thirdparty/location"), + makePath("/_matrix/client/v3", "/thirdparty/location"), queryToQueryLocationByAlias(alias)) {} @@ -110,13 +110,13 @@ auto queryToQueryUserByID(const QString& userid) QUrl QueryUserByIDJob::makeRequestUrl(QUrl baseUrl, const QString& userid) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/thirdparty/user"), queryToQueryUserByID(userid)); } QueryUserByIDJob::QueryUserByIDJob(const QString& userid) : BaseJob(HttpVerb::Get, QStringLiteral("QueryUserByIDJob"), - makePath("/_matrix/client/r0", "/thirdparty/user"), + makePath("/_matrix/client/v3", "/thirdparty/user"), queryToQueryUserByID(userid)) {} diff --git a/lib/csapi/third_party_membership.cpp b/lib/csapi/third_party_membership.cpp index 59275e41..2d6df77d 100644 --- a/lib/csapi/third_party_membership.cpp +++ b/lib/csapi/third_party_membership.cpp @@ -10,7 +10,7 @@ InviteBy3PIDJob::InviteBy3PIDJob(const QString& roomId, const QString& idServer, const QString& idAccessToken, const QString& medium, const QString& address) : BaseJob(HttpVerb::Post, QStringLiteral("InviteBy3PIDJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/invite")) + makePath("/_matrix/client/v3", "/rooms/", roomId, "/invite")) { QJsonObject _data; addParam<>(_data, QStringLiteral("id_server"), idServer); diff --git a/lib/csapi/third_party_membership.h b/lib/csapi/third_party_membership.h index 1edb969e..1129a9a8 100644 --- a/lib/csapi/third_party_membership.h +++ b/lib/csapi/third_party_membership.h @@ -16,7 +16,7 @@ namespace Quotient { * The homeserver uses an identity server to perform the mapping from * third party identifier to a Matrix identifier. The other is documented in * the* [joining rooms - * section](/client-server-api/#post_matrixclientr0roomsroomidinvite). + * section](/client-server-api/#post_matrixclientv3roomsroomidinvite). * * This API invites a user to participate in a particular room. * They do not start participating in the room until they actually join the diff --git a/lib/csapi/to_device.cpp b/lib/csapi/to_device.cpp index 628e8314..48e943db 100644 --- a/lib/csapi/to_device.cpp +++ b/lib/csapi/to_device.cpp @@ -10,7 +10,7 @@ SendToDeviceJob::SendToDeviceJob( const QString& eventType, const QString& txnId, const QHash>& messages) : BaseJob(HttpVerb::Put, QStringLiteral("SendToDeviceJob"), - makePath("/_matrix/client/r0", "/sendToDevice/", eventType, "/", + makePath("/_matrix/client/v3", "/sendToDevice/", eventType, "/", txnId)) { QJsonObject _data; diff --git a/lib/csapi/typing.cpp b/lib/csapi/typing.cpp index c9673118..1b4fe147 100644 --- a/lib/csapi/typing.cpp +++ b/lib/csapi/typing.cpp @@ -9,7 +9,7 @@ using namespace Quotient; SetTypingJob::SetTypingJob(const QString& userId, const QString& roomId, bool typing, Omittable timeout) : BaseJob(HttpVerb::Put, QStringLiteral("SetTypingJob"), - makePath("/_matrix/client/r0", "/rooms/", roomId, "/typing/", + makePath("/_matrix/client/v3", "/rooms/", roomId, "/typing/", userId)) { QJsonObject _data; diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index 48b727f0..e0db6f70 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -9,7 +9,7 @@ using namespace Quotient; SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, Omittable limit) : BaseJob(HttpVerb::Post, QStringLiteral("SearchUserDirectoryJob"), - makePath("/_matrix/client/r0", "/user_directory/search")) + makePath("/_matrix/client/v3", "/user_directory/search")) { QJsonObject _data; addParam<>(_data, QStringLiteral("search_term"), searchTerm); diff --git a/lib/csapi/versions.h b/lib/csapi/versions.h index 4445dbd2..9f799cb0 100644 --- a/lib/csapi/versions.h +++ b/lib/csapi/versions.h @@ -12,11 +12,9 @@ namespace Quotient { * * Gets the versions of the specification supported by the server. * - * Values will take the form `rX.Y.Z`. - * - * Only the latest `Z` value will be reported for each supported `X.Y` value. - * i.e. if the server implements `r0.0.0`, `r0.0.1`, and `r1.2.0`, it will - * report `r0.0.1` and `r1.2.0`. + * Values will take the form `vX.Y` or `rX.Y.Z` in historical cases. See + * [the Specification Versioning](../#specification-versions) for more + * information. * * The server may additionally advertise experimental features it supports * through `unstable_features`. These features should be namespaced and diff --git a/lib/csapi/voip.cpp b/lib/csapi/voip.cpp index c748ad94..1e1f2441 100644 --- a/lib/csapi/voip.cpp +++ b/lib/csapi/voip.cpp @@ -9,10 +9,10 @@ using namespace Quotient; QUrl GetTurnServerJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl( - std::move(baseUrl), makePath("/_matrix/client/r0", "/voip/turnServer")); + std::move(baseUrl), makePath("/_matrix/client/v3", "/voip/turnServer")); } GetTurnServerJob::GetTurnServerJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetTurnServerJob"), - makePath("/_matrix/client/r0", "/voip/turnServer")) + makePath("/_matrix/client/v3", "/voip/turnServer")) {} diff --git a/lib/csapi/whoami.cpp b/lib/csapi/whoami.cpp index ed8a9817..af0c5d31 100644 --- a/lib/csapi/whoami.cpp +++ b/lib/csapi/whoami.cpp @@ -9,12 +9,12 @@ using namespace Quotient; QUrl GetTokenOwnerJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl( - std::move(baseUrl), makePath("/_matrix/client/r0", "/account/whoami")); + std::move(baseUrl), makePath("/_matrix/client/v3", "/account/whoami")); } GetTokenOwnerJob::GetTokenOwnerJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetTokenOwnerJob"), - makePath("/_matrix/client/r0", "/account/whoami")) + makePath("/_matrix/client/v3", "/account/whoami")) { addExpectedKey("user_id"); } diff --git a/lib/csapi/whoami.h b/lib/csapi/whoami.h index fba099f6..3451dbc3 100644 --- a/lib/csapi/whoami.h +++ b/lib/csapi/whoami.h @@ -41,6 +41,14 @@ public: /// of application services) then this field can be omitted. /// Otherwise this is required. QString deviceId() const { return loadFromJson("device_id"_ls); } + + /// When `true`, the user is a [Guest User](#guest-access). When + /// not present or `false`, the user is presumed to be a non-guest + /// user. + Omittable isGuest() const + { + return loadFromJson>("is_guest"_ls); + } }; } // namespace Quotient -- cgit v1.2.3 From c9a2c38b5645de22315aac35c78a40127b5d2fe9 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Mon, 6 Jun 2022 14:02:17 +0200 Subject: Regenerate API files This only updates 3 files affected by the change in the previous commit. --- lib/csapi/definitions/public_rooms_response.h | 69 ++++++++++++++++++++++++-- lib/csapi/list_public_rooms.h | 10 ++-- lib/csapi/space_hierarchy.h | 71 +++++++++++++++++++++++++-- 3 files changed, 139 insertions(+), 11 deletions(-) (limited to 'lib/csapi') diff --git a/lib/csapi/definitions/public_rooms_response.h b/lib/csapi/definitions/public_rooms_response.h index ca512280..da917a98 100644 --- a/lib/csapi/definitions/public_rooms_response.h +++ b/lib/csapi/definitions/public_rooms_response.h @@ -6,13 +6,76 @@ #include "converters.h" -#include "csapi/definitions/public_rooms_chunk.h" - namespace Quotient { + +struct PublicRoomsChunk { + /// The canonical alias of the room, if any. + QString canonicalAlias; + + /// The name of the room, if any. + QString name; + + /// The number of members joined to the room. + int numJoinedMembers; + + /// The ID of the room. + QString roomId; + + /// The topic of the room, if any. + QString topic; + + /// Whether the room may be viewed by guest users without joining. + bool worldReadable; + + /// Whether guest users may join the room and participate in it. + /// If they can, they will be subject to ordinary power level + /// rules like any other user. + bool guestCanJoin; + + /// The URL for the room's avatar, if one is set. + QUrl avatarUrl; + + /// The room's join rule. When not present, the room is assumed to + /// be `public`. Note that rooms with `invite` join rules are not + /// expected here, but rooms with `knock` rules are given their + /// near-public nature. + QString joinRule; +}; + +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const PublicRoomsChunk& pod) + { + addParam(jo, QStringLiteral("canonical_alias"), + pod.canonicalAlias); + addParam(jo, QStringLiteral("name"), pod.name); + addParam<>(jo, QStringLiteral("num_joined_members"), + pod.numJoinedMembers); + addParam<>(jo, QStringLiteral("room_id"), pod.roomId); + addParam(jo, QStringLiteral("topic"), pod.topic); + addParam<>(jo, QStringLiteral("world_readable"), pod.worldReadable); + addParam<>(jo, QStringLiteral("guest_can_join"), pod.guestCanJoin); + addParam(jo, QStringLiteral("avatar_url"), pod.avatarUrl); + addParam(jo, QStringLiteral("join_rule"), pod.joinRule); + } + static void fillFrom(const QJsonObject& jo, PublicRoomsChunk& pod) + { + fromJson(jo.value("canonical_alias"_ls), pod.canonicalAlias); + fromJson(jo.value("name"_ls), pod.name); + fromJson(jo.value("num_joined_members"_ls), pod.numJoinedMembers); + fromJson(jo.value("room_id"_ls), pod.roomId); + fromJson(jo.value("topic"_ls), pod.topic); + fromJson(jo.value("world_readable"_ls), pod.worldReadable); + fromJson(jo.value("guest_can_join"_ls), pod.guestCanJoin); + fromJson(jo.value("avatar_url"_ls), pod.avatarUrl); + fromJson(jo.value("join_rule"_ls), pod.joinRule); + } +}; + /// A list of the rooms on the server. struct PublicRoomsResponse { /// A paginated chunk of public rooms. - QVector chunk; + QVector chunk; /// A pagination token for the response. The absence of this token /// means there are no more results to fetch and the client should diff --git a/lib/csapi/list_public_rooms.h b/lib/csapi/list_public_rooms.h index 701a74f6..e1f03db7 100644 --- a/lib/csapi/list_public_rooms.h +++ b/lib/csapi/list_public_rooms.h @@ -4,7 +4,7 @@ #pragma once -#include "csapi/definitions/public_rooms_chunk.h" +#include "csapi/definitions/public_rooms_response.h" #include "jobs/basejob.h" @@ -103,9 +103,9 @@ public: // Result properties /// A paginated chunk of public rooms. - QVector chunk() const + QVector chunk() const { - return loadFromJson>("chunk"_ls); + return loadFromJson>("chunk"_ls); } /// A pagination token for the response. The absence of this token @@ -182,9 +182,9 @@ public: // Result properties /// A paginated chunk of public rooms. - QVector chunk() const + QVector chunk() const { - return loadFromJson>("chunk"_ls); + return loadFromJson>("chunk"_ls); } /// A pagination token for the response. The absence of this token diff --git a/lib/csapi/space_hierarchy.h b/lib/csapi/space_hierarchy.h index adffe2f8..5b3c1f80 100644 --- a/lib/csapi/space_hierarchy.h +++ b/lib/csapi/space_hierarchy.h @@ -5,7 +5,6 @@ #pragma once #include "csapi/../../event-schemas/schema/core-event-schema/stripped_state.h" -#include "csapi/definitions/public_rooms_chunk.h" #include "jobs/basejob.h" @@ -25,6 +24,53 @@ namespace Quotient { */ class QUOTIENT_API GetSpaceHierarchyJob : public BaseJob { public: + // Inner data structures + + /// Paginates over the space tree in a depth-first manner to locate child + /// rooms of a given space. + /// + /// Where a child room is unknown to the local server, federation is used to + /// fill in the details. The servers listed in the `via` array should be + /// contacted to attempt to fill in missing rooms. + /// + /// Only [`m.space.child`](#mspacechild) state events of the room are + /// considered. Invalid child rooms and parent events are not covered by + /// this endpoint. + struct ChildRoomsChunk { + /// The canonical alias of the room, if any. + QString canonicalAlias; + /// The name of the room, if any. + QString name; + /// The number of members joined to the room. + int numJoinedMembers; + /// The ID of the room. + QString roomId; + /// The topic of the room, if any. + QString topic; + /// Whether the room may be viewed by guest users without joining. + bool worldReadable; + /// Whether guest users may join the room and participate in it. + /// If they can, they will be subject to ordinary power level + /// rules like any other user. + bool guestCanJoin; + /// The URL for the room's avatar, if one is set. + QUrl avatarUrl; + /// The room's join rule. When not present, the room is assumed to + /// be `public`. + QString joinRule; + /// The `type` of room (from + /// [`m.room.create`](/client-server-api/#mroomcreate)), if any. + QString roomType; + /// The [`m.space.child`](#mspacechild) events of the space-room, + /// represented as [Stripped State Events](#stripped-state) with an + /// added `origin_server_ts` key. + /// + /// If the room is not a space-room, this should be empty. + QVector childrenState; + }; + + // Construction/destruction + /*! \brief Retrieve a portion of a space tree. * * \param roomId @@ -75,9 +121,9 @@ public: // Result properties /// The rooms for the current page, with the current filters. - QVector rooms() const + QVector rooms() const { - return loadFromJson>("rooms"_ls); + return loadFromJson>("rooms"_ls); } /// A token to supply to `from` to keep paginating the responses. Not @@ -85,4 +131,23 @@ public: QString nextBatch() const { return loadFromJson("next_batch"_ls); } }; +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, + GetSpaceHierarchyJob::ChildRoomsChunk& result) + { + fromJson(jo.value("canonical_alias"_ls), result.canonicalAlias); + fromJson(jo.value("name"_ls), result.name); + fromJson(jo.value("num_joined_members"_ls), result.numJoinedMembers); + fromJson(jo.value("room_id"_ls), result.roomId); + fromJson(jo.value("topic"_ls), result.topic); + fromJson(jo.value("world_readable"_ls), result.worldReadable); + fromJson(jo.value("guest_can_join"_ls), result.guestCanJoin); + fromJson(jo.value("avatar_url"_ls), result.avatarUrl); + fromJson(jo.value("join_rule"_ls), result.joinRule); + fromJson(jo.value("room_type"_ls), result.roomType); + fromJson(jo.value("children_state"_ls), result.childrenState); + } +}; + } // namespace Quotient -- cgit v1.2.3 From f16e4d4e3e293a646569cb765a22607e4fd69756 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Thu, 9 Jun 2022 15:12:52 +0200 Subject: Regenerate API files The latest GTAD no more emits public_rooms_chunk.h (public_rooms_response.h already has the same definition), and skips on PublicRoomsResponse structure that is never used. --- lib/csapi/definitions/public_rooms_chunk.h | 73 --------------------------- lib/csapi/definitions/public_rooms_response.h | 40 --------------- 2 files changed, 113 deletions(-) delete mode 100644 lib/csapi/definitions/public_rooms_chunk.h (limited to 'lib/csapi') diff --git a/lib/csapi/definitions/public_rooms_chunk.h b/lib/csapi/definitions/public_rooms_chunk.h deleted file mode 100644 index eac68213..00000000 --- a/lib/csapi/definitions/public_rooms_chunk.h +++ /dev/null @@ -1,73 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "converters.h" - -namespace Quotient { - -struct PublicRoomsChunk { - /// The canonical alias of the room, if any. - QString canonicalAlias; - - /// The name of the room, if any. - QString name; - - /// The number of members joined to the room. - int numJoinedMembers; - - /// The ID of the room. - QString roomId; - - /// The topic of the room, if any. - QString topic; - - /// Whether the room may be viewed by guest users without joining. - bool worldReadable; - - /// Whether guest users may join the room and participate in it. - /// If they can, they will be subject to ordinary power level - /// rules like any other user. - bool guestCanJoin; - - /// The URL for the room's avatar, if one is set. - QUrl avatarUrl; - - /// The room's join rule. When not present, the room is assumed to - /// be `public`. - QString joinRule; -}; - -template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const PublicRoomsChunk& pod) - { - addParam(jo, QStringLiteral("canonical_alias"), - pod.canonicalAlias); - addParam(jo, QStringLiteral("name"), pod.name); - addParam<>(jo, QStringLiteral("num_joined_members"), - pod.numJoinedMembers); - addParam<>(jo, QStringLiteral("room_id"), pod.roomId); - addParam(jo, QStringLiteral("topic"), pod.topic); - addParam<>(jo, QStringLiteral("world_readable"), pod.worldReadable); - addParam<>(jo, QStringLiteral("guest_can_join"), pod.guestCanJoin); - addParam(jo, QStringLiteral("avatar_url"), pod.avatarUrl); - addParam(jo, QStringLiteral("join_rule"), pod.joinRule); - } - static void fillFrom(const QJsonObject& jo, PublicRoomsChunk& pod) - { - fromJson(jo.value("canonical_alias"_ls), pod.canonicalAlias); - fromJson(jo.value("name"_ls), pod.name); - fromJson(jo.value("num_joined_members"_ls), pod.numJoinedMembers); - fromJson(jo.value("room_id"_ls), pod.roomId); - fromJson(jo.value("topic"_ls), pod.topic); - fromJson(jo.value("world_readable"_ls), pod.worldReadable); - fromJson(jo.value("guest_can_join"_ls), pod.guestCanJoin); - fromJson(jo.value("avatar_url"_ls), pod.avatarUrl); - fromJson(jo.value("join_rule"_ls), pod.joinRule); - } -}; - -} // namespace Quotient diff --git a/lib/csapi/definitions/public_rooms_response.h b/lib/csapi/definitions/public_rooms_response.h index da917a98..d0a2595c 100644 --- a/lib/csapi/definitions/public_rooms_response.h +++ b/lib/csapi/definitions/public_rooms_response.h @@ -72,44 +72,4 @@ struct JsonObjectConverter { } }; -/// A list of the rooms on the server. -struct PublicRoomsResponse { - /// A paginated chunk of public rooms. - QVector chunk; - - /// A pagination token for the response. The absence of this token - /// means there are no more results to fetch and the client should - /// stop paginating. - QString nextBatch; - - /// A pagination token that allows fetching previous results. The - /// absence of this token means there are no results before this - /// batch, i.e. this is the first batch. - QString prevBatch; - - /// An estimate on the total number of public rooms, if the - /// server has an estimate. - Omittable totalRoomCountEstimate; -}; - -template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const PublicRoomsResponse& pod) - { - addParam<>(jo, QStringLiteral("chunk"), pod.chunk); - addParam(jo, QStringLiteral("next_batch"), pod.nextBatch); - addParam(jo, QStringLiteral("prev_batch"), pod.prevBatch); - addParam(jo, QStringLiteral("total_room_count_estimate"), - pod.totalRoomCountEstimate); - } - static void fillFrom(const QJsonObject& jo, PublicRoomsResponse& pod) - { - fromJson(jo.value("chunk"_ls), pod.chunk); - fromJson(jo.value("next_batch"_ls), pod.nextBatch); - fromJson(jo.value("prev_batch"_ls), pod.prevBatch); - fromJson(jo.value("total_room_count_estimate"_ls), - pod.totalRoomCountEstimate); - } -}; - } // namespace Quotient -- cgit v1.2.3 From ed05d9d589fe3d36bd3714e648016352179afbef Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Sat, 11 Jun 2022 19:42:08 +0200 Subject: Regenerate API files using latest matrix-spec New: - refresh tokens support (changes in login.* and registration.*; RefreshJob); - GetRelatingEvents[WithRelType[AndEventType]]Job Changed space_hierarchy.*: - childrenState is of type StateEvents now; limit and maxDepth are (omittable) integers, not doubles. - no more unused `stripped_state.h` file inclusion. --- .../schema/core-event-schema/stripped_state.h | 44 ---- lib/csapi/login.cpp | 4 +- lib/csapi/login.h | 30 ++- lib/csapi/refresh.cpp | 17 ++ lib/csapi/refresh.h | 65 +++++ lib/csapi/registration.cpp | 4 +- lib/csapi/registration.h | 32 ++- lib/csapi/relations.cpp | 111 +++++++++ lib/csapi/relations.h | 277 +++++++++++++++++++++ lib/csapi/space_hierarchy.cpp | 12 +- lib/csapi/space_hierarchy.h | 17 +- 11 files changed, 535 insertions(+), 78 deletions(-) delete mode 100644 event-schemas/schema/core-event-schema/stripped_state.h create mode 100644 lib/csapi/refresh.cpp create mode 100644 lib/csapi/refresh.h create mode 100644 lib/csapi/relations.cpp create mode 100644 lib/csapi/relations.h (limited to 'lib/csapi') diff --git a/event-schemas/schema/core-event-schema/stripped_state.h b/event-schemas/schema/core-event-schema/stripped_state.h deleted file mode 100644 index 742b0a56..00000000 --- a/event-schemas/schema/core-event-schema/stripped_state.h +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "converters.h" - -namespace Quotient { -/// A stripped down state event, with only the `type`, `state_key`, -/// `sender`, and `content` keys. -struct StrippedStateEvent { - /// The `content` for the event. - QJsonObject content; - - /// The `state_key` for the event. - QString stateKey; - - /// The `type` for the event. - QString type; - - /// The `sender` for the event. - QString sender; -}; - -template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const StrippedStateEvent& pod) - { - addParam<>(jo, QStringLiteral("content"), pod.content); - addParam<>(jo, QStringLiteral("state_key"), pod.stateKey); - addParam<>(jo, QStringLiteral("type"), pod.type); - addParam<>(jo, QStringLiteral("sender"), pod.sender); - } - static void fillFrom(const QJsonObject& jo, StrippedStateEvent& pod) - { - fromJson(jo.value("content"_ls), pod.content); - fromJson(jo.value("state_key"_ls), pod.stateKey); - fromJson(jo.value("type"_ls), pod.type); - fromJson(jo.value("sender"_ls), pod.sender); - } -}; - -} // namespace Quotient diff --git a/lib/csapi/login.cpp b/lib/csapi/login.cpp index b2175a05..5e007d8f 100644 --- a/lib/csapi/login.cpp +++ b/lib/csapi/login.cpp @@ -21,7 +21,8 @@ LoginJob::LoginJob(const QString& type, const Omittable& identifier, const QString& password, const QString& token, const QString& deviceId, - const QString& initialDeviceDisplayName) + const QString& initialDeviceDisplayName, + Omittable refreshToken) : BaseJob(HttpVerb::Post, QStringLiteral("LoginJob"), makePath("/_matrix/client/v3", "/login"), false) { @@ -33,5 +34,6 @@ LoginJob::LoginJob(const QString& type, addParam(_data, QStringLiteral("device_id"), deviceId); addParam(_data, QStringLiteral("initial_device_display_name"), initialDeviceDisplayName); + addParam(_data, QStringLiteral("refresh_token"), refreshToken); setRequestData(std::move(_data)); } diff --git a/lib/csapi/login.h b/lib/csapi/login.h index ce6951eb..b9f14266 100644 --- a/lib/csapi/login.h +++ b/lib/csapi/login.h @@ -111,12 +111,16 @@ public: * \param initialDeviceDisplayName * A display name to assign to the newly-created device. Ignored * if `device_id` corresponds to a known device. + * + * \param refreshToken + * If true, the client supports refresh tokens. */ explicit LoginJob(const QString& type, const Omittable& identifier = none, const QString& password = {}, const QString& token = {}, const QString& deviceId = {}, - const QString& initialDeviceDisplayName = {}); + const QString& initialDeviceDisplayName = {}, + Omittable refreshToken = none); // Result properties @@ -130,15 +134,23 @@ public: return loadFromJson("access_token"_ls); } - /// The server_name of the homeserver on which the account has - /// been registered. - /// - /// **Deprecated**. Clients should extract the server_name from - /// `user_id` (by splitting at the first colon) if they require - /// it. Note also that `homeserver` is not spelt this way. - QString homeServer() const + /// A refresh token for the account. This token can be used to + /// obtain a new access token when it expires by calling the + /// `/refresh` endpoint. + QString refreshToken() const + { + return loadFromJson("refresh_token"_ls); + } + + /// The lifetime of the access token, in milliseconds. Once + /// the access token has expired a new access token can be + /// obtained by using the provided refresh token. If no + /// refresh token is provided, the client will need to re-log in + /// to obtain a new access token. If not given, the client can + /// assume that the access token will not expire. + Omittable expiresInMs() const { - return loadFromJson("home_server"_ls); + return loadFromJson>("expires_in_ms"_ls); } /// ID of the logged-in device. Will be the same as the diff --git a/lib/csapi/refresh.cpp b/lib/csapi/refresh.cpp new file mode 100644 index 00000000..8d4a34ae --- /dev/null +++ b/lib/csapi/refresh.cpp @@ -0,0 +1,17 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "refresh.h" + +using namespace Quotient; + +RefreshJob::RefreshJob(const QString& refreshToken) + : BaseJob(HttpVerb::Post, QStringLiteral("RefreshJob"), + makePath("/_matrix/client/v3", "/refresh"), false) +{ + QJsonObject _data; + addParam(_data, QStringLiteral("refresh_token"), refreshToken); + setRequestData(std::move(_data)); + addExpectedKey("access_token"); +} diff --git a/lib/csapi/refresh.h b/lib/csapi/refresh.h new file mode 100644 index 00000000..d432802c --- /dev/null +++ b/lib/csapi/refresh.h @@ -0,0 +1,65 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "jobs/basejob.h" + +namespace Quotient { + +/*! \brief Refresh an access token + * + * Refresh an access token. Clients should use the returned access token + * when making subsequent API calls, and store the returned refresh token + * (if given) in order to refresh the new access token when necessary. + * + * After an access token has been refreshed, a server can choose to + * invalidate the old access token immediately, or can choose not to, for + * example if the access token would expire soon anyways. Clients should + * not make any assumptions about the old access token still being valid, + * and should use the newly provided access token instead. + * + * The old refresh token remains valid until the new access token or refresh + * token is used, at which point the old refresh token is revoked. + * + * Note that this endpoint does not require authentication via an + * access token. Authentication is provided via the refresh token. + * + * Application Service identity assertion is disabled for this endpoint. + */ +class QUOTIENT_API RefreshJob : public BaseJob { +public: + /*! \brief Refresh an access token + * + * \param refreshToken + * The refresh token + */ + explicit RefreshJob(const QString& refreshToken = {}); + + // Result properties + + /// The new access token to use. + QString accessToken() const + { + return loadFromJson("access_token"_ls); + } + + /// The new refresh token to use when the access token needs to + /// be refreshed again. If not given, the old refresh token can + /// be re-used. + QString refreshToken() const + { + return loadFromJson("refresh_token"_ls); + } + + /// The lifetime of the access token, in milliseconds. If not + /// given, the client can assume that the access token will not + /// expire. + Omittable expiresInMs() const + { + return loadFromJson>("expires_in_ms"_ls); + } +}; + +} // namespace Quotient diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index aa4b4fad..3541724b 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -18,7 +18,8 @@ RegisterJob::RegisterJob(const QString& kind, const QString& username, const QString& password, const QString& deviceId, const QString& initialDeviceDisplayName, - Omittable inhibitLogin) + Omittable inhibitLogin, + Omittable refreshToken) : BaseJob(HttpVerb::Post, QStringLiteral("RegisterJob"), makePath("/_matrix/client/v3", "/register"), queryToRegister(kind), {}, false) @@ -31,6 +32,7 @@ RegisterJob::RegisterJob(const QString& kind, addParam(_data, QStringLiteral("initial_device_display_name"), initialDeviceDisplayName); addParam(_data, QStringLiteral("inhibit_login"), inhibitLogin); + addParam(_data, QStringLiteral("refresh_token"), refreshToken); setRequestData(std::move(_data)); addExpectedKey("user_id"); } diff --git a/lib/csapi/registration.h b/lib/csapi/registration.h index 39840008..7a20cab8 100644 --- a/lib/csapi/registration.h +++ b/lib/csapi/registration.h @@ -93,6 +93,9 @@ public: * If true, an `access_token` and `device_id` should not be * returned from this call, therefore preventing an automatic * login. Defaults to false. + * + * \param refreshToken + * If true, the client supports refresh tokens. */ explicit RegisterJob(const QString& kind = QStringLiteral("user"), const Omittable& auth = none, @@ -100,7 +103,8 @@ public: const QString& password = {}, const QString& deviceId = {}, const QString& initialDeviceDisplayName = {}, - Omittable inhibitLogin = none); + Omittable inhibitLogin = none, + Omittable refreshToken = none); // Result properties @@ -118,15 +122,27 @@ public: return loadFromJson("access_token"_ls); } - /// The server_name of the homeserver on which the account has - /// been registered. + /// A refresh token for the account. This token can be used to + /// obtain a new access token when it expires by calling the + /// `/refresh` endpoint. + /// + /// Omitted if the `inhibit_login` option is false. + QString refreshToken() const + { + return loadFromJson("refresh_token"_ls); + } + + /// The lifetime of the access token, in milliseconds. Once + /// the access token has expired a new access token can be + /// obtained by using the provided refresh token. If no + /// refresh token is provided, the client will need to re-log in + /// to obtain a new access token. If not given, the client can + /// assume that the access token will not expire. /// - /// **Deprecated**. Clients should extract the server_name from - /// `user_id` (by splitting at the first colon) if they require - /// it. Note also that `homeserver` is not spelt this way. - QString homeServer() const + /// Omitted if the `inhibit_login` option is false. + Omittable expiresInMs() const { - return loadFromJson("home_server"_ls); + return loadFromJson>("expires_in_ms"_ls); } /// ID of the registered device. Will be the same as the diff --git a/lib/csapi/relations.cpp b/lib/csapi/relations.cpp new file mode 100644 index 00000000..8bcecee4 --- /dev/null +++ b/lib/csapi/relations.cpp @@ -0,0 +1,111 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "relations.h" + +using namespace Quotient; + +auto queryToGetRelatingEvents(const QString& from, const QString& to, + Omittable limit) +{ + QUrlQuery _q; + addParam(_q, QStringLiteral("from"), from); + addParam(_q, QStringLiteral("to"), to); + addParam(_q, QStringLiteral("limit"), limit); + return _q; +} + +QUrl GetRelatingEventsJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, + const QString& eventId, + const QString& from, const QString& to, + Omittable limit) +{ + return BaseJob::makeRequestUrl(std::move(baseUrl), + makePath("/_matrix/client/v1", "/rooms/", + roomId, "/relations/", eventId), + queryToGetRelatingEvents(from, to, limit)); +} + +GetRelatingEventsJob::GetRelatingEventsJob(const QString& roomId, + const QString& eventId, + const QString& from, + const QString& to, + Omittable limit) + : BaseJob(HttpVerb::Get, QStringLiteral("GetRelatingEventsJob"), + makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", + eventId), + queryToGetRelatingEvents(from, to, limit)) +{ + addExpectedKey("chunk"); +} + +auto queryToGetRelatingEventsWithRelType(const QString& from, const QString& to, + Omittable limit) +{ + QUrlQuery _q; + addParam(_q, QStringLiteral("from"), from); + addParam(_q, QStringLiteral("to"), to); + addParam(_q, QStringLiteral("limit"), limit); + return _q; +} + +QUrl GetRelatingEventsWithRelTypeJob::makeRequestUrl( + QUrl baseUrl, const QString& roomId, const QString& eventId, + const QString& relType, const QString& from, const QString& to, + Omittable limit) +{ + return BaseJob::makeRequestUrl( + std::move(baseUrl), + makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", + eventId, "/", relType), + queryToGetRelatingEventsWithRelType(from, to, limit)); +} + +GetRelatingEventsWithRelTypeJob::GetRelatingEventsWithRelTypeJob( + const QString& roomId, const QString& eventId, const QString& relType, + const QString& from, const QString& to, Omittable limit) + : BaseJob(HttpVerb::Get, QStringLiteral("GetRelatingEventsWithRelTypeJob"), + makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", + eventId, "/", relType), + queryToGetRelatingEventsWithRelType(from, to, limit)) +{ + addExpectedKey("chunk"); +} + +auto queryToGetRelatingEventsWithRelTypeAndEventType(const QString& from, + const QString& to, + Omittable limit) +{ + QUrlQuery _q; + addParam(_q, QStringLiteral("from"), from); + addParam(_q, QStringLiteral("to"), to); + addParam(_q, QStringLiteral("limit"), limit); + return _q; +} + +QUrl GetRelatingEventsWithRelTypeAndEventTypeJob::makeRequestUrl( + QUrl baseUrl, const QString& roomId, const QString& eventId, + const QString& relType, const QString& eventType, const QString& from, + const QString& to, Omittable limit) +{ + return BaseJob::makeRequestUrl( + std::move(baseUrl), + makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", + eventId, "/", relType, "/", eventType), + queryToGetRelatingEventsWithRelTypeAndEventType(from, to, limit)); +} + +GetRelatingEventsWithRelTypeAndEventTypeJob:: + GetRelatingEventsWithRelTypeAndEventTypeJob( + const QString& roomId, const QString& eventId, const QString& relType, + const QString& eventType, const QString& from, const QString& to, + Omittable limit) + : BaseJob(HttpVerb::Get, + QStringLiteral("GetRelatingEventsWithRelTypeAndEventTypeJob"), + makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", + eventId, "/", relType, "/", eventType), + queryToGetRelatingEventsWithRelTypeAndEventType(from, to, limit)) +{ + addExpectedKey("chunk"); +} diff --git a/lib/csapi/relations.h b/lib/csapi/relations.h new file mode 100644 index 00000000..985a43b5 --- /dev/null +++ b/lib/csapi/relations.h @@ -0,0 +1,277 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "events/eventloader.h" +#include "jobs/basejob.h" + +namespace Quotient { + +/*! \brief Get the child events for a given parent event. + * + * Retrieve all of the child events for a given parent event. + * + * Note that when paginating the `from` token should be "after" the `to` token + * in terms of topological ordering, because it is only possible to paginate + * "backwards" through events, starting at `from`. + * + * For example, passing a `from` token from page 2 of the results, and a `to` + * token from page 1, would return the empty set. The caller can use a `from` + * token from page 1 and a `to` token from page 2 to paginate over the same + * range, however. + */ +class QUOTIENT_API GetRelatingEventsJob : public BaseJob { +public: + /*! \brief Get the child events for a given parent event. + * + * \param roomId + * The ID of the room containing the parent event. + * + * \param eventId + * The ID of the parent event whose child events are to be returned. + * + * \param from + * The pagination token to start returning results from. If not supplied, + * results start at the most recent topological event known to the server. + * + * Can be a `next_batch` token from a previous call, or a returned + * `start` token from + * [`/messages`](/client-server-api/#get_matrixclientv3roomsroomidmessages), + * or a `next_batch` token from + * [`/sync`](/client-server-api/#get_matrixclientv3sync). + * + * \param to + * The pagination token to stop returning results at. If not supplied, + * results continue up to `limit` or until there are no more events. + * + * Like `from`, this can be a previous token from a prior call to this + * endpoint or from `/messages` or `/sync`. + * + * \param limit + * The maximum number of results to return in a single `chunk`. The server + * can and should apply a maximum value to this parameter to avoid large + * responses. + * + * Similarly, the server should apply a default value when not supplied. + */ + explicit GetRelatingEventsJob(const QString& roomId, const QString& eventId, + const QString& from = {}, + const QString& to = {}, + Omittable limit = none); + + /*! \brief Construct a URL without creating a full-fledged job object + * + * This function can be used when a URL for GetRelatingEventsJob + * is necessary but the job itself isn't. + */ + static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, + const QString& eventId, const QString& from = {}, + const QString& to = {}, + Omittable limit = none); + + // Result properties + + /// The child events of the requested event, ordered topologically + /// most-recent first. + RoomEvents chunk() { return takeFromJson("chunk"_ls); } + + /// An opaque string representing a pagination token. The absence of this + /// token means there are no more results to fetch and the client should + /// stop paginating. + QString nextBatch() const { return loadFromJson("next_batch"_ls); } + + /// An opaque string representing a pagination token. The absence of this + /// token means this is the start of the result set, i.e. this is the first + /// batch/page. + QString prevBatch() const { return loadFromJson("prev_batch"_ls); } +}; + +/*! \brief Get the child events for a given parent event, with a given + * `relType`. + * + * Retrieve all of the child events for a given parent event which relate to the + * parent using the given `relType`. + * + * Note that when paginating the `from` token should be "after" the `to` token + * in terms of topological ordering, because it is only possible to paginate + * "backwards" through events, starting at `from`. + * + * For example, passing a `from` token from page 2 of the results, and a `to` + * token from page 1, would return the empty set. The caller can use a `from` + * token from page 1 and a `to` token from page 2 to paginate over the same + * range, however. + */ +class QUOTIENT_API GetRelatingEventsWithRelTypeJob : public BaseJob { +public: + /*! \brief Get the child events for a given parent event, with a given + * `relType`. + * + * \param roomId + * The ID of the room containing the parent event. + * + * \param eventId + * The ID of the parent event whose child events are to be returned. + * + * \param relType + * The [relationship type](/client-server-api/#relationship-types) to + * search for. + * + * \param from + * The pagination token to start returning results from. If not supplied, + * results start at the most recent topological event known to the server. + * + * Can be a `next_batch` token from a previous call, or a returned + * `start` token from + * [`/messages`](/client-server-api/#get_matrixclientv3roomsroomidmessages), + * or a `next_batch` token from + * [`/sync`](/client-server-api/#get_matrixclientv3sync). + * + * \param to + * The pagination token to stop returning results at. If not supplied, + * results continue up to `limit` or until there are no more events. + * + * Like `from`, this can be a previous token from a prior call to this + * endpoint or from `/messages` or `/sync`. + * + * \param limit + * The maximum number of results to return in a single `chunk`. The server + * can and should apply a maximum value to this parameter to avoid large + * responses. + * + * Similarly, the server should apply a default value when not supplied. + */ + explicit GetRelatingEventsWithRelTypeJob(const QString& roomId, + const QString& eventId, + const QString& relType, + const QString& from = {}, + const QString& to = {}, + Omittable limit = none); + + /*! \brief Construct a URL without creating a full-fledged job object + * + * This function can be used when a URL for GetRelatingEventsWithRelTypeJob + * is necessary but the job itself isn't. + */ + static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, + const QString& eventId, const QString& relType, + const QString& from = {}, const QString& to = {}, + Omittable limit = none); + + // Result properties + + /// The child events of the requested event, ordered topologically + /// most-recent first. The events returned will match the `relType` + /// supplied in the URL. + RoomEvents chunk() { return takeFromJson("chunk"_ls); } + + /// An opaque string representing a pagination token. The absence of this + /// token means there are no more results to fetch and the client should + /// stop paginating. + QString nextBatch() const { return loadFromJson("next_batch"_ls); } + + /// An opaque string representing a pagination token. The absence of this + /// token means this is the start of the result set, i.e. this is the first + /// batch/page. + QString prevBatch() const { return loadFromJson("prev_batch"_ls); } +}; + +/*! \brief Get the child events for a given parent event, with a given `relType` + * and `eventType`. + * + * Retrieve all of the child events for a given parent event which relate to the + * parent using the given `relType` and have the given `eventType`. + * + * Note that when paginating the `from` token should be "after" the `to` token + * in terms of topological ordering, because it is only possible to paginate + * "backwards" through events, starting at `from`. + * + * For example, passing a `from` token from page 2 of the results, and a `to` + * token from page 1, would return the empty set. The caller can use a `from` + * token from page 1 and a `to` token from page 2 to paginate over the same + * range, however. + */ +class QUOTIENT_API GetRelatingEventsWithRelTypeAndEventTypeJob + : public BaseJob { +public: + /*! \brief Get the child events for a given parent event, with a given + * `relType` and `eventType`. + * + * \param roomId + * The ID of the room containing the parent event. + * + * \param eventId + * The ID of the parent event whose child events are to be returned. + * + * \param relType + * The [relationship type](/client-server-api/#relationship-types) to + * search for. + * + * \param eventType + * The event type of child events to search for. + * + * Note that in encrypted rooms this will typically always be + * `m.room.encrypted` regardless of the event type contained within the + * encrypted payload. + * + * \param from + * The pagination token to start returning results from. If not supplied, + * results start at the most recent topological event known to the server. + * + * Can be a `next_batch` token from a previous call, or a returned + * `start` token from + * [`/messages`](/client-server-api/#get_matrixclientv3roomsroomidmessages), + * or a `next_batch` token from + * [`/sync`](/client-server-api/#get_matrixclientv3sync). + * + * \param to + * The pagination token to stop returning results at. If not supplied, + * results continue up to `limit` or until there are no more events. + * + * Like `from`, this can be a previous token from a prior call to this + * endpoint or from `/messages` or `/sync`. + * + * \param limit + * The maximum number of results to return in a single `chunk`. The server + * can and should apply a maximum value to this parameter to avoid large + * responses. + * + * Similarly, the server should apply a default value when not supplied. + */ + explicit GetRelatingEventsWithRelTypeAndEventTypeJob( + const QString& roomId, const QString& eventId, const QString& relType, + const QString& eventType, const QString& from = {}, + const QString& to = {}, Omittable limit = none); + + /*! \brief Construct a URL without creating a full-fledged job object + * + * This function can be used when a URL for + * GetRelatingEventsWithRelTypeAndEventTypeJob is necessary but the job + * itself isn't. + */ + static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, + const QString& eventId, const QString& relType, + const QString& eventType, + const QString& from = {}, const QString& to = {}, + Omittable limit = none); + + // Result properties + + /// The child events of the requested event, ordered topologically + /// most-recent first. The events returned will match the `relType` and + /// `eventType` supplied in the URL. + RoomEvents chunk() { return takeFromJson("chunk"_ls); } + + /// An opaque string representing a pagination token. The absence of this + /// token means there are no more results to fetch and the client should + /// stop paginating. + QString nextBatch() const { return loadFromJson("next_batch"_ls); } + + /// An opaque string representing a pagination token. The absence of this + /// token means this is the start of the result set, i.e. this is the first + /// batch/page. + QString prevBatch() const { return loadFromJson("prev_batch"_ls); } +}; + +} // namespace Quotient diff --git a/lib/csapi/space_hierarchy.cpp b/lib/csapi/space_hierarchy.cpp index 7c17ce8a..7b5c7eac 100644 --- a/lib/csapi/space_hierarchy.cpp +++ b/lib/csapi/space_hierarchy.cpp @@ -7,8 +7,8 @@ using namespace Quotient; auto queryToGetSpaceHierarchy(Omittable suggestedOnly, - Omittable limit, - Omittable maxDepth, const QString& from) + Omittable limit, Omittable maxDepth, + const QString& from) { QUrlQuery _q; addParam(_q, QStringLiteral("suggested_only"), suggestedOnly); @@ -20,8 +20,8 @@ auto queryToGetSpaceHierarchy(Omittable suggestedOnly, QUrl GetSpaceHierarchyJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, Omittable suggestedOnly, - Omittable limit, - Omittable maxDepth, + Omittable limit, + Omittable maxDepth, const QString& from) { return BaseJob::makeRequestUrl( @@ -32,8 +32,8 @@ QUrl GetSpaceHierarchyJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, GetSpaceHierarchyJob::GetSpaceHierarchyJob(const QString& roomId, Omittable suggestedOnly, - Omittable limit, - Omittable maxDepth, + Omittable limit, + Omittable maxDepth, const QString& from) : BaseJob(HttpVerb::Get, QStringLiteral("GetSpaceHierarchyJob"), makePath("/_matrix/client/v1", "/rooms/", roomId, "/hierarchy"), diff --git a/lib/csapi/space_hierarchy.h b/lib/csapi/space_hierarchy.h index 5b3c1f80..7a421be8 100644 --- a/lib/csapi/space_hierarchy.h +++ b/lib/csapi/space_hierarchy.h @@ -4,8 +4,7 @@ #pragma once -#include "csapi/../../event-schemas/schema/core-event-schema/stripped_state.h" - +#include "events/eventloader.h" #include "jobs/basejob.h" namespace Quotient { @@ -66,7 +65,7 @@ public: /// added `origin_server_ts` key. /// /// If the room is not a space-room, this should be empty. - QVector childrenState; + StateEvents childrenState; }; // Construction/destruction @@ -103,8 +102,8 @@ public: */ explicit GetSpaceHierarchyJob(const QString& roomId, Omittable suggestedOnly = none, - Omittable limit = none, - Omittable maxDepth = none, + Omittable limit = none, + Omittable maxDepth = none, const QString& from = {}); /*! \brief Construct a URL without creating a full-fledged job object @@ -114,16 +113,16 @@ public: */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, Omittable suggestedOnly = none, - Omittable limit = none, - Omittable maxDepth = none, + Omittable limit = none, + Omittable maxDepth = none, const QString& from = {}); // Result properties /// The rooms for the current page, with the current filters. - QVector rooms() const + std::vector rooms() { - return loadFromJson>("rooms"_ls); + return takeFromJson>("rooms"_ls); } /// A token to supply to `from` to keep paginating the responses. Not -- cgit v1.2.3 From 2dd85770cbfd6d9c7506757f25765c05ef74987d Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Thu, 16 Jun 2022 13:29:02 +0200 Subject: Regenerate API files upon the previous commit --- lib/csapi/account-data.cpp | 4 +-- lib/csapi/administrative_contact.cpp | 52 ++++++++++++++++----------------- lib/csapi/appservice_room_directory.cpp | 6 ++-- lib/csapi/banning.cpp | 16 +++++----- lib/csapi/content-repo.cpp | 2 +- lib/csapi/create_room.cpp | 30 ++++++++++--------- lib/csapi/cross_signing.cpp | 14 ++++----- lib/csapi/device_management.cpp | 20 ++++++------- lib/csapi/directory.cpp | 6 ++-- lib/csapi/filter.cpp | 2 +- lib/csapi/inviting.cpp | 8 ++--- lib/csapi/joining.cpp | 16 +++++----- lib/csapi/keys.cpp | 30 ++++++++++--------- lib/csapi/kicking.cpp | 8 ++--- lib/csapi/knocking.cpp | 6 ++-- lib/csapi/leaving.cpp | 6 ++-- lib/csapi/list_public_rooms.cpp | 20 ++++++------- lib/csapi/login.cpp | 20 +++++++------ lib/csapi/openid.cpp | 2 +- lib/csapi/presence.cpp | 8 ++--- lib/csapi/profile.cpp | 12 ++++---- lib/csapi/pusher.cpp | 23 ++++++++------- lib/csapi/pushrules.cpp | 22 +++++++------- lib/csapi/read_markers.cpp | 8 ++--- lib/csapi/receipts.cpp | 2 +- lib/csapi/redaction.cpp | 6 ++-- lib/csapi/refresh.cpp | 7 +++-- lib/csapi/registration.cpp | 48 ++++++++++++++++-------------- lib/csapi/registration.h | 4 +-- lib/csapi/report_content.cpp | 8 ++--- lib/csapi/room_send.cpp | 2 +- lib/csapi/room_state.cpp | 2 +- lib/csapi/room_upgrades.cpp | 6 ++-- lib/csapi/search.cpp | 6 ++-- lib/csapi/tags.cpp | 8 ++--- lib/csapi/third_party_membership.cpp | 12 ++++---- lib/csapi/to_device.cpp | 6 ++-- lib/csapi/typing.cpp | 8 ++--- lib/csapi/users.cpp | 8 ++--- 39 files changed, 243 insertions(+), 231 deletions(-) (limited to 'lib/csapi') diff --git a/lib/csapi/account-data.cpp b/lib/csapi/account-data.cpp index 1343eb98..8c71f6c5 100644 --- a/lib/csapi/account-data.cpp +++ b/lib/csapi/account-data.cpp @@ -12,7 +12,7 @@ SetAccountDataJob::SetAccountDataJob(const QString& userId, const QString& type, makePath("/_matrix/client/v3", "/user/", userId, "/account_data/", type)) { - setRequestData(RequestData(toJson(content))); + setRequestData({ toJson(content) }); } QUrl GetAccountDataJob::makeRequestUrl(QUrl baseUrl, const QString& userId, @@ -37,7 +37,7 @@ SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/account_data/", type)) { - setRequestData(RequestData(toJson(content))); + setRequestData({ toJson(content) }); } QUrl GetAccountDataPerRoomJob::makeRequestUrl(QUrl baseUrl, diff --git a/lib/csapi/administrative_contact.cpp b/lib/csapi/administrative_contact.cpp index f52e2e1f..aa55d934 100644 --- a/lib/csapi/administrative_contact.cpp +++ b/lib/csapi/administrative_contact.cpp @@ -21,9 +21,9 @@ Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds) : BaseJob(HttpVerb::Post, QStringLiteral("Post3PIDsJob"), makePath("/_matrix/client/v3", "/account/3pid")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("three_pid_creds"), threePidCreds); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("three_pid_creds"), threePidCreds); + setRequestData({ _dataJson }); } Add3PIDJob::Add3PIDJob(const QString& clientSecret, const QString& sid, @@ -31,11 +31,11 @@ Add3PIDJob::Add3PIDJob(const QString& clientSecret, const QString& sid, : BaseJob(HttpVerb::Post, QStringLiteral("Add3PIDJob"), makePath("/_matrix/client/v3", "/account/3pid/add")) { - QJsonObject _data; - addParam(_data, QStringLiteral("auth"), auth); - addParam<>(_data, QStringLiteral("client_secret"), clientSecret); - addParam<>(_data, QStringLiteral("sid"), sid); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("auth"), auth); + addParam<>(_dataJson, QStringLiteral("client_secret"), clientSecret); + addParam<>(_dataJson, QStringLiteral("sid"), sid); + setRequestData({ _dataJson }); } Bind3PIDJob::Bind3PIDJob(const QString& clientSecret, const QString& idServer, @@ -43,12 +43,12 @@ Bind3PIDJob::Bind3PIDJob(const QString& clientSecret, const QString& idServer, : BaseJob(HttpVerb::Post, QStringLiteral("Bind3PIDJob"), makePath("/_matrix/client/v3", "/account/3pid/bind")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("client_secret"), clientSecret); - addParam<>(_data, QStringLiteral("id_server"), idServer); - addParam<>(_data, QStringLiteral("id_access_token"), idAccessToken); - addParam<>(_data, QStringLiteral("sid"), sid); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("client_secret"), clientSecret); + addParam<>(_dataJson, QStringLiteral("id_server"), idServer); + addParam<>(_dataJson, QStringLiteral("id_access_token"), idAccessToken); + addParam<>(_dataJson, QStringLiteral("sid"), sid); + setRequestData({ _dataJson }); } Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium, @@ -57,11 +57,11 @@ Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium, : BaseJob(HttpVerb::Post, QStringLiteral("Delete3pidFromAccountJob"), makePath("/_matrix/client/v3", "/account/3pid/delete")) { - QJsonObject _data; - addParam(_data, QStringLiteral("id_server"), idServer); - addParam<>(_data, QStringLiteral("medium"), medium); - addParam<>(_data, QStringLiteral("address"), address); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("id_server"), idServer); + addParam<>(_dataJson, QStringLiteral("medium"), medium); + addParam<>(_dataJson, QStringLiteral("address"), address); + setRequestData({ _dataJson }); addExpectedKey("id_server_unbind_result"); } @@ -71,11 +71,11 @@ Unbind3pidFromAccountJob::Unbind3pidFromAccountJob(const QString& medium, : BaseJob(HttpVerb::Post, QStringLiteral("Unbind3pidFromAccountJob"), makePath("/_matrix/client/v3", "/account/3pid/unbind")) { - QJsonObject _data; - addParam(_data, QStringLiteral("id_server"), idServer); - addParam<>(_data, QStringLiteral("medium"), medium); - addParam<>(_data, QStringLiteral("address"), address); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("id_server"), idServer); + addParam<>(_dataJson, QStringLiteral("medium"), medium); + addParam<>(_dataJson, QStringLiteral("address"), address); + setRequestData({ _dataJson }); addExpectedKey("id_server_unbind_result"); } @@ -86,7 +86,7 @@ RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob( "/account/3pid/email/requestToken"), false) { - setRequestData(RequestData(toJson(body))); + setRequestData({ toJson(body) }); } RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob( @@ -96,5 +96,5 @@ RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob( "/account/3pid/msisdn/requestToken"), false) { - setRequestData(RequestData(toJson(body))); + setRequestData({ toJson(body) }); } diff --git a/lib/csapi/appservice_room_directory.cpp b/lib/csapi/appservice_room_directory.cpp index c989559f..dff7e032 100644 --- a/lib/csapi/appservice_room_directory.cpp +++ b/lib/csapi/appservice_room_directory.cpp @@ -15,7 +15,7 @@ UpdateAppserviceRoomDirectoryVisibilityJob:: makePath("/_matrix/client/v3", "/directory/list/appservice/", networkId, "/", roomId)) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("visibility"), visibility); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("visibility"), visibility); + setRequestData({ _dataJson }); } diff --git a/lib/csapi/banning.cpp b/lib/csapi/banning.cpp index 77047e89..e04075b7 100644 --- a/lib/csapi/banning.cpp +++ b/lib/csapi/banning.cpp @@ -11,10 +11,10 @@ BanJob::BanJob(const QString& roomId, const QString& userId, : BaseJob(HttpVerb::Post, QStringLiteral("BanJob"), makePath("/_matrix/client/v3", "/rooms/", roomId, "/ban")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("user_id"), userId); - addParam(_data, QStringLiteral("reason"), reason); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("user_id"), userId); + addParam(_dataJson, QStringLiteral("reason"), reason); + setRequestData({ _dataJson }); } UnbanJob::UnbanJob(const QString& roomId, const QString& userId, @@ -22,8 +22,8 @@ UnbanJob::UnbanJob(const QString& roomId, const QString& userId, : BaseJob(HttpVerb::Post, QStringLiteral("UnbanJob"), makePath("/_matrix/client/v3", "/rooms/", roomId, "/unban")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("user_id"), userId); - addParam(_data, QStringLiteral("reason"), reason); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("user_id"), userId); + addParam(_dataJson, QStringLiteral("reason"), reason); + setRequestData({ _dataJson }); } diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index 7d740cb7..6f6738af 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -20,7 +20,7 @@ UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, queryToUploadContent(filename)) { setRequestHeader("Content-Type", contentType.toLatin1()); - setRequestData(RequestData(content)); + setRequestData({ content }); addExpectedKey("content_uri"); } diff --git a/lib/csapi/create_room.cpp b/lib/csapi/create_room.cpp index 834d8c13..afae80af 100644 --- a/lib/csapi/create_room.cpp +++ b/lib/csapi/create_room.cpp @@ -18,22 +18,24 @@ CreateRoomJob::CreateRoomJob(const QString& visibility, : BaseJob(HttpVerb::Post, QStringLiteral("CreateRoomJob"), makePath("/_matrix/client/v3", "/createRoom")) { - QJsonObject _data; - addParam(_data, QStringLiteral("visibility"), visibility); - addParam(_data, QStringLiteral("room_alias_name"), + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("visibility"), visibility); + addParam(_dataJson, QStringLiteral("room_alias_name"), roomAliasName); - addParam(_data, QStringLiteral("name"), name); - addParam(_data, QStringLiteral("topic"), topic); - addParam(_data, QStringLiteral("invite"), invite); - addParam(_data, QStringLiteral("invite_3pid"), invite3pid); - addParam(_data, QStringLiteral("room_version"), roomVersion); - addParam(_data, QStringLiteral("creation_content"), + addParam(_dataJson, QStringLiteral("name"), name); + addParam(_dataJson, QStringLiteral("topic"), topic); + addParam(_dataJson, QStringLiteral("invite"), invite); + addParam(_dataJson, QStringLiteral("invite_3pid"), invite3pid); + addParam(_dataJson, QStringLiteral("room_version"), roomVersion); + addParam(_dataJson, QStringLiteral("creation_content"), creationContent); - addParam(_data, QStringLiteral("initial_state"), initialState); - addParam(_data, QStringLiteral("preset"), preset); - addParam(_data, QStringLiteral("is_direct"), isDirect); - addParam(_data, QStringLiteral("power_level_content_override"), + addParam(_dataJson, QStringLiteral("initial_state"), + initialState); + addParam(_dataJson, QStringLiteral("preset"), preset); + addParam(_dataJson, QStringLiteral("is_direct"), isDirect); + addParam(_dataJson, + QStringLiteral("power_level_content_override"), powerLevelContentOverride); - setRequestData(std::move(_data)); + setRequestData({ _dataJson }); addExpectedKey("room_id"); } diff --git a/lib/csapi/cross_signing.cpp b/lib/csapi/cross_signing.cpp index c6c34772..83136d71 100644 --- a/lib/csapi/cross_signing.cpp +++ b/lib/csapi/cross_signing.cpp @@ -14,14 +14,14 @@ UploadCrossSigningKeysJob::UploadCrossSigningKeysJob( : BaseJob(HttpVerb::Post, QStringLiteral("UploadCrossSigningKeysJob"), makePath("/_matrix/client/v3", "/keys/device_signing/upload")) { - QJsonObject _data; - addParam(_data, QStringLiteral("master_key"), masterKey); - addParam(_data, QStringLiteral("self_signing_key"), + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("master_key"), masterKey); + addParam(_dataJson, QStringLiteral("self_signing_key"), selfSigningKey); - addParam(_data, QStringLiteral("user_signing_key"), + addParam(_dataJson, QStringLiteral("user_signing_key"), userSigningKey); - addParam(_data, QStringLiteral("auth"), auth); - setRequestData(std::move(_data)); + addParam(_dataJson, QStringLiteral("auth"), auth); + setRequestData({ _dataJson }); } UploadCrossSigningSignaturesJob::UploadCrossSigningSignaturesJob( @@ -29,5 +29,5 @@ UploadCrossSigningSignaturesJob::UploadCrossSigningSignaturesJob( : BaseJob(HttpVerb::Post, QStringLiteral("UploadCrossSigningSignaturesJob"), makePath("/_matrix/client/v3", "/keys/signatures/upload")) { - setRequestData(RequestData(toJson(signatures))); + setRequestData({ toJson(signatures) }); } diff --git a/lib/csapi/device_management.cpp b/lib/csapi/device_management.cpp index fb58633c..6f2badee 100644 --- a/lib/csapi/device_management.cpp +++ b/lib/csapi/device_management.cpp @@ -34,9 +34,9 @@ UpdateDeviceJob::UpdateDeviceJob(const QString& deviceId, : BaseJob(HttpVerb::Put, QStringLiteral("UpdateDeviceJob"), makePath("/_matrix/client/v3", "/devices/", deviceId)) { - QJsonObject _data; - addParam(_data, QStringLiteral("display_name"), displayName); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("display_name"), displayName); + setRequestData({ _dataJson }); } DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, @@ -44,9 +44,9 @@ DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteDeviceJob"), makePath("/_matrix/client/v3", "/devices/", deviceId)) { - QJsonObject _data; - addParam(_data, QStringLiteral("auth"), auth); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("auth"), auth); + setRequestData({ _dataJson }); } DeleteDevicesJob::DeleteDevicesJob(const QStringList& devices, @@ -54,8 +54,8 @@ DeleteDevicesJob::DeleteDevicesJob(const QStringList& devices, : BaseJob(HttpVerb::Post, QStringLiteral("DeleteDevicesJob"), makePath("/_matrix/client/v3", "/delete_devices")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("devices"), devices); - addParam(_data, QStringLiteral("auth"), auth); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("devices"), devices); + addParam(_dataJson, QStringLiteral("auth"), auth); + setRequestData({ _dataJson }); } diff --git a/lib/csapi/directory.cpp b/lib/csapi/directory.cpp index 86b14f3a..c1255bb1 100644 --- a/lib/csapi/directory.cpp +++ b/lib/csapi/directory.cpp @@ -10,9 +10,9 @@ SetRoomAliasJob::SetRoomAliasJob(const QString& roomAlias, const QString& roomId : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomAliasJob"), makePath("/_matrix/client/v3", "/directory/room/", roomAlias)) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("room_id"), roomId); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("room_id"), roomId); + setRequestData({ _dataJson }); } QUrl GetRoomIdByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) diff --git a/lib/csapi/filter.cpp b/lib/csapi/filter.cpp index 57cb1271..2469fbd1 100644 --- a/lib/csapi/filter.cpp +++ b/lib/csapi/filter.cpp @@ -10,7 +10,7 @@ DefineFilterJob::DefineFilterJob(const QString& userId, const Filter& filter) : BaseJob(HttpVerb::Post, QStringLiteral("DefineFilterJob"), makePath("/_matrix/client/v3", "/user/", userId, "/filter")) { - setRequestData(RequestData(toJson(filter))); + setRequestData({ toJson(filter) }); addExpectedKey("filter_id"); } diff --git a/lib/csapi/inviting.cpp b/lib/csapi/inviting.cpp index bc1863ce..41a8b5be 100644 --- a/lib/csapi/inviting.cpp +++ b/lib/csapi/inviting.cpp @@ -11,8 +11,8 @@ InviteUserJob::InviteUserJob(const QString& roomId, const QString& userId, : BaseJob(HttpVerb::Post, QStringLiteral("InviteUserJob"), makePath("/_matrix/client/v3", "/rooms/", roomId, "/invite")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("user_id"), userId); - addParam(_data, QStringLiteral("reason"), reason); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("user_id"), userId); + addParam(_dataJson, QStringLiteral("reason"), reason); + setRequestData({ _dataJson }); } diff --git a/lib/csapi/joining.cpp b/lib/csapi/joining.cpp index b05bd964..cdba95e9 100644 --- a/lib/csapi/joining.cpp +++ b/lib/csapi/joining.cpp @@ -12,11 +12,11 @@ JoinRoomByIdJob::JoinRoomByIdJob( : BaseJob(HttpVerb::Post, QStringLiteral("JoinRoomByIdJob"), makePath("/_matrix/client/v3", "/rooms/", roomId, "/join")) { - QJsonObject _data; - addParam(_data, QStringLiteral("third_party_signed"), + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("third_party_signed"), thirdPartySigned); - addParam(_data, QStringLiteral("reason"), reason); - setRequestData(std::move(_data)); + addParam(_dataJson, QStringLiteral("reason"), reason); + setRequestData({ _dataJson }); addExpectedKey("room_id"); } @@ -35,10 +35,10 @@ JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, makePath("/_matrix/client/v3", "/join/", roomIdOrAlias), queryToJoinRoom(serverName)) { - QJsonObject _data; - addParam(_data, QStringLiteral("third_party_signed"), + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("third_party_signed"), thirdPartySigned); - addParam(_data, QStringLiteral("reason"), reason); - setRequestData(std::move(_data)); + addParam(_dataJson, QStringLiteral("reason"), reason); + setRequestData({ _dataJson }); addExpectedKey("room_id"); } diff --git a/lib/csapi/keys.cpp b/lib/csapi/keys.cpp index d4996664..2e4978f2 100644 --- a/lib/csapi/keys.cpp +++ b/lib/csapi/keys.cpp @@ -12,11 +12,13 @@ UploadKeysJob::UploadKeysJob(const Omittable& deviceKeys, : BaseJob(HttpVerb::Post, QStringLiteral("UploadKeysJob"), makePath("/_matrix/client/v3", "/keys/upload")) { - QJsonObject _data; - addParam(_data, QStringLiteral("device_keys"), deviceKeys); - addParam(_data, QStringLiteral("one_time_keys"), oneTimeKeys); - addParam(_data, QStringLiteral("fallback_keys"), fallbackKeys); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("device_keys"), deviceKeys); + addParam(_dataJson, QStringLiteral("one_time_keys"), + oneTimeKeys); + addParam(_dataJson, QStringLiteral("fallback_keys"), + fallbackKeys); + setRequestData({ _dataJson }); addExpectedKey("one_time_key_counts"); } @@ -25,11 +27,11 @@ QueryKeysJob::QueryKeysJob(const QHash& deviceKeys, : BaseJob(HttpVerb::Post, QStringLiteral("QueryKeysJob"), makePath("/_matrix/client/v3", "/keys/query")) { - QJsonObject _data; - addParam(_data, QStringLiteral("timeout"), timeout); - addParam<>(_data, QStringLiteral("device_keys"), deviceKeys); - addParam(_data, QStringLiteral("token"), token); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("timeout"), timeout); + addParam<>(_dataJson, QStringLiteral("device_keys"), deviceKeys); + addParam(_dataJson, QStringLiteral("token"), token); + setRequestData({ _dataJson }); } ClaimKeysJob::ClaimKeysJob( @@ -38,10 +40,10 @@ ClaimKeysJob::ClaimKeysJob( : BaseJob(HttpVerb::Post, QStringLiteral("ClaimKeysJob"), makePath("/_matrix/client/v3", "/keys/claim")) { - QJsonObject _data; - addParam(_data, QStringLiteral("timeout"), timeout); - addParam<>(_data, QStringLiteral("one_time_keys"), oneTimeKeys); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("timeout"), timeout); + addParam<>(_dataJson, QStringLiteral("one_time_keys"), oneTimeKeys); + setRequestData({ _dataJson }); addExpectedKey("one_time_keys"); } diff --git a/lib/csapi/kicking.cpp b/lib/csapi/kicking.cpp index 3bedcb34..4ca39c4c 100644 --- a/lib/csapi/kicking.cpp +++ b/lib/csapi/kicking.cpp @@ -11,8 +11,8 @@ KickJob::KickJob(const QString& roomId, const QString& userId, : BaseJob(HttpVerb::Post, QStringLiteral("KickJob"), makePath("/_matrix/client/v3", "/rooms/", roomId, "/kick")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("user_id"), userId); - addParam(_data, QStringLiteral("reason"), reason); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("user_id"), userId); + addParam(_dataJson, QStringLiteral("reason"), reason); + setRequestData({ _dataJson }); } diff --git a/lib/csapi/knocking.cpp b/lib/csapi/knocking.cpp index ba541643..b9da4b9b 100644 --- a/lib/csapi/knocking.cpp +++ b/lib/csapi/knocking.cpp @@ -19,8 +19,8 @@ KnockRoomJob::KnockRoomJob(const QString& roomIdOrAlias, makePath("/_matrix/client/v3", "/knock/", roomIdOrAlias), queryToKnockRoom(serverName)) { - QJsonObject _data; - addParam(_data, QStringLiteral("reason"), reason); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("reason"), reason); + setRequestData({ _dataJson }); addExpectedKey("room_id"); } diff --git a/lib/csapi/leaving.cpp b/lib/csapi/leaving.cpp index 84340b94..ba91f26a 100644 --- a/lib/csapi/leaving.cpp +++ b/lib/csapi/leaving.cpp @@ -10,9 +10,9 @@ LeaveRoomJob::LeaveRoomJob(const QString& roomId, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("LeaveRoomJob"), makePath("/_matrix/client/v3", "/rooms/", roomId, "/leave")) { - QJsonObject _data; - addParam(_data, QStringLiteral("reason"), reason); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("reason"), reason); + setRequestData({ _dataJson }); } QUrl ForgetRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp index 417e50b3..4deecfc2 100644 --- a/lib/csapi/list_public_rooms.cpp +++ b/lib/csapi/list_public_rooms.cpp @@ -26,9 +26,9 @@ SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob( : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomVisibilityOnDirectoryJob"), makePath("/_matrix/client/v3", "/directory/list/room/", roomId)) { - QJsonObject _data; - addParam(_data, QStringLiteral("visibility"), visibility); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("visibility"), visibility); + setRequestData({ _dataJson }); } auto queryToGetPublicRooms(Omittable limit, const QString& since, @@ -77,14 +77,14 @@ QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, makePath("/_matrix/client/v3", "/publicRooms"), queryToQueryPublicRooms(server)) { - QJsonObject _data; - addParam(_data, QStringLiteral("limit"), limit); - addParam(_data, QStringLiteral("since"), since); - addParam(_data, QStringLiteral("filter"), filter); - addParam(_data, QStringLiteral("include_all_networks"), + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("limit"), limit); + addParam(_dataJson, QStringLiteral("since"), since); + addParam(_dataJson, QStringLiteral("filter"), filter); + addParam(_dataJson, QStringLiteral("include_all_networks"), includeAllNetworks); - addParam(_data, QStringLiteral("third_party_instance_id"), + addParam(_dataJson, QStringLiteral("third_party_instance_id"), thirdPartyInstanceId); - setRequestData(std::move(_data)); + setRequestData({ _dataJson }); addExpectedKey("chunk"); } diff --git a/lib/csapi/login.cpp b/lib/csapi/login.cpp index 5e007d8f..81e603b5 100644 --- a/lib/csapi/login.cpp +++ b/lib/csapi/login.cpp @@ -26,14 +26,16 @@ LoginJob::LoginJob(const QString& type, : BaseJob(HttpVerb::Post, QStringLiteral("LoginJob"), makePath("/_matrix/client/v3", "/login"), false) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("type"), type); - addParam(_data, QStringLiteral("identifier"), identifier); - addParam(_data, QStringLiteral("password"), password); - addParam(_data, QStringLiteral("token"), token); - addParam(_data, QStringLiteral("device_id"), deviceId); - addParam(_data, QStringLiteral("initial_device_display_name"), + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("type"), type); + addParam(_dataJson, QStringLiteral("identifier"), identifier); + addParam(_dataJson, QStringLiteral("password"), password); + addParam(_dataJson, QStringLiteral("token"), token); + addParam(_dataJson, QStringLiteral("device_id"), deviceId); + addParam(_dataJson, + QStringLiteral("initial_device_display_name"), initialDeviceDisplayName); - addParam(_data, QStringLiteral("refresh_token"), refreshToken); - setRequestData(std::move(_data)); + addParam(_dataJson, QStringLiteral("refresh_token"), + refreshToken); + setRequestData({ _dataJson }); } diff --git a/lib/csapi/openid.cpp b/lib/csapi/openid.cpp index 8349e6db..7e89b8a6 100644 --- a/lib/csapi/openid.cpp +++ b/lib/csapi/openid.cpp @@ -12,5 +12,5 @@ RequestOpenIdTokenJob::RequestOpenIdTokenJob(const QString& userId, makePath("/_matrix/client/v3", "/user/", userId, "/openid/request_token")) { - setRequestData(RequestData(toJson(body))); + setRequestData({ toJson(body) }); } diff --git a/lib/csapi/presence.cpp b/lib/csapi/presence.cpp index 6d154ebd..828ccfb7 100644 --- a/lib/csapi/presence.cpp +++ b/lib/csapi/presence.cpp @@ -11,10 +11,10 @@ SetPresenceJob::SetPresenceJob(const QString& userId, const QString& presence, : BaseJob(HttpVerb::Put, QStringLiteral("SetPresenceJob"), makePath("/_matrix/client/v3", "/presence/", userId, "/status")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("presence"), presence); - addParam(_data, QStringLiteral("status_msg"), statusMsg); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("presence"), presence); + addParam(_dataJson, QStringLiteral("status_msg"), statusMsg); + setRequestData({ _dataJson }); } QUrl GetPresenceJob::makeRequestUrl(QUrl baseUrl, const QString& userId) diff --git a/lib/csapi/profile.cpp b/lib/csapi/profile.cpp index 7621d828..f024ed82 100644 --- a/lib/csapi/profile.cpp +++ b/lib/csapi/profile.cpp @@ -12,9 +12,9 @@ SetDisplayNameJob::SetDisplayNameJob(const QString& userId, makePath("/_matrix/client/v3", "/profile/", userId, "/displayname")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("displayname"), displayname); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("displayname"), displayname); + setRequestData({ _dataJson }); } QUrl GetDisplayNameJob::makeRequestUrl(QUrl baseUrl, const QString& userId) @@ -35,9 +35,9 @@ SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QUrl& avatarUrl) : BaseJob(HttpVerb::Put, QStringLiteral("SetAvatarUrlJob"), makePath("/_matrix/client/v3", "/profile/", userId, "/avatar_url")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("avatar_url"), avatarUrl); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("avatar_url"), avatarUrl); + setRequestData({ _dataJson }); } QUrl GetAvatarUrlJob::makeRequestUrl(QUrl baseUrl, const QString& userId) diff --git a/lib/csapi/pusher.cpp b/lib/csapi/pusher.cpp index 498be3ee..fb6595fc 100644 --- a/lib/csapi/pusher.cpp +++ b/lib/csapi/pusher.cpp @@ -25,15 +25,16 @@ PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind, : BaseJob(HttpVerb::Post, QStringLiteral("PostPusherJob"), makePath("/_matrix/client/v3", "/pushers/set")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("pushkey"), pushkey); - addParam<>(_data, QStringLiteral("kind"), kind); - addParam<>(_data, QStringLiteral("app_id"), appId); - addParam<>(_data, QStringLiteral("app_display_name"), appDisplayName); - addParam<>(_data, QStringLiteral("device_display_name"), deviceDisplayName); - addParam(_data, QStringLiteral("profile_tag"), profileTag); - addParam<>(_data, QStringLiteral("lang"), lang); - addParam<>(_data, QStringLiteral("data"), data); - addParam(_data, QStringLiteral("append"), append); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("pushkey"), pushkey); + addParam<>(_dataJson, QStringLiteral("kind"), kind); + addParam<>(_dataJson, QStringLiteral("app_id"), appId); + addParam<>(_dataJson, QStringLiteral("app_display_name"), appDisplayName); + addParam<>(_dataJson, QStringLiteral("device_display_name"), + deviceDisplayName); + addParam(_dataJson, QStringLiteral("profile_tag"), profileTag); + addParam<>(_dataJson, QStringLiteral("lang"), lang); + addParam<>(_dataJson, QStringLiteral("data"), data); + addParam(_dataJson, QStringLiteral("append"), append); + setRequestData({ _dataJson }); } diff --git a/lib/csapi/pushrules.cpp b/lib/csapi/pushrules.cpp index 6b0effd4..2376654a 100644 --- a/lib/csapi/pushrules.cpp +++ b/lib/csapi/pushrules.cpp @@ -69,11 +69,11 @@ SetPushRuleJob::SetPushRuleJob(const QString& scope, const QString& kind, "/", ruleId), queryToSetPushRule(before, after)) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("actions"), actions); - addParam(_data, QStringLiteral("conditions"), conditions); - addParam(_data, QStringLiteral("pattern"), pattern); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("actions"), actions); + addParam(_dataJson, QStringLiteral("conditions"), conditions); + addParam(_dataJson, QStringLiteral("pattern"), pattern); + setRequestData({ _dataJson }); } QUrl IsPushRuleEnabledJob::makeRequestUrl(QUrl baseUrl, const QString& scope, @@ -103,9 +103,9 @@ SetPushRuleEnabledJob::SetPushRuleEnabledJob(const QString& scope, makePath("/_matrix/client/v3", "/pushrules/", scope, "/", kind, "/", ruleId, "/enabled")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("enabled"), enabled); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("enabled"), enabled); + setRequestData({ _dataJson }); } QUrl GetPushRuleActionsJob::makeRequestUrl(QUrl baseUrl, const QString& scope, @@ -136,7 +136,7 @@ SetPushRuleActionsJob::SetPushRuleActionsJob(const QString& scope, makePath("/_matrix/client/v3", "/pushrules/", scope, "/", kind, "/", ruleId, "/actions")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("actions"), actions); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("actions"), actions); + setRequestData({ _dataJson }); } diff --git a/lib/csapi/read_markers.cpp b/lib/csapi/read_markers.cpp index dc84f887..de5f4a9a 100644 --- a/lib/csapi/read_markers.cpp +++ b/lib/csapi/read_markers.cpp @@ -12,8 +12,8 @@ SetReadMarkerJob::SetReadMarkerJob(const QString& roomId, : BaseJob(HttpVerb::Post, QStringLiteral("SetReadMarkerJob"), makePath("/_matrix/client/v3", "/rooms/", roomId, "/read_markers")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("m.fully_read"), mFullyRead); - addParam(_data, QStringLiteral("m.read"), mRead); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("m.fully_read"), mFullyRead); + addParam(_dataJson, QStringLiteral("m.read"), mRead); + setRequestData({ _dataJson }); } diff --git a/lib/csapi/receipts.cpp b/lib/csapi/receipts.cpp index 8feab986..0194603d 100644 --- a/lib/csapi/receipts.cpp +++ b/lib/csapi/receipts.cpp @@ -13,5 +13,5 @@ PostReceiptJob::PostReceiptJob(const QString& roomId, const QString& receiptType makePath("/_matrix/client/v3", "/rooms/", roomId, "/receipt/", receiptType, "/", eventId)) { - setRequestData(RequestData(toJson(receipt))); + setRequestData({ toJson(receipt) }); } diff --git a/lib/csapi/redaction.cpp b/lib/csapi/redaction.cpp index d67cb37b..154abd9b 100644 --- a/lib/csapi/redaction.cpp +++ b/lib/csapi/redaction.cpp @@ -12,7 +12,7 @@ RedactEventJob::RedactEventJob(const QString& roomId, const QString& eventId, makePath("/_matrix/client/v3", "/rooms/", roomId, "/redact/", eventId, "/", txnId)) { - QJsonObject _data; - addParam(_data, QStringLiteral("reason"), reason); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("reason"), reason); + setRequestData({ _dataJson }); } diff --git a/lib/csapi/refresh.cpp b/lib/csapi/refresh.cpp index 8d4a34ae..284ae4ff 100644 --- a/lib/csapi/refresh.cpp +++ b/lib/csapi/refresh.cpp @@ -10,8 +10,9 @@ RefreshJob::RefreshJob(const QString& refreshToken) : BaseJob(HttpVerb::Post, QStringLiteral("RefreshJob"), makePath("/_matrix/client/v3", "/refresh"), false) { - QJsonObject _data; - addParam(_data, QStringLiteral("refresh_token"), refreshToken); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("refresh_token"), + refreshToken); + setRequestData({ _dataJson }); addExpectedKey("access_token"); } diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 3541724b..04c0fe12 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -24,16 +24,19 @@ RegisterJob::RegisterJob(const QString& kind, makePath("/_matrix/client/v3", "/register"), queryToRegister(kind), {}, false) { - QJsonObject _data; - addParam(_data, QStringLiteral("auth"), auth); - addParam(_data, QStringLiteral("username"), username); - addParam(_data, QStringLiteral("password"), password); - addParam(_data, QStringLiteral("device_id"), deviceId); - addParam(_data, QStringLiteral("initial_device_display_name"), + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("auth"), auth); + addParam(_dataJson, QStringLiteral("username"), username); + addParam(_dataJson, QStringLiteral("password"), password); + addParam(_dataJson, QStringLiteral("device_id"), deviceId); + addParam(_dataJson, + QStringLiteral("initial_device_display_name"), initialDeviceDisplayName); - addParam(_data, QStringLiteral("inhibit_login"), inhibitLogin); - addParam(_data, QStringLiteral("refresh_token"), refreshToken); - setRequestData(std::move(_data)); + addParam(_dataJson, QStringLiteral("inhibit_login"), + inhibitLogin); + addParam(_dataJson, QStringLiteral("refresh_token"), + refreshToken); + setRequestData({ _dataJson }); addExpectedKey("user_id"); } @@ -43,7 +46,7 @@ RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( makePath("/_matrix/client/v3", "/register/email/requestToken"), false) { - setRequestData(RequestData(toJson(body))); + setRequestData({ toJson(body) }); } RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( @@ -52,7 +55,7 @@ RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( makePath("/_matrix/client/v3", "/register/msisdn/requestToken"), false) { - setRequestData(RequestData(toJson(body))); + setRequestData({ toJson(body) }); } ChangePasswordJob::ChangePasswordJob(const QString& newPassword, @@ -61,11 +64,12 @@ ChangePasswordJob::ChangePasswordJob(const QString& newPassword, : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), makePath("/_matrix/client/v3", "/account/password")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("new_password"), newPassword); - addParam(_data, QStringLiteral("logout_devices"), logoutDevices); - addParam(_data, QStringLiteral("auth"), auth); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("new_password"), newPassword); + addParam(_dataJson, QStringLiteral("logout_devices"), + logoutDevices); + addParam(_dataJson, QStringLiteral("auth"), auth); + setRequestData({ _dataJson }); } RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( @@ -76,7 +80,7 @@ RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( "/account/password/email/requestToken"), false) { - setRequestData(RequestData(toJson(body))); + setRequestData({ toJson(body) }); } RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( @@ -87,7 +91,7 @@ RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( "/account/password/msisdn/requestToken"), false) { - setRequestData(RequestData(toJson(body))); + setRequestData({ toJson(body) }); } DeactivateAccountJob::DeactivateAccountJob( @@ -95,10 +99,10 @@ DeactivateAccountJob::DeactivateAccountJob( : BaseJob(HttpVerb::Post, QStringLiteral("DeactivateAccountJob"), makePath("/_matrix/client/v3", "/account/deactivate")) { - QJsonObject _data; - addParam(_data, QStringLiteral("auth"), auth); - addParam(_data, QStringLiteral("id_server"), idServer); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("auth"), auth); + addParam(_dataJson, QStringLiteral("id_server"), idServer); + setRequestData({ _dataJson }); addExpectedKey("id_server_unbind_result"); } diff --git a/lib/csapi/registration.h b/lib/csapi/registration.h index 7a20cab8..21d7f9d7 100644 --- a/lib/csapi/registration.h +++ b/lib/csapi/registration.h @@ -126,7 +126,7 @@ public: /// obtain a new access token when it expires by calling the /// `/refresh` endpoint. /// - /// Omitted if the `inhibit_login` option is false. + /// Omitted if the `inhibit_login` option is true. QString refreshToken() const { return loadFromJson("refresh_token"_ls); @@ -139,7 +139,7 @@ public: /// to obtain a new access token. If not given, the client can /// assume that the access token will not expire. /// - /// Omitted if the `inhibit_login` option is false. + /// Omitted if the `inhibit_login` option is true. Omittable expiresInMs() const { return loadFromJson>("expires_in_ms"_ls); diff --git a/lib/csapi/report_content.cpp b/lib/csapi/report_content.cpp index b8e9a8d1..bc52208f 100644 --- a/lib/csapi/report_content.cpp +++ b/lib/csapi/report_content.cpp @@ -12,8 +12,8 @@ ReportContentJob::ReportContentJob(const QString& roomId, const QString& eventId makePath("/_matrix/client/v3", "/rooms/", roomId, "/report/", eventId)) { - QJsonObject _data; - addParam(_data, QStringLiteral("score"), score); - addParam(_data, QStringLiteral("reason"), reason); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("score"), score); + addParam(_dataJson, QStringLiteral("reason"), reason); + setRequestData({ _dataJson }); } diff --git a/lib/csapi/room_send.cpp b/lib/csapi/room_send.cpp index 93ab04d2..2319496f 100644 --- a/lib/csapi/room_send.cpp +++ b/lib/csapi/room_send.cpp @@ -12,6 +12,6 @@ SendMessageJob::SendMessageJob(const QString& roomId, const QString& eventType, makePath("/_matrix/client/v3", "/rooms/", roomId, "/send/", eventType, "/", txnId)) { - setRequestData(RequestData(toJson(body))); + setRequestData({ toJson(body) }); addExpectedKey("event_id"); } diff --git a/lib/csapi/room_state.cpp b/lib/csapi/room_state.cpp index 2253863a..b4adb739 100644 --- a/lib/csapi/room_state.cpp +++ b/lib/csapi/room_state.cpp @@ -14,6 +14,6 @@ SetRoomStateWithKeyJob::SetRoomStateWithKeyJob(const QString& roomId, makePath("/_matrix/client/v3", "/rooms/", roomId, "/state/", eventType, "/", stateKey)) { - setRequestData(RequestData(toJson(body))); + setRequestData({ toJson(body) }); addExpectedKey("event_id"); } diff --git a/lib/csapi/room_upgrades.cpp b/lib/csapi/room_upgrades.cpp index 3f67234d..b03fb6e8 100644 --- a/lib/csapi/room_upgrades.cpp +++ b/lib/csapi/room_upgrades.cpp @@ -10,8 +10,8 @@ UpgradeRoomJob::UpgradeRoomJob(const QString& roomId, const QString& newVersion) : BaseJob(HttpVerb::Post, QStringLiteral("UpgradeRoomJob"), makePath("/_matrix/client/v3", "/rooms/", roomId, "/upgrade")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("new_version"), newVersion); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("new_version"), newVersion); + setRequestData({ _dataJson }); addExpectedKey("replacement_room"); } diff --git a/lib/csapi/search.cpp b/lib/csapi/search.cpp index 92300351..4e2c9e92 100644 --- a/lib/csapi/search.cpp +++ b/lib/csapi/search.cpp @@ -19,8 +19,8 @@ SearchJob::SearchJob(const Categories& searchCategories, makePath("/_matrix/client/v3", "/search"), queryToSearch(nextBatch)) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("search_categories"), searchCategories); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("search_categories"), searchCategories); + setRequestData({ _dataJson }); addExpectedKey("search_categories"); } diff --git a/lib/csapi/tags.cpp b/lib/csapi/tags.cpp index 21cb18ed..2c85842d 100644 --- a/lib/csapi/tags.cpp +++ b/lib/csapi/tags.cpp @@ -27,10 +27,10 @@ SetRoomTagJob::SetRoomTagJob(const QString& userId, const QString& roomId, makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/tags/", tag)) { - QJsonObject _data; - fillJson(_data, additionalProperties); - addParam(_data, QStringLiteral("order"), order); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + fillJson(_dataJson, additionalProperties); + addParam(_dataJson, QStringLiteral("order"), order); + setRequestData({ _dataJson }); } QUrl DeleteRoomTagJob::makeRequestUrl(QUrl baseUrl, const QString& userId, diff --git a/lib/csapi/third_party_membership.cpp b/lib/csapi/third_party_membership.cpp index 2d6df77d..3ca986c7 100644 --- a/lib/csapi/third_party_membership.cpp +++ b/lib/csapi/third_party_membership.cpp @@ -12,10 +12,10 @@ InviteBy3PIDJob::InviteBy3PIDJob(const QString& roomId, const QString& idServer, : BaseJob(HttpVerb::Post, QStringLiteral("InviteBy3PIDJob"), makePath("/_matrix/client/v3", "/rooms/", roomId, "/invite")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("id_server"), idServer); - addParam<>(_data, QStringLiteral("id_access_token"), idAccessToken); - addParam<>(_data, QStringLiteral("medium"), medium); - addParam<>(_data, QStringLiteral("address"), address); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("id_server"), idServer); + addParam<>(_dataJson, QStringLiteral("id_access_token"), idAccessToken); + addParam<>(_dataJson, QStringLiteral("medium"), medium); + addParam<>(_dataJson, QStringLiteral("address"), address); + setRequestData({ _dataJson }); } diff --git a/lib/csapi/to_device.cpp b/lib/csapi/to_device.cpp index 48e943db..e10fac69 100644 --- a/lib/csapi/to_device.cpp +++ b/lib/csapi/to_device.cpp @@ -13,7 +13,7 @@ SendToDeviceJob::SendToDeviceJob( makePath("/_matrix/client/v3", "/sendToDevice/", eventType, "/", txnId)) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("messages"), messages); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("messages"), messages); + setRequestData({ _dataJson }); } diff --git a/lib/csapi/typing.cpp b/lib/csapi/typing.cpp index 1b4fe147..21bd45ae 100644 --- a/lib/csapi/typing.cpp +++ b/lib/csapi/typing.cpp @@ -12,8 +12,8 @@ SetTypingJob::SetTypingJob(const QString& userId, const QString& roomId, makePath("/_matrix/client/v3", "/rooms/", roomId, "/typing/", userId)) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("typing"), typing); - addParam(_data, QStringLiteral("timeout"), timeout); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("typing"), typing); + addParam(_dataJson, QStringLiteral("timeout"), timeout); + setRequestData({ _dataJson }); } diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index e0db6f70..c65280ee 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -11,10 +11,10 @@ SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, : BaseJob(HttpVerb::Post, QStringLiteral("SearchUserDirectoryJob"), makePath("/_matrix/client/v3", "/user_directory/search")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("search_term"), searchTerm); - addParam(_data, QStringLiteral("limit"), limit); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("search_term"), searchTerm); + addParam(_dataJson, QStringLiteral("limit"), limit); + setRequestData({ _dataJson }); addExpectedKey("results"); addExpectedKey("limited"); } -- cgit v1.2.3 From d5eef705b2b5d9dec17d72ab27cbdd48a1391485 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Fri, 12 Aug 2022 17:07:55 +0200 Subject: Regenerate CS API upon GTAD config change --- lib/csapi/event_context.h | 3 ++- lib/csapi/message_pagination.h | 2 +- lib/csapi/notifications.h | 2 +- lib/csapi/peeking_events.h | 2 +- lib/csapi/relations.h | 2 +- lib/csapi/rooms.h | 3 ++- lib/csapi/search.h | 3 ++- lib/csapi/space_hierarchy.h | 2 +- 8 files changed, 11 insertions(+), 8 deletions(-) (limited to 'lib/csapi') diff --git a/lib/csapi/event_context.h b/lib/csapi/event_context.h index 662b976b..1614c7ed 100644 --- a/lib/csapi/event_context.h +++ b/lib/csapi/event_context.h @@ -4,7 +4,8 @@ #pragma once -#include "events/eventloader.h" +#include "events/roomevent.h" +#include "events/stateevent.h" #include "jobs/basejob.h" namespace Quotient { diff --git a/lib/csapi/message_pagination.h b/lib/csapi/message_pagination.h index 9831ae2d..b4f3a38a 100644 --- a/lib/csapi/message_pagination.h +++ b/lib/csapi/message_pagination.h @@ -4,7 +4,7 @@ #pragma once -#include "events/eventloader.h" +#include "events/roomevent.h" #include "jobs/basejob.h" namespace Quotient { diff --git a/lib/csapi/notifications.h b/lib/csapi/notifications.h index 48167877..ff8aa47f 100644 --- a/lib/csapi/notifications.h +++ b/lib/csapi/notifications.h @@ -4,7 +4,7 @@ #pragma once -#include "events/eventloader.h" +#include "events/event.h" #include "jobs/basejob.h" namespace Quotient { diff --git a/lib/csapi/peeking_events.h b/lib/csapi/peeking_events.h index ff688c49..a67d2e4a 100644 --- a/lib/csapi/peeking_events.h +++ b/lib/csapi/peeking_events.h @@ -4,7 +4,7 @@ #pragma once -#include "events/eventloader.h" +#include "events/roomevent.h" #include "jobs/basejob.h" namespace Quotient { diff --git a/lib/csapi/relations.h b/lib/csapi/relations.h index 985a43b5..794ae445 100644 --- a/lib/csapi/relations.h +++ b/lib/csapi/relations.h @@ -4,7 +4,7 @@ #pragma once -#include "events/eventloader.h" +#include "events/roomevent.h" #include "jobs/basejob.h" namespace Quotient { diff --git a/lib/csapi/rooms.h b/lib/csapi/rooms.h index 247fb13f..7823a1b0 100644 --- a/lib/csapi/rooms.h +++ b/lib/csapi/rooms.h @@ -4,7 +4,8 @@ #pragma once -#include "events/eventloader.h" +#include "events/roomevent.h" +#include "events/stateevent.h" #include "jobs/basejob.h" namespace Quotient { diff --git a/lib/csapi/search.h b/lib/csapi/search.h index 8683413d..30095f32 100644 --- a/lib/csapi/search.h +++ b/lib/csapi/search.h @@ -6,7 +6,8 @@ #include "csapi/definitions/room_event_filter.h" -#include "events/eventloader.h" +#include "events/roomevent.h" +#include "events/stateevent.h" #include "jobs/basejob.h" namespace Quotient { diff --git a/lib/csapi/space_hierarchy.h b/lib/csapi/space_hierarchy.h index 7a421be8..e5da6df2 100644 --- a/lib/csapi/space_hierarchy.h +++ b/lib/csapi/space_hierarchy.h @@ -4,7 +4,7 @@ #pragma once -#include "events/eventloader.h" +#include "events/stateevent.h" #include "jobs/basejob.h" namespace Quotient { -- cgit v1.2.3 From bcae903921b81f578b0717e7376a45f9cafa16ad Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Mon, 3 Oct 2022 21:02:22 +0200 Subject: Regenerate API files from spec v1.4 --- lib/csapi/account-data.h | 61 ++++++++++----------- lib/csapi/definitions/public_rooms_response.h | 6 +++ lib/csapi/definitions/room_event_filter.h | 9 ++++ lib/csapi/joining.h | 2 +- lib/csapi/keys.h | 4 +- lib/csapi/list_public_rooms.h | 10 +++- lib/csapi/login.cpp | 3 ++ lib/csapi/read_markers.cpp | 7 ++- lib/csapi/read_markers.h | 11 +++- lib/csapi/receipts.h | 8 ++- lib/csapi/redaction.h | 6 +-- lib/csapi/relations.cpp | 45 +++++++++------- lib/csapi/relations.h | 55 +++++++++++++------ lib/csapi/room_send.h | 7 +-- lib/csapi/threads_list.cpp | 37 +++++++++++++ lib/csapi/threads_list.h | 76 +++++++++++++++++++++++++++ lib/csapi/to_device.h | 7 +-- 17 files changed, 269 insertions(+), 85 deletions(-) create mode 100644 lib/csapi/threads_list.cpp create mode 100644 lib/csapi/threads_list.h (limited to 'lib/csapi') diff --git a/lib/csapi/account-data.h b/lib/csapi/account-data.h index 5140d340..70d4e492 100644 --- a/lib/csapi/account-data.h +++ b/lib/csapi/account-data.h @@ -8,46 +8,47 @@ namespace Quotient { -/*! \brief Set some account_data for the user. +/*! \brief Set some account data for the user. * - * Set some account_data for the client. This config is only visible to the user - * that set the account_data. The config will be synced to clients in the - * top-level `account_data`. + * Set some account data for the client. This config is only visible to the user + * that set the account data. The config will be available to clients through + * the top-level `account_data` field in the homeserver response to + * [/sync](#get_matrixclientv3sync). */ class QUOTIENT_API SetAccountDataJob : public BaseJob { public: - /*! \brief Set some account_data for the user. + /*! \brief Set some account data for the user. * * \param userId - * The ID of the user to set account_data for. The access token must be + * The ID of the user to set account data for. The access token must be * authorized to make requests for this user ID. * * \param type - * The event type of the account_data to set. Custom types should be + * The event type of the account data to set. Custom types should be * namespaced to avoid clashes. * * \param content - * The content of the account_data + * The content of the account data. */ explicit SetAccountDataJob(const QString& userId, const QString& type, const QJsonObject& content = {}); }; -/*! \brief Get some account_data for the user. +/*! \brief Get some account data for the user. * - * Get some account_data for the client. This config is only visible to the user - * that set the account_data. + * Get some account data for the client. This config is only visible to the user + * that set the account data. */ class QUOTIENT_API GetAccountDataJob : public BaseJob { public: - /*! \brief Get some account_data for the user. + /*! \brief Get some account data for the user. * * \param userId - * The ID of the user to get account_data for. The access token must be + * The ID of the user to get account data for. The access token must be * authorized to make requests for this user ID. * * \param type - * The event type of the account_data to get. Custom types should be + * The event type of the account data to get. Custom types should be * namespaced to avoid clashes. */ explicit GetAccountDataJob(const QString& userId, const QString& type); @@ -61,53 +62,53 @@ public: const QString& type); }; -/*! \brief Set some account_data for the user. +/*! \brief Set some account data for the user that is specific to a room. * - * Set some account_data for the client on a given room. This config is only - * visible to the user that set the account_data. The config will be synced to - * clients in the per-room `account_data`. + * Set some account data for the client on a given room. This config is only + * visible to the user that set the account data. The config will be delivered + * to clients in the per-room entries via [/sync](#get_matrixclientv3sync). */ class QUOTIENT_API SetAccountDataPerRoomJob : public BaseJob { public: - /*! \brief Set some account_data for the user. + /*! \brief Set some account data for the user that is specific to a room. * * \param userId - * The ID of the user to set account_data for. The access token must be + * The ID of the user to set account data for. The access token must be * authorized to make requests for this user ID. * * \param roomId - * The ID of the room to set account_data on. + * The ID of the room to set account data on. * * \param type - * The event type of the account_data to set. Custom types should be + * The event type of the account data to set. Custom types should be * namespaced to avoid clashes. * * \param content - * The content of the account_data + * The content of the account data. */ explicit SetAccountDataPerRoomJob(const QString& userId, const QString& roomId, const QString& type, const QJsonObject& content = {}); }; -/*! \brief Get some account_data for the user. +/*! \brief Get some account data for the user that is specific to a room. * - * Get some account_data for the client on a given room. This config is only - * visible to the user that set the account_data. + * Get some account data for the client on a given room. This config is only + * visible to the user that set the account data. */ class QUOTIENT_API GetAccountDataPerRoomJob : public BaseJob { public: - /*! \brief Get some account_data for the user. + /*! \brief Get some account data for the user that is specific to a room. * * \param userId - * The ID of the user to set account_data for. The access token must be + * The ID of the user to get account data for. The access token must be * authorized to make requests for this user ID. * * \param roomId - * The ID of the room to get account_data for. + * The ID of the room to get account data for. * * \param type - * The event type of the account_data to get. Custom types should be + * The event type of the account data to get. Custom types should be * namespaced to avoid clashes. */ explicit GetAccountDataPerRoomJob(const QString& userId, diff --git a/lib/csapi/definitions/public_rooms_response.h b/lib/csapi/definitions/public_rooms_response.h index d0a2595c..7c7d9cc6 100644 --- a/lib/csapi/definitions/public_rooms_response.h +++ b/lib/csapi/definitions/public_rooms_response.h @@ -35,6 +35,10 @@ struct PublicRoomsChunk { /// The URL for the room's avatar, if one is set. QUrl avatarUrl; + /// The `type` of room (from + /// [`m.room.create`](/client-server-api/#mroomcreate)), if any. + QString roomType; + /// The room's join rule. When not present, the room is assumed to /// be `public`. Note that rooms with `invite` join rules are not /// expected here, but rooms with `knock` rules are given their @@ -56,6 +60,7 @@ struct JsonObjectConverter { addParam<>(jo, QStringLiteral("world_readable"), pod.worldReadable); addParam<>(jo, QStringLiteral("guest_can_join"), pod.guestCanJoin); addParam(jo, QStringLiteral("avatar_url"), pod.avatarUrl); + addParam(jo, QStringLiteral("room_type"), pod.roomType); addParam(jo, QStringLiteral("join_rule"), pod.joinRule); } static void fillFrom(const QJsonObject& jo, PublicRoomsChunk& pod) @@ -68,6 +73,7 @@ struct JsonObjectConverter { fromJson(jo.value("world_readable"_ls), pod.worldReadable); fromJson(jo.value("guest_can_join"_ls), pod.guestCanJoin); fromJson(jo.value("avatar_url"_ls), pod.avatarUrl); + fromJson(jo.value("room_type"_ls), pod.roomType); fromJson(jo.value("join_rule"_ls), pod.joinRule); } }; diff --git a/lib/csapi/definitions/room_event_filter.h b/lib/csapi/definitions/room_event_filter.h index 91caf667..293e5492 100644 --- a/lib/csapi/definitions/room_event_filter.h +++ b/lib/csapi/definitions/room_event_filter.h @@ -11,6 +11,11 @@ namespace Quotient { struct RoomEventFilter : EventFilter { + /// If `true`, enables per-[thread](/client-server-api/#threading) + /// notification counts. Only applies to the `/sync` endpoint. Defaults to + /// `false`. + Omittable unreadThreadNotifications; + /// If `true`, enables lazy-loading of membership events. See /// [Lazy-loading room /// members](/client-server-api/#lazy-loading-room-members) for more @@ -44,6 +49,8 @@ struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const RoomEventFilter& pod) { fillJson(jo, pod); + addParam(jo, QStringLiteral("unread_thread_notifications"), + pod.unreadThreadNotifications); addParam(jo, QStringLiteral("lazy_load_members"), pod.lazyLoadMembers); addParam(jo, QStringLiteral("include_redundant_members"), @@ -56,6 +63,8 @@ struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, RoomEventFilter& pod) { fillFromJson(jo, pod); + fromJson(jo.value("unread_thread_notifications"_ls), + pod.unreadThreadNotifications); fromJson(jo.value("lazy_load_members"_ls), pod.lazyLoadMembers); fromJson(jo.value("include_redundant_members"_ls), pod.includeRedundantMembers); diff --git a/lib/csapi/joining.h b/lib/csapi/joining.h index 233537bb..c86baa90 100644 --- a/lib/csapi/joining.h +++ b/lib/csapi/joining.h @@ -55,7 +55,7 @@ public: /*! \brief Start the requesting user participating in a particular room. * * *Note that this API takes either a room ID or alias, unlike* - * `/room/{roomId}/join`. + * `/rooms/{roomId}/join`. * * This API starts a user participating in a particular room, if that user * is allowed to participate in that room. After this call, the client is diff --git a/lib/csapi/keys.h b/lib/csapi/keys.h index 2f2ebc6d..b28de305 100644 --- a/lib/csapi/keys.h +++ b/lib/csapi/keys.h @@ -4,11 +4,11 @@ #pragma once -#include "e2ee/e2ee.h" - #include "csapi/definitions/cross_signing_key.h" #include "csapi/definitions/device_keys.h" +#include "e2ee/e2ee.h" + #include "jobs/basejob.h" namespace Quotient { diff --git a/lib/csapi/list_public_rooms.h b/lib/csapi/list_public_rooms.h index e1f03db7..3b6b91b9 100644 --- a/lib/csapi/list_public_rooms.h +++ b/lib/csapi/list_public_rooms.h @@ -139,9 +139,14 @@ public: /// Filter to apply to the results. struct Filter { - /// A string to search for in the room metadata, e.g. name, - /// topic, canonical alias etc. (Optional). + /// An optional string to search for in the room metadata, e.g. name, + /// topic, canonical alias, etc. QString genericSearchTerm; + /// An optional list of [room types](/client-server-api/#types) to + /// search for. To include rooms without a room type, specify `null` + /// within this list. When not specified, all applicable rooms + /// (regardless of type) are returned. + QStringList roomTypes; }; // Construction/destruction @@ -211,6 +216,7 @@ struct JsonObjectConverter { { addParam(jo, QStringLiteral("generic_search_term"), pod.genericSearchTerm); + addParam(jo, QStringLiteral("room_types"), pod.roomTypes); } }; diff --git a/lib/csapi/login.cpp b/lib/csapi/login.cpp index 81e603b5..7bb74e29 100644 --- a/lib/csapi/login.cpp +++ b/lib/csapi/login.cpp @@ -38,4 +38,7 @@ LoginJob::LoginJob(const QString& type, addParam(_dataJson, QStringLiteral("refresh_token"), refreshToken); setRequestData({ _dataJson }); + addExpectedKey("user_id"); + addExpectedKey("access_token"); + addExpectedKey("device_id"); } diff --git a/lib/csapi/read_markers.cpp b/lib/csapi/read_markers.cpp index de5f4a9a..febd6d3a 100644 --- a/lib/csapi/read_markers.cpp +++ b/lib/csapi/read_markers.cpp @@ -8,12 +8,15 @@ using namespace Quotient; SetReadMarkerJob::SetReadMarkerJob(const QString& roomId, const QString& mFullyRead, - const QString& mRead) + const QString& mRead, + const QString& mReadPrivate) : BaseJob(HttpVerb::Post, QStringLiteral("SetReadMarkerJob"), makePath("/_matrix/client/v3", "/rooms/", roomId, "/read_markers")) { QJsonObject _dataJson; - addParam<>(_dataJson, QStringLiteral("m.fully_read"), mFullyRead); + addParam(_dataJson, QStringLiteral("m.fully_read"), mFullyRead); addParam(_dataJson, QStringLiteral("m.read"), mRead); + addParam(_dataJson, QStringLiteral("m.read.private"), + mReadPrivate); setRequestData({ _dataJson }); } diff --git a/lib/csapi/read_markers.h b/lib/csapi/read_markers.h index d13fa4fc..1024076f 100644 --- a/lib/csapi/read_markers.h +++ b/lib/csapi/read_markers.h @@ -28,9 +28,16 @@ public: * The event ID to set the read receipt location at. This is * equivalent to calling `/receipt/m.read/$elsewhere:example.org` * and is provided here to save that extra call. + * + * \param mReadPrivate + * The event ID to set the *private* read receipt location at. This + * equivalent to calling `/receipt/m.read.private/$elsewhere:example.org` + * and is provided here to save that extra call. */ - explicit SetReadMarkerJob(const QString& roomId, const QString& mFullyRead, - const QString& mRead = {}); + explicit SetReadMarkerJob(const QString& roomId, + const QString& mFullyRead = {}, + const QString& mRead = {}, + const QString& mReadPrivate = {}); }; } // namespace Quotient diff --git a/lib/csapi/receipts.h b/lib/csapi/receipts.h index e29e7b29..98bc5004 100644 --- a/lib/csapi/receipts.h +++ b/lib/csapi/receipts.h @@ -21,7 +21,13 @@ public: * The room in which to send the event. * * \param receiptType - * The type of receipt to send. + * The type of receipt to send. This can also be `m.fully_read` as an + * alternative to + * [`/read_makers`](/client-server-api/#post_matrixclientv3roomsroomidread_markers). + * + * Note that `m.fully_read` does not appear under `m.receipt`: this + * endpoint effectively calls `/read_markers` internally when presented with + * a receipt type of `m.fully_read`. * * \param eventId * The event ID to acknowledge up to. diff --git a/lib/csapi/redaction.h b/lib/csapi/redaction.h index 29d9c5d5..2f85793e 100644 --- a/lib/csapi/redaction.h +++ b/lib/csapi/redaction.h @@ -33,9 +33,9 @@ public: * The ID of the event to redact * * \param txnId - * The transaction ID for this event. Clients should generate a - * unique ID; it will be used by the server to ensure idempotency of - * requests. + * The [transaction ID](/client-server-api/#transaction-identifiers) for + * this event. Clients should generate a unique ID; it will be used by the + * server to ensure idempotency of requests. * * \param reason * The reason for the event being redacted. diff --git a/lib/csapi/relations.cpp b/lib/csapi/relations.cpp index 8bcecee4..1d8febcc 100644 --- a/lib/csapi/relations.cpp +++ b/lib/csapi/relations.cpp @@ -7,105 +7,112 @@ using namespace Quotient; auto queryToGetRelatingEvents(const QString& from, const QString& to, - Omittable limit) + Omittable limit, const QString& dir) { QUrlQuery _q; addParam(_q, QStringLiteral("from"), from); addParam(_q, QStringLiteral("to"), to); addParam(_q, QStringLiteral("limit"), limit); + addParam(_q, QStringLiteral("dir"), dir); return _q; } QUrl GetRelatingEventsJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId, const QString& from, const QString& to, - Omittable limit) + Omittable limit, + const QString& dir) { return BaseJob::makeRequestUrl(std::move(baseUrl), makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", eventId), - queryToGetRelatingEvents(from, to, limit)); + queryToGetRelatingEvents(from, to, limit, + dir)); } -GetRelatingEventsJob::GetRelatingEventsJob(const QString& roomId, - const QString& eventId, - const QString& from, - const QString& to, - Omittable limit) +GetRelatingEventsJob::GetRelatingEventsJob( + const QString& roomId, const QString& eventId, const QString& from, + const QString& to, Omittable limit, const QString& dir) : BaseJob(HttpVerb::Get, QStringLiteral("GetRelatingEventsJob"), makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", eventId), - queryToGetRelatingEvents(from, to, limit)) + queryToGetRelatingEvents(from, to, limit, dir)) { addExpectedKey("chunk"); } auto queryToGetRelatingEventsWithRelType(const QString& from, const QString& to, - Omittable limit) + Omittable limit, + const QString& dir) { QUrlQuery _q; addParam(_q, QStringLiteral("from"), from); addParam(_q, QStringLiteral("to"), to); addParam(_q, QStringLiteral("limit"), limit); + addParam(_q, QStringLiteral("dir"), dir); return _q; } QUrl GetRelatingEventsWithRelTypeJob::makeRequestUrl( QUrl baseUrl, const QString& roomId, const QString& eventId, const QString& relType, const QString& from, const QString& to, - Omittable limit) + Omittable limit, const QString& dir) { return BaseJob::makeRequestUrl( std::move(baseUrl), makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", eventId, "/", relType), - queryToGetRelatingEventsWithRelType(from, to, limit)); + queryToGetRelatingEventsWithRelType(from, to, limit, dir)); } GetRelatingEventsWithRelTypeJob::GetRelatingEventsWithRelTypeJob( const QString& roomId, const QString& eventId, const QString& relType, - const QString& from, const QString& to, Omittable limit) + const QString& from, const QString& to, Omittable limit, + const QString& dir) : BaseJob(HttpVerb::Get, QStringLiteral("GetRelatingEventsWithRelTypeJob"), makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", eventId, "/", relType), - queryToGetRelatingEventsWithRelType(from, to, limit)) + queryToGetRelatingEventsWithRelType(from, to, limit, dir)) { addExpectedKey("chunk"); } auto queryToGetRelatingEventsWithRelTypeAndEventType(const QString& from, const QString& to, - Omittable limit) + Omittable limit, + const QString& dir) { QUrlQuery _q; addParam(_q, QStringLiteral("from"), from); addParam(_q, QStringLiteral("to"), to); addParam(_q, QStringLiteral("limit"), limit); + addParam(_q, QStringLiteral("dir"), dir); return _q; } QUrl GetRelatingEventsWithRelTypeAndEventTypeJob::makeRequestUrl( QUrl baseUrl, const QString& roomId, const QString& eventId, const QString& relType, const QString& eventType, const QString& from, - const QString& to, Omittable limit) + const QString& to, Omittable limit, const QString& dir) { return BaseJob::makeRequestUrl( std::move(baseUrl), makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", eventId, "/", relType, "/", eventType), - queryToGetRelatingEventsWithRelTypeAndEventType(from, to, limit)); + queryToGetRelatingEventsWithRelTypeAndEventType(from, to, limit, dir)); } GetRelatingEventsWithRelTypeAndEventTypeJob:: GetRelatingEventsWithRelTypeAndEventTypeJob( const QString& roomId, const QString& eventId, const QString& relType, const QString& eventType, const QString& from, const QString& to, - Omittable limit) + Omittable limit, const QString& dir) : BaseJob(HttpVerb::Get, QStringLiteral("GetRelatingEventsWithRelTypeAndEventTypeJob"), makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", eventId, "/", relType, "/", eventType), - queryToGetRelatingEventsWithRelTypeAndEventType(from, to, limit)) + queryToGetRelatingEventsWithRelTypeAndEventType(from, to, limit, + dir)) { addExpectedKey("chunk"); } diff --git a/lib/csapi/relations.h b/lib/csapi/relations.h index 794ae445..5d6efd1c 100644 --- a/lib/csapi/relations.h +++ b/lib/csapi/relations.h @@ -36,8 +36,8 @@ public: * The pagination token to start returning results from. If not supplied, * results start at the most recent topological event known to the server. * - * Can be a `next_batch` token from a previous call, or a returned - * `start` token from + * Can be a `next_batch` or `prev_batch` token from a previous call, or a + * returned `start` token from * [`/messages`](/client-server-api/#get_matrixclientv3roomsroomidmessages), * or a `next_batch` token from * [`/sync`](/client-server-api/#get_matrixclientv3sync). @@ -55,11 +55,18 @@ public: * responses. * * Similarly, the server should apply a default value when not supplied. + * + * \param dir + * Optional (default `b`) direction to return events from. If this is set + * to `f`, events will be returned in chronological order starting at + * `from`. If it is set to `b`, events will be returned in *reverse* + * chronological order, again starting at `from`. */ explicit GetRelatingEventsJob(const QString& roomId, const QString& eventId, const QString& from = {}, const QString& to = {}, - Omittable limit = none); + Omittable limit = none, + const QString& dir = {}); /*! \brief Construct a URL without creating a full-fledged job object * @@ -69,7 +76,8 @@ public: static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId, const QString& from = {}, const QString& to = {}, - Omittable limit = none); + Omittable limit = none, + const QString& dir = {}); // Result properties @@ -122,8 +130,8 @@ public: * The pagination token to start returning results from. If not supplied, * results start at the most recent topological event known to the server. * - * Can be a `next_batch` token from a previous call, or a returned - * `start` token from + * Can be a `next_batch` or `prev_batch` token from a previous call, or a + * returned `start` token from * [`/messages`](/client-server-api/#get_matrixclientv3roomsroomidmessages), * or a `next_batch` token from * [`/sync`](/client-server-api/#get_matrixclientv3sync). @@ -141,13 +149,17 @@ public: * responses. * * Similarly, the server should apply a default value when not supplied. + * + * \param dir + * Optional (default `b`) direction to return events from. If this is set + * to `f`, events will be returned in chronological order starting at + * `from`. If it is set to `b`, events will be returned in *reverse* + * chronological order, again starting at `from`. */ - explicit GetRelatingEventsWithRelTypeJob(const QString& roomId, - const QString& eventId, - const QString& relType, - const QString& from = {}, - const QString& to = {}, - Omittable limit = none); + explicit GetRelatingEventsWithRelTypeJob( + const QString& roomId, const QString& eventId, const QString& relType, + const QString& from = {}, const QString& to = {}, + Omittable limit = none, const QString& dir = {}); /*! \brief Construct a URL without creating a full-fledged job object * @@ -157,7 +169,8 @@ public: static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId, const QString& relType, const QString& from = {}, const QString& to = {}, - Omittable limit = none); + Omittable limit = none, + const QString& dir = {}); // Result properties @@ -219,8 +232,8 @@ public: * The pagination token to start returning results from. If not supplied, * results start at the most recent topological event known to the server. * - * Can be a `next_batch` token from a previous call, or a returned - * `start` token from + * Can be a `next_batch` or `prev_batch` token from a previous call, or a + * returned `start` token from * [`/messages`](/client-server-api/#get_matrixclientv3roomsroomidmessages), * or a `next_batch` token from * [`/sync`](/client-server-api/#get_matrixclientv3sync). @@ -238,11 +251,18 @@ public: * responses. * * Similarly, the server should apply a default value when not supplied. + * + * \param dir + * Optional (default `b`) direction to return events from. If this is set + * to `f`, events will be returned in chronological order starting at + * `from`. If it is set to `b`, events will be returned in *reverse* + * chronological order, again starting at `from`. */ explicit GetRelatingEventsWithRelTypeAndEventTypeJob( const QString& roomId, const QString& eventId, const QString& relType, const QString& eventType, const QString& from = {}, - const QString& to = {}, Omittable limit = none); + const QString& to = {}, Omittable limit = none, + const QString& dir = {}); /*! \brief Construct a URL without creating a full-fledged job object * @@ -254,7 +274,8 @@ public: const QString& eventId, const QString& relType, const QString& eventType, const QString& from = {}, const QString& to = {}, - Omittable limit = none); + Omittable limit = none, + const QString& dir = {}); // Result properties diff --git a/lib/csapi/room_send.h b/lib/csapi/room_send.h index fcb6b24f..abe5f207 100644 --- a/lib/csapi/room_send.h +++ b/lib/csapi/room_send.h @@ -30,9 +30,10 @@ public: * The type of event to send. * * \param txnId - * The transaction ID for this event. Clients should generate an - * ID unique across requests with the same access token; it will be - * used by the server to ensure idempotency of requests. + * The [transaction ID](/client-server-api/#transaction-identifiers) for + * this event. Clients should generate an ID unique across requests with the + * same access token; it will be used by the server to ensure idempotency of + * requests. * * \param body * This endpoint is used to send a message event to a room. Message events diff --git a/lib/csapi/threads_list.cpp b/lib/csapi/threads_list.cpp new file mode 100644 index 00000000..26924f24 --- /dev/null +++ b/lib/csapi/threads_list.cpp @@ -0,0 +1,37 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "threads_list.h" + +using namespace Quotient; + +auto queryToGetThreadRoots(const QString& include, Omittable limit, + const QString& from) +{ + QUrlQuery _q; + addParam(_q, QStringLiteral("include"), include); + addParam(_q, QStringLiteral("limit"), limit); + addParam(_q, QStringLiteral("from"), from); + return _q; +} + +QUrl GetThreadRootsJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, + const QString& include, + Omittable limit, const QString& from) +{ + return BaseJob::makeRequestUrl(std::move(baseUrl), + makePath("/_matrix/client/v1", "/rooms/", + roomId, "/threads"), + queryToGetThreadRoots(include, limit, from)); +} + +GetThreadRootsJob::GetThreadRootsJob(const QString& roomId, + const QString& include, + Omittable limit, const QString& from) + : BaseJob(HttpVerb::Get, QStringLiteral("GetThreadRootsJob"), + makePath("/_matrix/client/v1", "/rooms/", roomId, "/threads"), + queryToGetThreadRoots(include, limit, from)) +{ + addExpectedKey("chunk"); +} diff --git a/lib/csapi/threads_list.h b/lib/csapi/threads_list.h new file mode 100644 index 00000000..7041583a --- /dev/null +++ b/lib/csapi/threads_list.h @@ -0,0 +1,76 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "events/roomevent.h" +#include "jobs/basejob.h" + +namespace Quotient { + +/*! \brief Retrieve a list of threads in a room, with optional filters. + * + * Paginates over the thread roots in a room, ordered by the `latest_event` of + * each thread root in its bundle. + */ +class QUOTIENT_API GetThreadRootsJob : public BaseJob { +public: + /*! \brief Retrieve a list of threads in a room, with optional filters. + * + * \param roomId + * The room ID where the thread roots are located. + * + * \param include + * Optional (default `all`) flag to denote which thread roots are of + * interest to the caller. When `all`, all thread roots found in the room + * are returned. When `participated`, only thread roots for threads the user + * has [participated + * in](/client-server-api/#server-side-aggreagtion-of-mthread-relationships) + * will be returned. + * + * \param limit + * Optional limit for the maximum number of thread roots to include per + * response. Must be an integer greater than zero. + * + * Servers should apply a default value, and impose a maximum value to + * avoid resource exhaustion. + * + * \param from + * A pagination token from a previous result. When not provided, the + * server starts paginating from the most recent event visible to the user + * (as per history visibility rules; topologically). + */ + explicit GetThreadRootsJob(const QString& roomId, + const QString& include = {}, + Omittable limit = none, + const QString& from = {}); + + /*! \brief Construct a URL without creating a full-fledged job object + * + * This function can be used when a URL for GetThreadRootsJob + * is necessary but the job itself isn't. + */ + static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, + const QString& include = {}, + Omittable limit = none, + const QString& from = {}); + + // Result properties + + /// The thread roots, ordered by the `latest_event` in each event's + /// aggregation bundle. All events returned include bundled + /// [aggregations](/client-server-api/#aggregations). + /// + /// If the thread root event was sent by an [ignored + /// user](/client-server-api/#ignoring-users), the event is returned + /// redacted to the caller. This is to simulate the same behaviour of a + /// client doing aggregation locally on the thread. + RoomEvents chunk() { return takeFromJson("chunk"_ls); } + + /// A token to supply to `from` to keep paginating the responses. Not + /// present when there are no further results. + QString nextBatch() const { return loadFromJson("next_batch"_ls); } +}; + +} // namespace Quotient diff --git a/lib/csapi/to_device.h b/lib/csapi/to_device.h index 5b6e0bfb..54828337 100644 --- a/lib/csapi/to_device.h +++ b/lib/csapi/to_device.h @@ -21,9 +21,10 @@ public: * The type of event to send. * * \param txnId - * The transaction ID for this event. Clients should generate an - * ID unique across requests with the same access token; it will be - * used by the server to ensure idempotency of requests. + * The [transaction ID](/client-server-api/#transaction-identifiers) for + * this event. Clients should generate an ID unique across requests with the + * same access token; it will be used by the server to ensure idempotency of + * requests. * * \param messages * The messages to send. A map from user ID, to a map from -- cgit v1.2.3