aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/definitions/push_condition.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-06-09 08:52:25 +0200
committerGitHub <noreply@github.com>2020-06-09 08:52:25 +0200
commit370d9b3e46332d38df8798cda208c534c58be808 (patch)
treef3db0cd7463468ff52c74446acd608356f8b8ab6 /lib/csapi/definitions/push_condition.h
parente1f5d0aa2c33e6da6c3a609c8bc7e0b5867e748d (diff)
parent10d9ac4673e374a9ac17ff492591136520337c4c (diff)
downloadlibquotient-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.h25
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