2018-02-04 03:22:01 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
2017-09-25 03:05:42 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_M_FILTER_H
|
|
|
|
|
|
|
|
namespace ircd::m
|
|
|
|
{
|
|
|
|
struct filter;
|
|
|
|
struct room_filter;
|
|
|
|
struct event_filter;
|
|
|
|
struct room_event_filter;
|
2019-03-31 22:25:00 +02:00
|
|
|
struct state_filter;
|
2018-02-17 21:58:34 +01:00
|
|
|
|
2022-07-13 02:25:33 +02:00
|
|
|
bool match(const event_filter &, const event &);
|
|
|
|
bool match(const room_event_filter &, const event &);
|
2017-09-25 03:05:42 +02:00
|
|
|
}
|
|
|
|
|
2018-02-17 21:58:34 +01:00
|
|
|
/// 5.1 "Filter" we use event_filter here
|
2017-09-25 03:05:42 +02:00
|
|
|
struct ircd::m::event_filter
|
|
|
|
:json::tuple
|
|
|
|
<
|
2018-04-27 06:44:48 +02:00
|
|
|
json::property<name::limit, long>,
|
2017-09-25 03:05:42 +02:00
|
|
|
json::property<name::types, json::array>,
|
|
|
|
json::property<name::senders, json::array>,
|
2020-03-30 22:06:21 +02:00
|
|
|
json::property<name::labels, json::array>,
|
2017-09-25 03:05:42 +02:00
|
|
|
json::property<name::not_types, json::array>,
|
2020-03-30 22:06:21 +02:00
|
|
|
json::property<name::not_senders, json::array>,
|
|
|
|
json::property<name::not_labels, json::array>
|
2017-09-25 03:05:42 +02:00
|
|
|
>
|
|
|
|
{
|
|
|
|
using super_type::tuple;
|
2018-04-19 22:47:51 +02:00
|
|
|
event_filter(const mutable_buffer &, const json::members &);
|
|
|
|
event_filter() = default;
|
2017-09-25 03:05:42 +02:00
|
|
|
using super_type::operator=;
|
|
|
|
};
|
|
|
|
|
2018-02-17 21:58:34 +01:00
|
|
|
/// 5.1 "RoomEventFilter"
|
2017-09-25 03:05:42 +02:00
|
|
|
struct ircd::m::room_event_filter
|
|
|
|
:json::tuple
|
|
|
|
<
|
2018-04-27 06:44:48 +02:00
|
|
|
json::property<name::limit, long>,
|
2017-09-25 03:05:42 +02:00
|
|
|
json::property<name::types, json::array>,
|
|
|
|
json::property<name::rooms, json::array>,
|
|
|
|
json::property<name::senders, json::array>,
|
2020-03-30 22:06:21 +02:00
|
|
|
json::property<name::labels, json::array>,
|
2017-09-25 03:05:42 +02:00
|
|
|
json::property<name::not_types, json::array>,
|
|
|
|
json::property<name::not_rooms, json::array>,
|
2018-05-12 11:27:39 +02:00
|
|
|
json::property<name::not_senders, json::array>,
|
2020-03-30 22:06:21 +02:00
|
|
|
json::property<name::not_labels, json::array>,
|
2019-07-08 02:00:36 +02:00
|
|
|
json::property<name::contains_url, bool>,
|
|
|
|
json::property<name::lazy_load_members, bool>,
|
|
|
|
json::property<name::include_redundant_members, bool>
|
2017-09-25 03:05:42 +02:00
|
|
|
>
|
|
|
|
{
|
|
|
|
using super_type::tuple;
|
2018-04-19 23:03:08 +02:00
|
|
|
room_event_filter(const mutable_buffer &, const json::members &);
|
|
|
|
room_event_filter() = default;
|
2017-09-25 03:05:42 +02:00
|
|
|
using super_type::operator=;
|
|
|
|
};
|
|
|
|
|
2019-03-31 22:25:00 +02:00
|
|
|
/// "StateFilter"
|
|
|
|
struct ircd::m::state_filter
|
|
|
|
:json::tuple
|
|
|
|
<
|
|
|
|
json::property<name::limit, long>,
|
|
|
|
json::property<name::types, json::array>,
|
|
|
|
json::property<name::rooms, json::array>,
|
|
|
|
json::property<name::senders, json::array>,
|
2020-03-30 22:06:21 +02:00
|
|
|
json::property<name::labels, json::array>,
|
2019-03-31 22:25:00 +02:00
|
|
|
json::property<name::not_types, json::array>,
|
|
|
|
json::property<name::not_rooms, json::array>,
|
|
|
|
json::property<name::not_senders, json::array>,
|
2020-03-30 22:06:21 +02:00
|
|
|
json::property<name::not_labels, json::array>,
|
2019-03-31 22:25:00 +02:00
|
|
|
json::property<name::contains_url, bool>,
|
|
|
|
json::property<name::lazy_load_members, bool>,
|
|
|
|
json::property<name::include_redundant_members, bool>
|
|
|
|
>
|
|
|
|
{
|
|
|
|
using super_type::tuple;
|
|
|
|
state_filter(const mutable_buffer &, const json::members &);
|
|
|
|
state_filter() = default;
|
|
|
|
using super_type::operator=;
|
|
|
|
};
|
|
|
|
|
2018-02-17 21:58:34 +01:00
|
|
|
/// 5.1 "RoomFilter"
|
2017-09-25 03:05:42 +02:00
|
|
|
struct ircd::m::room_filter
|
|
|
|
:json::tuple
|
|
|
|
<
|
|
|
|
json::property<name::rooms, json::array>,
|
|
|
|
json::property<name::not_rooms, json::array>,
|
2019-03-31 22:25:00 +02:00
|
|
|
json::property<name::state, state_filter>,
|
2017-09-25 03:05:42 +02:00
|
|
|
json::property<name::timeline, room_event_filter>,
|
|
|
|
json::property<name::ephemeral, room_event_filter>,
|
|
|
|
json::property<name::account_data, room_event_filter>,
|
|
|
|
json::property<name::include_leave, bool>
|
|
|
|
>
|
|
|
|
{
|
|
|
|
using super_type::tuple;
|
2018-04-19 23:03:08 +02:00
|
|
|
room_filter(const mutable_buffer &, const json::members &);
|
|
|
|
room_filter() = default;
|
2017-09-25 03:05:42 +02:00
|
|
|
using super_type::operator=;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ircd::m::filter
|
|
|
|
:json::tuple
|
|
|
|
<
|
|
|
|
json::property<name::event_fields, json::array>,
|
|
|
|
json::property<name::event_format, string_view>,
|
|
|
|
json::property<name::account_data, event_filter>,
|
|
|
|
json::property<name::room, room_filter>,
|
|
|
|
json::property<name::presence, event_filter>
|
|
|
|
>
|
|
|
|
{
|
|
|
|
using super_type::tuple;
|
2018-02-12 04:45:31 +01:00
|
|
|
filter(const user &, const string_view &filter_id, const mutable_buffer &);
|
2018-05-13 01:00:37 +02:00
|
|
|
using super_type::operator=;
|
2019-03-31 23:33:12 +02:00
|
|
|
|
|
|
|
static std::string get(const string_view &urle_id_or_json, const m::user &);
|
2017-09-25 03:05:42 +02:00
|
|
|
};
|