aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/definitions/push_condition.h
diff options
context:
space:
mode:
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