diff options
author | Black Hat <bhat@encom.eu.org> | 2019-09-26 22:22:36 -0700 |
---|---|---|
committer | Black Hat <bhat@encom.eu.org> | 2019-09-26 22:22:36 -0700 |
commit | 363cf452bcdbaf6ff1cf94a83ca66cbb31122346 (patch) | |
tree | c64c8fda885e4e1785130e8ee3e7c47fd18cbf67 /lib/csapi/notifications.h | |
parent | 412e2cf19449e73aa7da729e9c5de6502687aade (diff) | |
parent | 944653463fe4134c82d85e2d01e2bc0fa43fd727 (diff) | |
download | libquotient-363cf452bcdbaf6ff1cf94a83ca66cbb31122346.tar.gz libquotient-363cf452bcdbaf6ff1cf94a83ca66cbb31122346.zip |
Merge branch 'master' of https://github.com/quotient-im/libQuotient into
bhat-libqtolm-update
Diffstat (limited to 'lib/csapi/notifications.h')
-rw-r--r-- | lib/csapi/notifications.h | 158 |
1 files changed, 83 insertions, 75 deletions
diff --git a/lib/csapi/notifications.h b/lib/csapi/notifications.h index 898b5154..eeec5d4e 100644 --- a/lib/csapi/notifications.h +++ b/lib/csapi/notifications.h @@ -4,86 +4,94 @@ #pragma once -#include "jobs/basejob.h" +#include "converters.h" #include "events/eventloader.h" -#include "converters.h" -#include <QtCore/QVector> -#include <QtCore/QVariant> +#include "jobs/basejob.h" + #include <QtCore/QJsonObject> +#include <QtCore/QVariant> +#include <QtCore/QVector> + +namespace Quotient +{ -namespace QMatrixClient +// Operations + +/// Gets a list of events that the user has been notified about +/*! + * This API is used to paginate through the list of events that the + * user has been, or would have been notified about. + */ +class GetNotificationsJob : public BaseJob { - // Operations +public: + // Inner data structures - /// Gets a list of events that the user has been notified about - /// - /// This API is used to paginate through the list of events that the - /// user has been, or would have been notified about. - class GetNotificationsJob : public BaseJob + /// This API is used to paginate through the list of events that theuser has + /// been, or would have been notified about. + struct Notification { - public: - // Inner data structures - - /// This API is used to paginate through the list of events that the - /// user has been, or would have been notified about. - struct Notification - { - /// The action(s) to perform when the conditions for this rule are met. - /// See `Push Rules: API`_. - QVector<QVariant> actions; - /// The Event object for the event that triggered the notification. - EventPtr event; - /// The profile tag of the rule that matched this event. - QString profileTag; - /// Indicates whether the user has sent a read receipt indicating - /// that they have read this message. - bool read; - /// The ID of the room in which the event was posted. - QString roomId; - /// The unix timestamp at which the event notification was sent, - /// in milliseconds. - int ts; - }; - - // Construction/destruction - - /*! Gets a list of events that the user has been notified about - * \param from - * Pagination token given to retrieve the next set of events. - * \param limit - * Limit on the number of events to return in this request. - * \param only - * Allows basic filtering of events returned. Supply ``highlight`` - * to return only events where the notification had the highlight - * tweak set. - */ - explicit GetNotificationsJob(const QString& from = {}, Omittable<int> limit = none, const QString& only = {}); - - /*! Construct a URL without creating a full-fledged job object - * - * This function can be used when a URL for - * GetNotificationsJob is necessary but the job - * itself isn't. - */ - static QUrl makeRequestUrl(QUrl baseUrl, const QString& from = {}, Omittable<int> limit = none, const QString& only = {}); - - ~GetNotificationsJob() override; - - // Result properties - - /// The token to supply in the ``from`` param of the next - /// ``/notifications`` request in order to request more - /// events. If this is absent, there are no more results. - const QString& nextToken() const; - /// The list of events that triggered notifications. - std::vector<Notification>&& notifications(); - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer<Private> d; + /// The action(s) to perform when the conditions for this rule are + /// met.See `Push Rules: API`_. + QVector<QVariant> actions; + /// The Event object for the event that triggered the notification. + EventPtr event; + /// The profile tag of the rule that matched this event. + QString profileTag; + /// Indicates whether the user has sent a read receipt indicatingthat + /// they have read this message. + bool read; + /// The ID of the room in which the event was posted. + QString roomId; + /// The unix timestamp at which the event notification was sent,in + /// milliseconds. + int ts; }; -} // namespace QMatrixClient + + // Construction/destruction + + /*! Gets a list of events that the user has been notified about + * \param from + * Pagination token given to retrieve the next set of events. + * \param limit + * Limit on the number of events to return in this request. + * \param only + * Allows basic filtering of events returned. Supply ``highlight`` + * to return only events where the notification had the highlight + * tweak set. + */ + explicit GetNotificationsJob(const QString& from = {}, + Omittable<int> limit = none, + const QString& only = {}); + + /*! Construct a URL without creating a full-fledged job object + * + * This function can be used when a URL for + * GetNotificationsJob is necessary but the job + * itself isn't. + */ + static QUrl makeRequestUrl(QUrl baseUrl, const QString& from = {}, + Omittable<int> limit = none, + const QString& only = {}); + + ~GetNotificationsJob() override; + + // Result properties + + /// The token to supply in the ``from`` param of the next + /// ``/notifications`` request in order to request more + /// events. If this is absent, there are no more results. + const QString& nextToken() const; + /// The list of events that triggered notifications. + std::vector<Notification>&& notifications(); + +protected: + Status parseJson(const QJsonDocument& data) override; + +private: + class Private; + QScopedPointer<Private> d; +}; + +} // namespace Quotient |