diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-06-09 08:52:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-09 08:52:25 +0200 |
commit | 370d9b3e46332d38df8798cda208c534c58be808 (patch) | |
tree | f3db0cd7463468ff52c74446acd608356f8b8ab6 /lib/csapi/definitions/push_condition.h | |
parent | e1f5d0aa2c33e6da6c3a609c8bc7e0b5867e748d (diff) | |
parent | 10d9ac4673e374a9ac17ff492591136520337c4c (diff) | |
download | libquotient-370d9b3e46332d38df8798cda208c534c58be808.tar.gz libquotient-370d9b3e46332d38df8798cda208c534c58be808.zip |
Merge pull request #405 from quotient-im/kitsune-basejob-store-json-response
Store JSON response in BaseJob + tweaks to the generated code
Diffstat (limited to 'lib/csapi/definitions/push_condition.h')
-rw-r--r-- | lib/csapi/definitions/push_condition.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/csapi/definitions/push_condition.h b/lib/csapi/definitions/push_condition.h index 189153b3..a6decf1b 100644 --- a/lib/csapi/definitions/push_condition.h +++ b/lib/csapi/definitions/push_condition.h @@ -8,13 +8,18 @@ namespace Quotient { -// Data structures - struct PushCondition { + /// The kind of condition to apply. See `conditions <#conditions>`_ for + /// more information on the allowed kinds and how they work. QString kind; /// Required for ``event_match`` conditions. The dot-separated field of the /// event to match. + /// + /// Required for ``sender_notification_permission`` conditions. The field in + /// the power level event the user needs a minimum power level for. Fields + /// must be specified under the ``notifications`` property in the power + /// level event's ``content``. QString key; /// Required for ``event_match`` conditions. The glob-style pattern to @@ -32,8 +37,20 @@ struct PushCondition { template <> struct JsonObjectConverter<PushCondition> { - static void dumpTo(QJsonObject& jo, const PushCondition& pod); - static void fillFrom(const QJsonObject& jo, PushCondition& pod); + static void dumpTo(QJsonObject& jo, const PushCondition& pod) + { + addParam<>(jo, QStringLiteral("kind"), pod.kind); + addParam<IfNotEmpty>(jo, QStringLiteral("key"), pod.key); + addParam<IfNotEmpty>(jo, QStringLiteral("pattern"), pod.pattern); + addParam<IfNotEmpty>(jo, QStringLiteral("is"), pod.is); + } + static void fillFrom(const QJsonObject& jo, PushCondition& pod) + { + fromJson(jo.value("kind"_ls), pod.kind); + fromJson(jo.value("key"_ls), pod.key); + fromJson(jo.value("pattern"_ls), pod.pattern); + fromJson(jo.value("is"_ls), pod.is); + } }; } // namespace Quotient |