File: account-data.h

package info (click to toggle)
libquotient 0.9.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,588 kB
  • sloc: xml: 39,103; cpp: 25,226; sh: 97; makefile: 10
file content (119 lines) | stat: -rw-r--r-- 4,677 bytes parent folder | download
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
// THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN

#pragma once

#include <Quotient/jobs/basejob.h>

namespace Quotient {

//! \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 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:
    //! \param userId
    //!   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
    //!   namespaced to avoid clashes.
    //!
    //! \param content
    //!   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.
//!
//! 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:
    //! \param userId
    //!   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
    //!   namespaced to avoid clashes.
    explicit GetAccountDataJob(const QString& userId, const QString& type);

    //! \brief Construct a URL without creating a full-fledged job object
    //!
    //! This function can be used when a URL for GetAccountDataJob
    //! is necessary but the job itself isn't.
    static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId,
                               const QString& type);

    // Result properties

    //! The account data content for the given type.
    QJsonObject data() const { return fromJson<QJsonObject>(jsonData()); }
};

inline auto collectResponse(const GetAccountDataJob* job) { return job->data(); }

//! \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 delivered to
//! clients in the per-room entries via [/sync](#get_matrixclientv3sync).
class QUOTIENT_API SetAccountDataPerRoomJob : public BaseJob {
public:
    //! \param userId
    //!   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.
    //!
    //! \param type
    //!   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.
    explicit SetAccountDataPerRoomJob(const QString& userId, const QString& roomId,
                                      const QString& type, const QJsonObject& content = {});
};

//! \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.
class QUOTIENT_API GetAccountDataPerRoomJob : public BaseJob {
public:
    //! \param userId
    //!   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.
    //!
    //! \param type
    //!   The event type of the account data to get. Custom types should be
    //!   namespaced to avoid clashes.
    explicit GetAccountDataPerRoomJob(const QString& userId, const QString& roomId,
                                      const QString& type);

    //! \brief Construct a URL without creating a full-fledged job object
    //!
    //! This function can be used when a URL for GetAccountDataPerRoomJob
    //! is necessary but the job itself isn't.
    static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId,
                               const QString& roomId, const QString& type);

    // Result properties

    //! The account data content for the given type.
    QJsonObject data() const { return fromJson<QJsonObject>(jsonData()); }
};

inline auto collectResponse(const GetAccountDataPerRoomJob* job) { return job->data(); }

} // namespace Quotient