aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/definitions/push_rule.h
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
committerAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
commit09eb39236666e81d5da014acea011dcd74d0999b (patch)
tree52876d96be71be1a39d5d935c1295a51995e8949 /lib/csapi/definitions/push_rule.h
parentf1788ee27f33e9339334e0d79bde9a27d9ce2e44 (diff)
parenta4e78956f105875625b572d8b98459ffa86fafe5 (diff)
downloadlibquotient-09eb39236666e81d5da014acea011dcd74d0999b.tar.gz
libquotient-09eb39236666e81d5da014acea011dcd74d0999b.zip
Update upstream source from tag 'upstream/0.6.4'
Update to upstream version '0.6.4' with Debian dir aa8705fd74743e79c043bc9e3e425d5064404cfe
Diffstat (limited to 'lib/csapi/definitions/push_rule.h')
-rw-r--r--lib/csapi/definitions/push_rule.h73
1 files changed, 44 insertions, 29 deletions
diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h
index bea13e96..43749bae 100644
--- a/lib/csapi/definitions/push_rule.h
+++ b/lib/csapi/definitions/push_rule.h
@@ -7,37 +7,52 @@
#include "converters.h"
#include "csapi/definitions/push_condition.h"
-#include <QtCore/QJsonObject>
-#include <QtCore/QVector>
-#include <QtCore/QVariant>
-#include "converters.h"
-namespace QMatrixClient
-{
- // Data structures
+namespace Quotient {
+
+struct PushRule {
+ /// The actions to perform when this rule is matched.
+ QVector<QVariant> actions;
+
+ /// Whether this is a default rule, or has been set explicitly.
+ bool isDefault;
+
+ /// Whether the push rule is enabled or not.
+ bool enabled;
+
+ /// The ID of this rule.
+ QString ruleId;
+
+ /// The conditions that must hold true for an event in order for a rule to
+ /// be applied to an event. A rule with no conditions always matches. Only
+ /// applicable to ``underride`` and ``override`` rules.
+ QVector<PushCondition> conditions;
+
+ /// The glob-style pattern to match against. Only applicable to ``content``
+ /// rules.
+ QString pattern;
+};
- struct PushRule
+template <>
+struct JsonObjectConverter<PushRule> {
+ static void dumpTo(QJsonObject& jo, const PushRule& pod)
{
- /// The actions to perform when this rule is matched.
- QVector<QVariant> actions;
- /// Whether this is a default rule, or has been set explicitly.
- bool isDefault;
- /// Whether the push rule is enabled or not.
- bool enabled;
- /// The ID of this rule.
- QString ruleId;
- /// The conditions that must hold true for an event in order for a rule to be
- /// applied to an event. A rule with no conditions always matches. Only
- /// applicable to ``underride`` and ``override`` rules.
- QVector<PushCondition> conditions;
- /// The glob-style pattern to match against. Only applicable to ``content``
- /// rules.
- QString pattern;
- };
- template <> struct JsonObjectConverter<PushRule>
+ addParam<>(jo, QStringLiteral("actions"), pod.actions);
+ addParam<>(jo, QStringLiteral("default"), pod.isDefault);
+ addParam<>(jo, QStringLiteral("enabled"), pod.enabled);
+ addParam<>(jo, QStringLiteral("rule_id"), pod.ruleId);
+ addParam<IfNotEmpty>(jo, QStringLiteral("conditions"), pod.conditions);
+ addParam<IfNotEmpty>(jo, QStringLiteral("pattern"), pod.pattern);
+ }
+ static void fillFrom(const QJsonObject& jo, PushRule& pod)
{
- static void dumpTo(QJsonObject& jo, const PushRule& pod);
- static void fillFrom(const QJsonObject& jo, PushRule& pod);
- };
+ fromJson(jo.value("actions"_ls), pod.actions);
+ fromJson(jo.value("default"_ls), pod.isDefault);
+ fromJson(jo.value("enabled"_ls), pod.enabled);
+ fromJson(jo.value("rule_id"_ls), pod.ruleId);
+ fromJson(jo.value("conditions"_ls), pod.conditions);
+ fromJson(jo.value("pattern"_ls), pod.pattern);
+ }
+};
-} // namespace QMatrixClient
+} // namespace Quotient