mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd:Ⓜ️:event::auth::chain: No closing over full event; overload void closure.
This commit is contained in:
parent
ed87eb31e0
commit
f275cf8c83
5 changed files with 42 additions and 22 deletions
|
@ -51,7 +51,8 @@ struct ircd::m::event::auth::refs
|
|||
|
||||
struct ircd::m::event::auth::chain
|
||||
{
|
||||
using closure_bool = std::function<bool (const event::idx &, const event &)>;
|
||||
using closure_bool = event::closure_idx_bool;
|
||||
using closure = event::closure_idx;
|
||||
|
||||
event::idx idx;
|
||||
|
||||
|
@ -59,6 +60,8 @@ struct ircd::m::event::auth::chain
|
|||
|
||||
public:
|
||||
bool for_each(const closure_bool &) const;
|
||||
bool for_each(const closure &) const;
|
||||
|
||||
bool has(const string_view &type) const noexcept;
|
||||
size_t depth() const noexcept;
|
||||
|
||||
|
|
|
@ -1433,10 +1433,9 @@ ircd::m::event::auth::chain::depth()
|
|||
const noexcept
|
||||
{
|
||||
size_t ret(0);
|
||||
for_each([&ret](const auto &, const auto &)
|
||||
for_each([&ret](const auto &)
|
||||
{
|
||||
++ret;
|
||||
return true;
|
||||
});
|
||||
|
||||
return ret;
|
||||
|
@ -1447,16 +1446,33 @@ ircd::m::event::auth::chain::has(const string_view &type)
|
|||
const noexcept
|
||||
{
|
||||
bool ret(false);
|
||||
for_each([&type, &ret]
|
||||
(const auto &, const auto &event)
|
||||
for_each(closure_bool{[&type, &ret]
|
||||
(const auto &idx)
|
||||
{
|
||||
ret = type == json::get<"type"_>(event);
|
||||
return !ret;
|
||||
m::get(std::nothrow, idx, "type", [&type, &ret]
|
||||
(const auto &value)
|
||||
{
|
||||
ret = value == type;
|
||||
});
|
||||
|
||||
return !ret;
|
||||
}});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::event::auth::chain::for_each(const closure &closure)
|
||||
const
|
||||
{
|
||||
return for_each(closure_bool{[&closure]
|
||||
(const auto &idx)
|
||||
{
|
||||
closure(idx);
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::event::auth::chain::for_each(const closure_bool &closure)
|
||||
const
|
||||
|
|
|
@ -5939,13 +5939,18 @@ console_cmd__event__auth(opt &out, const string_view &line)
|
|||
m::index(event_id)
|
||||
};
|
||||
|
||||
ac.for_each([&out](const auto &idx, const auto &event)
|
||||
ac.for_each([&out](const auto &idx)
|
||||
{
|
||||
out << idx
|
||||
<< " " << pretty_oneline(event)
|
||||
<< std::endl;
|
||||
const m::event::fetch event
|
||||
{
|
||||
idx, std::nothrow
|
||||
};
|
||||
|
||||
return true;
|
||||
out << idx;
|
||||
if(event.valid)
|
||||
out << " " << pretty_oneline(event);
|
||||
|
||||
out << std::endl;
|
||||
});
|
||||
|
||||
return true;
|
||||
|
|
|
@ -96,11 +96,12 @@ get__event_auth(client &client,
|
|||
m::index(event_id)
|
||||
};
|
||||
|
||||
chain.for_each([&auth_chain]
|
||||
(const m::event::idx &event_idx, const m::event &event)
|
||||
m::event::fetch event;
|
||||
chain.for_each([&auth_chain, &event]
|
||||
(const m::event::idx &event_idx)
|
||||
{
|
||||
if(seek(event, event_idx, std::nothrow))
|
||||
auth_chain.append(event);
|
||||
return true;
|
||||
});
|
||||
|
||||
return {};
|
||||
|
|
|
@ -598,13 +598,8 @@ ircd::m::event::auth::chain::for_each(const auth::chain &c,
|
|||
while(!aq.empty());
|
||||
|
||||
for(const auto &idx : ae)
|
||||
{
|
||||
if(!seek(e, idx, std::nothrow))
|
||||
continue;
|
||||
|
||||
if(!closure(idx, e))
|
||||
if(!closure(idx))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue