mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd:Ⓜ️:user::mitsein: Simplify interface.
This commit is contained in:
parent
5c219c67da
commit
34e87c08c3
4 changed files with 7 additions and 52 deletions
|
@ -19,15 +19,11 @@ struct ircd::m::user::mitsein
|
|||
public:
|
||||
// All common rooms with user
|
||||
bool for_each(const m::user &, const string_view &membership, const rooms::closure_bool &) const;
|
||||
void for_each(const m::user &, const string_view &membership, const rooms::closure &) const;
|
||||
bool for_each(const m::user &, const rooms::closure_bool &) const;
|
||||
void for_each(const m::user &, const rooms::closure &) const;
|
||||
|
||||
// All common users in all rooms
|
||||
bool for_each(const string_view &membership, const closure_bool &) const;
|
||||
void for_each(const string_view &membership, const closure &) const;
|
||||
bool for_each(const closure_bool &) const;
|
||||
void for_each(const closure &) const;
|
||||
|
||||
// Counting convenience
|
||||
size_t count(const m::user &, const string_view &membership = {}) const;
|
||||
|
|
|
@ -240,6 +240,8 @@ initialsync_presence(client &client,
|
|||
};
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -160,6 +160,7 @@ ircd::m::sync::presence_polylog(data &data)
|
|||
(const m::user &user)
|
||||
{
|
||||
concurrent(std::string(user.user_id));
|
||||
return true;
|
||||
});
|
||||
|
||||
const ctx::uninterruptible ui;
|
||||
|
|
|
@ -27,12 +27,12 @@ ircd::m::user::mitsein::has(const m::user &other,
|
|||
const
|
||||
{
|
||||
// Return true if broken out of loop.
|
||||
return !for_each(other, membership, rooms::closure_bool{[]
|
||||
return !for_each(other, membership, []
|
||||
(const m::room &, const string_view &)
|
||||
{
|
||||
// Break out of loop at first shared room
|
||||
return false;
|
||||
}});
|
||||
});
|
||||
}
|
||||
|
||||
size_t
|
||||
|
@ -44,6 +44,7 @@ const
|
|||
for_each(membership, [&ret](const m::user &)
|
||||
{
|
||||
++ret;
|
||||
return true;
|
||||
});
|
||||
|
||||
return ret;
|
||||
|
@ -59,19 +60,12 @@ const
|
|||
for_each(user, membership, [&ret](const m::room &, const string_view &)
|
||||
{
|
||||
++ret;
|
||||
return true;
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::user::mitsein::for_each(const closure &closure)
|
||||
const
|
||||
{
|
||||
for_each(string_view{}, closure);
|
||||
}
|
||||
|
||||
bool
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::user::mitsein::for_each(const closure_bool &closure)
|
||||
|
@ -80,20 +74,6 @@ const
|
|||
return for_each(string_view{}, closure);
|
||||
}
|
||||
|
||||
void
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::user::mitsein::for_each(const string_view &membership,
|
||||
const closure &closure)
|
||||
const
|
||||
{
|
||||
for_each(membership, closure_bool{[&closure]
|
||||
(const m::user &user)
|
||||
{
|
||||
closure(user);
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
|
||||
bool
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::user::mitsein::for_each(const string_view &membership,
|
||||
|
@ -140,15 +120,6 @@ const
|
|||
}});
|
||||
}
|
||||
|
||||
void
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::user::mitsein::for_each(const m::user &user,
|
||||
const rooms::closure &closure)
|
||||
const
|
||||
{
|
||||
for_each(user, string_view{}, closure);
|
||||
}
|
||||
|
||||
bool
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::user::mitsein::for_each(const m::user &user,
|
||||
|
@ -158,21 +129,6 @@ const
|
|||
return for_each(user, string_view{}, closure);
|
||||
}
|
||||
|
||||
void
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::user::mitsein::for_each(const m::user &user,
|
||||
const string_view &membership,
|
||||
const rooms::closure &closure)
|
||||
const
|
||||
{
|
||||
for_each(user, membership, rooms::closure_bool{[&membership, &closure]
|
||||
(const m::room &room, const string_view &)
|
||||
{
|
||||
closure(room, membership);
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
|
||||
bool
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::user::mitsein::for_each(const m::user &user,
|
||||
|
|
Loading…
Reference in a new issue