aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/room_state.h
blob: a00b09470f1f49c1f487491b2e86973248955279 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#pragma once

#include "jobs/basejob.h"

namespace Quotient {

/*! \brief Send a state event to the given room.
 *
 * State events can be sent using this endpoint.  These events will be
 * overwritten if `<room id>`, `<event type>` and `<state key>` 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.
 *
 * 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.
 *
 * 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 QUOTIENT_API 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. When
     *   an empty string, the trailing slash on this endpoint is optional.
     *
     * \param body
     *   State events can be sent using this endpoint.  These events will be
     *   overwritten if `<room id>`, `<event type>` and `<state key>` 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.
     *
     *   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.
     *
     *   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 = {});

    // Result properties

    /// A unique identifier for the event.
    QString eventId() const { return loadFromJson<QString>("event_id"_ls); }
};

} // namespace Quotient