aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/definitions/event_filter.h
blob: c55d4f9293c9b243a98b9c70843ea77dffc6fe49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#pragma once

#include "converters.h"

namespace Quotient {

struct EventFilter {
    /// The maximum number of events to return.
    Omittable<int> limit;

    /// A list of sender IDs to exclude. If this list is absent then no senders
    /// are excluded. A matching sender will be excluded even if it is listed in
    /// the `'senders'` filter.
    QStringList notSenders;

    /// A list of event types to exclude. If this list is absent then no event
    /// types are excluded. A matching type will be excluded even if it is
    /// listed in the `'types'` filter. A '*' can be used as a wildcard to match
    /// any sequence of characters.
    QStringList notTypes;

    /// A list of senders IDs to include. If this list is absent then all
    /// senders are included.
    QStringList senders;

    /// A list of event types to include. If this list is absent then all event
    /// types are included. A `'*'` can be used as a wildcard to match any
    /// sequence of characters.
    QStringList types;
};

template <>
struct JsonObjectConverter<EventFilter> {
    static void dumpTo(QJsonObject& jo, const EventFilter& pod)
    {
        addParam<IfNotEmpty>(jo, QStringLiteral("limit"), pod.limit);
        addParam<IfNotEmpty>(jo, QStringLiteral("not_senders"), pod.notSenders);
        addParam<IfNotEmpty>(jo, QStringLiteral("not_types"), pod.notTypes);
        addParam<IfNotEmpty>(jo, QStringLiteral("senders"), pod.senders);
        addParam<IfNotEmpty>(jo, QStringLiteral("types"), pod.types);
    }
    static void fillFrom(const QJsonObject& jo, EventFilter& pod)
    {
        fromJson(jo.value("limit"_ls), pod.limit);
        fromJson(jo.value("not_senders"_ls), pod.notSenders);
        fromJson(jo.value("not_types"_ls), pod.notTypes);
        fromJson(jo.value("senders"_ls), pod.senders);
        fromJson(jo.value("types"_ls), pod.types);
    }
};

} // namespace Quotient