diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-06-09 08:52:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-09 08:52:25 +0200 |
commit | 370d9b3e46332d38df8798cda208c534c58be808 (patch) | |
tree | f3db0cd7463468ff52c74446acd608356f8b8ab6 /lib/csapi/directory.h | |
parent | e1f5d0aa2c33e6da6c3a609c8bc7e0b5867e748d (diff) | |
parent | 10d9ac4673e374a9ac17ff492591136520337c4c (diff) | |
download | libquotient-370d9b3e46332d38df8798cda208c534c58be808.tar.gz libquotient-370d9b3e46332d38df8798cda208c534c58be808.zip |
Merge pull request #405 from quotient-im/kitsune-basejob-store-json-response
Store JSON response in BaseJob + tweaks to the generated code
Diffstat (limited to 'lib/csapi/directory.h')
-rw-r--r-- | lib/csapi/directory.h | 74 |
1 files changed, 62 insertions, 12 deletions
diff --git a/lib/csapi/directory.h b/lib/csapi/directory.h index c13ca20a..7ae44d1d 100644 --- a/lib/csapi/directory.h +++ b/lib/csapi/directory.h @@ -8,8 +8,6 @@ namespace Quotient { -// Operations - /*! \brief Create a new mapping from room alias to room ID. * */ @@ -17,8 +15,10 @@ class SetRoomAliasJob : public BaseJob { public: /*! \brief Create a new mapping from room alias to room ID. * + * * \param roomAlias * The room alias to set. + * * \param roomId * The room ID to set. */ @@ -37,6 +37,7 @@ class GetRoomIdByAliasJob : public BaseJob { public: /*! \brief Get the room ID corresponding to this room alias. * + * * \param roomAlias * The room alias. */ @@ -48,22 +49,17 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomAlias); - ~GetRoomIdByAliasJob() override; // Result properties /// The room ID for this room alias. - const QString& roomId() const; + QString roomId() const { return loadFromJson<QString>("room_id"_ls); } /// A list of servers that are aware of this room alias. - const QStringList& servers() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer<Private> d; + QStringList servers() const + { + return loadFromJson<QStringList>("servers"_ls); + } }; /*! \brief Remove a mapping of room alias to room ID. @@ -73,11 +69,20 @@ private: * Servers may choose to implement additional access control checks here, for * 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. + * 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. */ class DeleteRoomAliasJob : public BaseJob { public: /*! \brief Remove a mapping of room alias to room ID. * + * * \param roomAlias * The room alias to remove. */ @@ -91,4 +96,49 @@ public: static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomAlias); }; +/*! \brief Get a list of local aliases on a given room. + * + * Get a list of aliases maintained by the local server for the + * 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 + * 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. + */ +class GetLocalAliasesJob : public BaseJob { +public: + /*! \brief Get a list of local aliases on a given room. + * + * + * \param roomId + * The room ID to find local aliases of. + */ + explicit GetLocalAliasesJob(const QString& roomId); + + /*! \brief Construct a URL without creating a full-fledged job object + * + * This function can be used when a URL for GetLocalAliasesJob + * is necessary but the job itself isn't. + */ + static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); + + // Result properties + + /// The server's local aliases on the room. Can be empty. + QStringList aliases() const + { + return loadFromJson<QStringList>("aliases"_ls); + } +}; + } // namespace Quotient |