diff options
Diffstat (limited to 'lib/csapi/definitions')
-rw-r--r-- | lib/csapi/definitions/push_rule.cpp | 18 | ||||
-rw-r--r-- | lib/csapi/definitions/push_rule.h | 27 |
2 files changed, 43 insertions, 2 deletions
diff --git a/lib/csapi/definitions/push_rule.cpp b/lib/csapi/definitions/push_rule.cpp index 833135ec..1ee57945 100644 --- a/lib/csapi/definitions/push_rule.cpp +++ b/lib/csapi/definitions/push_rule.cpp @@ -6,6 +6,24 @@ using namespace QMatrixClient; +QJsonObject QMatrixClient::toJson(const SetTweakAction& pod) +{ + QJsonObject _json = toJson(pod.additionalProperties); + addParam<>(_json, QStringLiteral("set_tweak"), pod.setTweak); + return _json; +} + +SetTweakAction FromJson<SetTweakAction>::operator()(const QJsonValue& jv) +{ + auto _json = jv.toObject(); + SetTweakAction result; + result.setTweak = + fromJson<QString>(_json.take("set_tweak"_ls)); + + result.additionalProperties = fromJson<QVariantHash>(_json); + return result; +} + QJsonObject QMatrixClient::toJson(const PushRule& pod) { QJsonObject _json; diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index c6542aa6..6959e9d1 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -7,15 +7,38 @@ #include "converters.h" #include "csapi/definitions/push_condition.h" -#include "converters.h" #include <QtCore/QVector> #include <QtCore/QVariant> -#include <QtCore/QJsonObject> +#include "converters.h" namespace QMatrixClient { // Data structures + /// Specifies an entry to the 'tweaks' dictionary sent in + /// the notification request to the Push Gateway. + /// Tweak parameters, if any, are provided as additional + /// key-value pairs in this structure. + struct SetTweakAction + { + /// The tweak type. Two predefined types are `sound` + /// and `highlight`; client applications and Push Gateways + /// may agree on additional tweak types. + QString setTweak; + /// Specifies an entry to the 'tweaks' dictionary sent in + /// the notification request to the Push Gateway. + /// Tweak parameters, if any, are provided as additional + /// key-value pairs in this structure. + QVariantHash additionalProperties; + }; + + QJsonObject toJson(const SetTweakAction& pod); + + template <> struct FromJson<SetTweakAction> + { + SetTweakAction operator()(const QJsonValue& jv); + }; + struct PushRule { /// The actions to perform when this rule is matched. |