0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-25 05:18:23 +02:00

ircd:Ⓜ️ Add RoomEventFilter matcher.

This commit is contained in:
Jason Volk 2018-02-17 13:08:59 -08:00
parent d89eaf338c
commit 3c359e1dcc
2 changed files with 20 additions and 0 deletions

View file

@ -21,6 +21,7 @@ namespace ircd::m
struct room_event_filter;
bool match(const event_filter &, const event &);
bool match(const room_event_filter &, const event &);
}
/// 5.1 "Filter" we use event_filter here

View file

@ -10,6 +10,25 @@
#include <ircd/m/m.h>
//TODO: globular expression
bool
ircd::m::match(const room_event_filter &filter,
const event &event)
{
for(const auto &room_id : json::get<"not_rooms"_>(filter))
if(at<"room_id"_>(event) == unquote(room_id))
return false;
if(empty(json::get<"rooms"_>(filter)))
return match(event_filter{filter}, event);
for(const auto &room_id : json::get<"rooms"_>(filter))
if(at<"room_id"_>(event) == unquote(room_id))
return match(event_filter{filter}, event);
return false;
}
//TODO: globular expression
bool
ircd::m::match(const event_filter &filter,