mirror of
https://github.com/matrix-construct/construct
synced 2024-05-28 15:53:46 +02:00
ircd:Ⓜ️:room::auth::chain: Simplify interface.
This commit is contained in:
parent
8baa2265e4
commit
52657ca410
|
@ -61,17 +61,12 @@ struct ircd::m::room::auth::refs
|
|||
|
||||
struct ircd::m::room::auth::chain
|
||||
{
|
||||
using closure_bool = event::closure_idx_bool;
|
||||
using closure = event::closure_idx;
|
||||
using closure = event::closure_idx_bool;
|
||||
|
||||
event::idx idx;
|
||||
|
||||
static bool for_each(const auth::chain &, const closure_bool &);
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -10001,6 +10001,7 @@ console_cmd__room__auth(opt &out, const string_view &line)
|
|||
out << " " << pretty_oneline(event);
|
||||
|
||||
out << std::endl;
|
||||
return true;
|
||||
});
|
||||
|
||||
return true;
|
||||
|
@ -12830,6 +12831,8 @@ console_cmd__fed__query_auth(opt &out, const string_view &line)
|
|||
{
|
||||
if(seek(event, event_idx, std::nothrow))
|
||||
auth_chain.append(event);
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -124,6 +124,8 @@ get__event_auth(client &client,
|
|||
{
|
||||
if(seek(event, event_idx, std::nothrow))
|
||||
auth_chain.append(event);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return std::move(response);
|
||||
|
|
|
@ -223,6 +223,7 @@ put__send_join(client &client,
|
|||
(const m::event::id &event_id)
|
||||
{
|
||||
state_ids.append(event_id);
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
|
||||
|
|
|
@ -122,6 +122,8 @@ get__state(client &client,
|
|||
{
|
||||
if(seek(event, event_idx, std::nothrow))
|
||||
auth_chain.append(event);
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,8 @@ get__state_ids(client &client,
|
|||
{
|
||||
auth_chain_ids.append(event_id);
|
||||
});
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -117,6 +119,7 @@ get__state_ids(client &client,
|
|||
(const m::event::id &event_id)
|
||||
{
|
||||
pdu_ids.append(event_id);
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
|
||||
|
|
|
@ -681,6 +681,7 @@ const noexcept
|
|||
for_each([&ret](const auto &)
|
||||
{
|
||||
++ret;
|
||||
return true;
|
||||
});
|
||||
|
||||
return ret;
|
||||
|
@ -692,7 +693,7 @@ ircd::m::room::auth::chain::has(const string_view &type)
|
|||
const noexcept
|
||||
{
|
||||
bool ret(false);
|
||||
for_each(closure_bool{[&type, &ret]
|
||||
for_each([&type, &ret]
|
||||
(const auto &idx)
|
||||
{
|
||||
m::get(std::nothrow, idx, "type", [&type, &ret]
|
||||
|
@ -702,7 +703,7 @@ const noexcept
|
|||
});
|
||||
|
||||
return !ret;
|
||||
}});
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -711,31 +712,10 @@ bool
|
|||
IRCD_MODULE_EXPORT
|
||||
ircd::m::room::auth::chain::for_each(const closure &closure)
|
||||
const
|
||||
{
|
||||
return for_each(closure_bool{[&closure]
|
||||
(const auto &idx)
|
||||
{
|
||||
closure(idx);
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
|
||||
bool
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::room::auth::chain::for_each(const closure_bool &closure)
|
||||
const
|
||||
{
|
||||
return chain::for_each(*this, closure);
|
||||
}
|
||||
|
||||
bool
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::room::auth::chain::for_each(const auth::chain &c,
|
||||
const closure_bool &closure)
|
||||
{
|
||||
m::event::fetch e, a;
|
||||
std::set<event::idx> ae;
|
||||
std::deque<event::idx> aq {c.idx}; do
|
||||
std::deque<event::idx> aq {idx}; do
|
||||
{
|
||||
const auto idx(aq.front());
|
||||
aq.pop_front();
|
||||
|
@ -743,8 +723,7 @@ ircd::m::room::auth::chain::for_each(const auth::chain &c,
|
|||
continue;
|
||||
|
||||
const m::event::prev prev{e};
|
||||
const auto count(prev.auth_events_count());
|
||||
for(size_t i(0); i < count && i < 4; ++i)
|
||||
for(size_t i(0); i < prev.auth_events_count() && i < 4; ++i)
|
||||
{
|
||||
const auto &auth_event_id(prev.auth_event(i));
|
||||
const auto &auth_event_idx(index(auth_event_id, std::nothrow));
|
||||
|
|
Loading…
Reference in a new issue