aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/presence.h
blob: 4ab50e25f3d3e73ba824f813d4b0a9464e21d11a (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 Update this user's presence state.
 *
 * This API sets the given user's presence state. When setting the status,
 * the activity time is updated to reflect that activity; the client does
 * not need to specify the `last_active_ago` field. You cannot set the
 * presence state of another user.
 */
class SetPresenceJob : public BaseJob {
public:
    /*! \brief Update this user's presence state.
     *
     * \param userId
     *   The user whose presence state to update.
     *
     * \param presence
     *   The new presence state.
     *
     * \param statusMsg
     *   The status message to attach to this state.
     */
    explicit SetPresenceJob(const QString& userId, const QString& presence,
                            const QString& statusMsg = {});
};

/*! \brief Get this user's presence state.
 *
 * Get the given user's presence state.
 */
class GetPresenceJob : public BaseJob {
public:
    /*! \brief Get this user's presence state.
     *
     * \param userId
     *   The user whose presence state to get.
     */
    explicit GetPresenceJob(const QString& userId);

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

    // Result properties

    /// This user's presence.
    QString presence() const { return loadFromJson<QString>("presence"_ls); }

    /// The length of time in milliseconds since an action was performed
    /// by this user.
    Omittable<int> lastActiveAgo() const
    {
        return loadFromJson<Omittable<int>>("last_active_ago"_ls);
    }

    /// The state message for this user if one was set.
    QString statusMsg() const { return loadFromJson<QString>("status_msg"_ls); }

    /// Whether the user is currently active
    Omittable<bool> currentlyActive() const
    {
        return loadFromJson<Omittable<bool>>("currently_active"_ls);
    }
};

} // namespace Quotient
pan class="s">"/_matrix/client/r0") % "/rooms/" % roomId % "/state/" % eventType % "/" % stateKey) {} QUrl GetRoomStateJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/state"); } GetRoomStateJob::GetRoomStateJob(const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateJob"), QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/state") {} auto queryToGetMembersByRoom(const QString& at, const QString& membership, const QString& notMembership) { QUrlQuery _q; addParam<IfNotEmpty>(_q, QStringLiteral("at"), at); addParam<IfNotEmpty>(_q, QStringLiteral("membership"), membership); addParam<IfNotEmpty>(_q, QStringLiteral("not_membership"), notMembership); return _q; } QUrl GetMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& at, const QString& membership, const QString& notMembership) { return BaseJob::makeRequestUrl( std::move(baseUrl), QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/members", queryToGetMembersByRoom(at, membership, notMembership)); } GetMembersByRoomJob::GetMembersByRoomJob(const QString& roomId, const QString& at, const QString& membership, const QString& notMembership) : BaseJob(HttpVerb::Get, QStringLiteral("GetMembersByRoomJob"), QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/members", queryToGetMembersByRoom(at, membership, notMembership)) {} QUrl GetJoinedMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/joined_members"); } GetJoinedMembersByRoomJob::GetJoinedMembersByRoomJob(const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetJoinedMembersByRoomJob"), QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/joined_members") {}