mirror of
https://github.com/matrix-construct/construct
synced 2024-09-27 11:18:51 +02:00
ircd:Ⓜ️:room::origins: Minor reorg for_each.
This commit is contained in:
parent
f95d66a914
commit
425385265a
2 changed files with 12 additions and 13 deletions
|
@ -11,21 +11,20 @@
|
|||
#pragma once
|
||||
#define HAVE_IRCD_M_ROOM_ORIGINS_H
|
||||
|
||||
/// Interface to the origins (autonomous systems) of a room
|
||||
///
|
||||
/// This interface focuses specifically on the origins (from the field in the
|
||||
/// event object) which are servers/networks/autonomous systems, or something.
|
||||
/// Messages have to be sent to them, and an efficient iteration of the
|
||||
/// origins as provided by this interface helps with that.
|
||||
/// Interface to the servers of a room. Messages have to be sent to them,
|
||||
/// and an efficient iteration of the origins as provided by this interface
|
||||
/// helps with that. This includes servers with joined members by default.
|
||||
///
|
||||
struct ircd::m::room::origins
|
||||
{
|
||||
using closure = std::function<void (const string_view &)>;
|
||||
using closure_bool = std::function<bool (const string_view &)>;
|
||||
|
||||
static bool _for_each(const origins &, const closure_bool &view);
|
||||
|
||||
m::room room;
|
||||
|
||||
bool _for_each_(const closure_bool &view) const;
|
||||
public:
|
||||
bool for_each(const closure_bool &view) const;
|
||||
void for_each(const closure &view) const;
|
||||
bool has(const string_view &origin) const;
|
||||
|
|
|
@ -1761,7 +1761,7 @@ const
|
|||
{
|
||||
size_t ret{0};
|
||||
const room::origins origins{room};
|
||||
origins._for_each_([&ret](const string_view &)
|
||||
origins._for_each(origins, [&ret](const string_view &)
|
||||
{
|
||||
++ret;
|
||||
return true;
|
||||
|
@ -1916,7 +1916,7 @@ const
|
|||
if(!room.event_id && membership == "join")
|
||||
{
|
||||
const room::origins origins{room};
|
||||
return origins._for_each_([&closure, this]
|
||||
return origins._for_each(origins, [&closure, this]
|
||||
(const string_view &key)
|
||||
{
|
||||
const string_view &member
|
||||
|
@ -2078,7 +2078,7 @@ const
|
|||
{
|
||||
string_view last;
|
||||
char lastbuf[rfc1035::NAME_BUF_SIZE];
|
||||
return _for_each_([&last, &lastbuf, &view]
|
||||
return _for_each(*this, [&last, &lastbuf, &view]
|
||||
(const string_view &key)
|
||||
{
|
||||
const string_view &origin
|
||||
|
@ -2098,8 +2098,8 @@ const
|
|||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::origins::_for_each_(const closure_bool &view)
|
||||
const
|
||||
ircd::m::room::origins::_for_each(const origins &origins,
|
||||
const closure_bool &view)
|
||||
{
|
||||
db::index &index
|
||||
{
|
||||
|
@ -2108,7 +2108,7 @@ const
|
|||
|
||||
auto it
|
||||
{
|
||||
index.begin(room.room_id)
|
||||
index.begin(origins.room.room_id)
|
||||
};
|
||||
|
||||
for(; bool(it); ++it)
|
||||
|
|
Loading…
Reference in a new issue