0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 18:22:50 +01:00

ircd:Ⓜ️:push: Fixes for the event_match condition functor.

This commit is contained in:
Jason Volk 2020-03-22 16:22:54 -07:00
parent 5bd8178c94
commit aeefb8a155

View file

@ -119,39 +119,36 @@ try
{
assert(json::get<"kind"_>(cond) == "event_match");
const auto &[path, prop]
const auto &[top, path]
{
rsplit(json::get<"key"_>(cond), '.')
split(json::get<"key"_>(cond), '.')
};
json::object targ
string_view value
{
event.source
json::get(event, top, json::object{})
};
const token_view_bool walk
tokens(path, ".", token_view_bool{[&value]
(const string_view &key)
{
[&targ](const string_view &key)
{
targ = targ[key];
return targ && json::type(targ) == json::OBJECT;
}
};
if(!tokens(path, ".", walk))
if(json::type(value, std::nothrow) != json::OBJECT)
return false;
value = json::object(value)[key];
if(likely(json::type(value, std::nothrow) != json::STRING))
return true;
value = json::string(value);
return false;
}});
//TODO: XXX spec leading/trailing; not imatch
const globular_imatch pattern
{
json::get<"pattern"_>(cond)
};
const json::string &value
{
targ[prop]
};
return pattern(value);
}
catch(const ctx::interrupted &)