libQuotient
A Qt library for building matrix clients
push_rule.h
Go to the documentation of this file.
1 // THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
2 
3 #pragma once
4 
5 #include <Quotient/csapi/definitions/push_condition.h>
6 
7 #include <Quotient/converters.h>
8 
9 namespace Quotient {
10 
11 struct QUOTIENT_API PushRule {
12  //! The actions to perform when this rule is matched.
13  QVector<QVariant> actions;
14 
15  //! Whether this is a default rule, or has been set explicitly.
16  bool isDefault;
17 
18  //! Whether the push rule is enabled or not.
19  bool enabled;
20 
21  //! The ID of this rule.
22  QString ruleId;
23 
24  //! The conditions that must hold true for an event in order for a rule to be
25  //! applied to an event. A rule with no conditions always matches. Only
26  //! applicable to `underride` and `override` rules.
27  QVector<PushCondition> conditions{};
28 
29  //! The [glob-style pattern](/appendices#glob-style-matching) to match against.
30  //! Only applicable to `content` rules.
31  QString pattern{};
32 };
33 
34 template <>
35 struct JsonObjectConverter<PushRule> {
36  static void dumpTo(QJsonObject& jo, const PushRule& pod)
37  {
38  addParam<>(jo, QStringLiteral("actions"), pod.actions);
39  addParam<>(jo, QStringLiteral("default"), pod.isDefault);
40  addParam<>(jo, QStringLiteral("enabled"), pod.enabled);
41  addParam<>(jo, QStringLiteral("rule_id"), pod.ruleId);
42  addParam<IfNotEmpty>(jo, QStringLiteral("conditions"), pod.conditions);
43  addParam<IfNotEmpty>(jo, QStringLiteral("pattern"), pod.pattern);
44  }
45  static void fillFrom(const QJsonObject& jo, PushRule& pod)
46  {
47  fillFromJson(jo.value("actions"_ls), pod.actions);
48  fillFromJson(jo.value("default"_ls), pod.isDefault);
49  fillFromJson(jo.value("enabled"_ls), pod.enabled);
50  fillFromJson(jo.value("rule_id"_ls), pod.ruleId);
51  fillFromJson(jo.value("conditions"_ls), pod.conditions);
52  fillFromJson(jo.value("pattern"_ls), pod.pattern);
53  }
54 };
55 
56 } // namespace Quotient