mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +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
|
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;
|
event::idx idx;
|
||||||
|
|
||||||
|
@ -59,6 +60,8 @@ struct ircd::m::event::auth::chain
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool for_each(const closure_bool &) const;
|
bool for_each(const closure_bool &) const;
|
||||||
|
bool for_each(const closure &) const;
|
||||||
|
|
||||||
bool has(const string_view &type) const noexcept;
|
bool has(const string_view &type) const noexcept;
|
||||||
size_t depth() const noexcept;
|
size_t depth() const noexcept;
|
||||||
|
|
||||||
|
|
|
@ -1433,10 +1433,9 @@ ircd::m::event::auth::chain::depth()
|
||||||
const noexcept
|
const noexcept
|
||||||
{
|
{
|
||||||
size_t ret(0);
|
size_t ret(0);
|
||||||
for_each([&ret](const auto &, const auto &)
|
for_each([&ret](const auto &)
|
||||||
{
|
{
|
||||||
++ret;
|
++ret;
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1447,16 +1446,33 @@ ircd::m::event::auth::chain::has(const string_view &type)
|
||||||
const noexcept
|
const noexcept
|
||||||
{
|
{
|
||||||
bool ret(false);
|
bool ret(false);
|
||||||
for_each([&type, &ret]
|
for_each(closure_bool{[&type, &ret]
|
||||||
(const auto &, const auto &event)
|
(const auto &idx)
|
||||||
{
|
{
|
||||||
ret = type == json::get<"type"_>(event);
|
m::get(std::nothrow, idx, "type", [&type, &ret]
|
||||||
return !ret;
|
(const auto &value)
|
||||||
|
{
|
||||||
|
ret = value == type;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return !ret;
|
||||||
|
}});
|
||||||
|
|
||||||
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
|
bool
|
||||||
ircd::m::event::auth::chain::for_each(const closure_bool &closure)
|
ircd::m::event::auth::chain::for_each(const closure_bool &closure)
|
||||||
const
|
const
|
||||||
|
|
|
@ -5939,13 +5939,18 @@ console_cmd__event__auth(opt &out, const string_view &line)
|
||||||
m::index(event_id)
|
m::index(event_id)
|
||||||
};
|
};
|
||||||
|
|
||||||
ac.for_each([&out](const auto &idx, const auto &event)
|
ac.for_each([&out](const auto &idx)
|
||||||
{
|
{
|
||||||
out << idx
|
const m::event::fetch event
|
||||||
<< " " << pretty_oneline(event)
|
{
|
||||||
<< std::endl;
|
idx, std::nothrow
|
||||||
|
};
|
||||||
|
|
||||||
return true;
|
out << idx;
|
||||||
|
if(event.valid)
|
||||||
|
out << " " << pretty_oneline(event);
|
||||||
|
|
||||||
|
out << std::endl;
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -96,11 +96,12 @@ get__event_auth(client &client,
|
||||||
m::index(event_id)
|
m::index(event_id)
|
||||||
};
|
};
|
||||||
|
|
||||||
chain.for_each([&auth_chain]
|
m::event::fetch event;
|
||||||
(const m::event::idx &event_idx, const m::event &event)
|
chain.for_each([&auth_chain, &event]
|
||||||
|
(const m::event::idx &event_idx)
|
||||||
{
|
{
|
||||||
|
if(seek(event, event_idx, std::nothrow))
|
||||||
auth_chain.append(event);
|
auth_chain.append(event);
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -598,13 +598,8 @@ ircd::m::event::auth::chain::for_each(const auth::chain &c,
|
||||||
while(!aq.empty());
|
while(!aq.empty());
|
||||||
|
|
||||||
for(const auto &idx : ae)
|
for(const auto &idx : ae)
|
||||||
{
|
if(!closure(idx))
|
||||||
if(!seek(e, idx, std::nothrow))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(!closure(idx, e))
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue