diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-07-29 17:19:18 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-07-29 18:33:08 +0900 |
commit | 68358af90bdfbcb6f2884c6d1c795f1724cf840b (patch) | |
tree | 02ae3f7c8bc5cb49ee5cb35257aaf3b9443f7b7e /lib/csapi/definitions/push_rule.cpp | |
parent | 941cfdf8b591bf14002f28e99e06c200dc5bcc84 (diff) | |
download | libquotient-68358af90bdfbcb6f2884c6d1c795f1724cf840b.tar.gz libquotient-68358af90bdfbcb6f2884c6d1c795f1724cf840b.zip |
csapi: define PushRule more accurately
It's not always a JSON object; it's either a SetTweakAction object or a string. (Unfortunately, QVariant isn't a template type and there's no easy way to put Q_DECLARE_METATYPE(SetTweakAction) in a Mustache template, so adding one is left as an exercise to the user now.)
Diffstat (limited to 'lib/csapi/definitions/push_rule.cpp')
-rw-r--r-- | lib/csapi/definitions/push_rule.cpp | 18 |
1 files changed, 18 insertions, 0 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; |