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:
parent
5bd8178c94
commit
aeefb8a155
1 changed files with 14 additions and 17 deletions
|
@ -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 &)
|
||||
|
|
Loading…
Reference in a new issue