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/room_state.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/room_state.h')
-rw-r--r-- | lib/csapi/room_state.h | 96 |
1 files changed, 25 insertions, 71 deletions
diff --git a/lib/csapi/room_state.h b/lib/csapi/room_state.h index 7843cff4..eeb2b33c 100644 --- a/lib/csapi/room_state.h +++ b/lib/csapi/room_state.h @@ -6,14 +6,13 @@ #include "jobs/basejob.h" -#include <QtCore/QJsonObject> - namespace Quotient { -// Operations - /*! \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 ``<room id>``, ``<event type>`` and ``<state key>`` all * match. @@ -25,18 +24,32 @@ 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. + * + * 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 + * being removed or are already present in the state event. */ class SetRoomStateWithKeyJob : public BaseJob { public: /*! \brief Send a state event to the given room. * + * * \param roomId * The room to set the state in + * * \param eventType * The type of event to send. + * * \param stateKey - * The state_key for the state to send. Defaults to the empty string. + * The state_key for the state to send. Defaults to the empty string. When + * 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 ``<room id>``, ``<event type>`` and ``<state key>`` all * match. @@ -48,81 +61,22 @@ 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. + * + * 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 + * being removed or are already present in the state event. */ explicit SetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, const QString& stateKey, const QJsonObject& body = {}); - ~SetRoomStateWithKeyJob() override; - - // Result properties - - /// A unique identifier for the event. - const QString& eventId() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer<Private> d; -}; - -/*! \brief Send a state event to the given room. - * - * State events can be sent using this endpoint. This endpoint is - * equivalent to calling `/rooms/{roomId}/state/{eventType}/{stateKey}` - * with an empty `stateKey`. Previous state events with matching - * `<roomId>` and `<eventType>`, and empty `<stateKey>`, will be overwritten. - * - * 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. - * - * 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. - */ -class SetRoomStateJob : public BaseJob { -public: - /*! \brief Send a state event to the given room. - * - * \param roomId - * The room to set the state in - * \param eventType - * The type of event to send. - * \param body - * State events can be sent using this endpoint. This endpoint is - * equivalent to calling `/rooms/{roomId}/state/{eventType}/{stateKey}` - * with an empty `stateKey`. Previous state events with matching - * `<roomId>` and `<eventType>`, and empty `<stateKey>`, will be - * overwritten. - * - * 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. - * - * 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. - */ - explicit SetRoomStateJob(const QString& roomId, const QString& eventType, - const QJsonObject& body = {}); - - ~SetRoomStateJob() override; - // Result properties /// A unique identifier for the event. - const QString& eventId() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer<Private> d; + QString eventId() const { return loadFromJson<QString>("event_id"_ls); } }; } // namespace Quotient |