0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-29 00:03:45 +02: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,27 +119,29 @@ 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(json::type(value, std::nothrow) != json::OBJECT)
return false;
if(!tokens(path, ".", walk))
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
@ -147,11 +149,6 @@ try
json::get<"pattern"_>(cond)
};
const json::string &value
{
targ[prop]
};
return pattern(value);
}
catch(const ctx::interrupted &)