aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/joining.h
blob: 6d93bcb103c28a300b76ac323bd7dcfbce5e426c (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#pragma once

#include "converters.h"

#include "jobs/basejob.h"

#include <QtCore/QJsonObject>

namespace Quotient {

// Operations

/*! \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.*
 *
 * 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
 * allowed to see all current state events in the room, and all subsequent
 * 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.
 *
 * 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.
 */
class JoinRoomByIdJob : public BaseJob {
public:
    // Inner data structures

    /// 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.
        QString sender;
        /// The Matrix ID of the invitee.
        QString mxid;
        /// The state key of the m.third_party_invite event.
        QString token;
        /// A signatures object containing a signature of the entire signed
        /// object.
        QJsonObject signatures;
    };

    // Construction/destruction

    /*! \brief Start the requesting user participating in a particular room.
     *
     * \param roomId
     *   The room identifier (not alias) to join.
     * \param thirdPartySigned
     *   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.
     */
    explicit JoinRoomByIdJob(
        const QString& roomId,
        const Omittable<ThirdPartySigned>& thirdPartySigned = none);

    ~JoinRoomByIdJob() override;

    // Result properties

    /// The joined room ID.
    const QString& roomId() const;

protected:
    Status parseJson(const QJsonDocument& data) override;

private:
    class Private;
    QScopedPointer<Private> d;
};

/*! \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``.
 *
 * 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
 * allowed to see all current state events in the room, and all subsequent
 * 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.
 *
 * 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.
 */
class JoinRoomJob : public BaseJob {
public:
    // Inner data structures

    /// *Note that this API takes either a room ID or alias, unlike*
    /// ``/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
    /// allowed to see all current state events in the room, and all subsequent
    /// 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.
    ///
    /// 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.
    struct Signed {
        /// The Matrix ID of the user who issued the invite.
        QString sender;
        /// The Matrix ID of the invitee.
        QString mxid;
        /// The state key of the m.third_party_invite event.
        QString token;
        /// A signatures object containing a signature of the entire signed
        /// object.
        QJsonObject signatures;
    };

    /// 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 {
        /// 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.
        Signed signedData;
    };

    // Construction/destruction

    /*! \brief Start the requesting user participating in a particular room.
     *
     * \param roomIdOrAlias
     *   The room identifier or alias to join.
     * \param serverName
     *   The servers to attempt to join the room through. One of the servers
     *   must be participating in the room.
     * \param thirdPartySigned
     *   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.
     */
    explicit JoinRoomJob(
        const QString& roomIdOrAlias, const QStringList& serverName = {},
        const Omittable<ThirdPartySigned>& thirdPartySigned = none);

    ~JoinRoomJob() override;

    // Result properties

    /// The joined room ID.
    const QString& roomId() const;

protected:
    Status parseJson(const QJsonDocument& data) override;

private:
    class Private;
    QScopedPointer<Private> d;
};

} // namespace Quotient