0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

ircd:Ⓜ️:user::mitsein: Simplify interface.

This commit is contained in:
Jason Volk 2019-08-17 01:59:17 -07:00
parent 5c219c67da
commit 34e87c08c3
4 changed files with 7 additions and 52 deletions

View file

@ -19,15 +19,11 @@ struct ircd::m::user::mitsein
public: public:
// All common rooms with user // All common rooms with user
bool for_each(const m::user &, const string_view &membership, const rooms::closure_bool &) const; 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; 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 // All common users in all rooms
bool for_each(const string_view &membership, const closure_bool &) const; 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; bool for_each(const closure_bool &) const;
void for_each(const closure &) const;
// Counting convenience // Counting convenience
size_t count(const m::user &, const string_view &membership = {}) const; size_t count(const m::user &, const string_view &membership = {}) const;

View file

@ -240,6 +240,8 @@ initialsync_presence(client &client,
}; };
} }
}); });
return true;
}); });
} }

View file

@ -160,6 +160,7 @@ ircd::m::sync::presence_polylog(data &data)
(const m::user &user) (const m::user &user)
{ {
concurrent(std::string(user.user_id)); concurrent(std::string(user.user_id));
return true;
}); });
const ctx::uninterruptible ui; const ctx::uninterruptible ui;

View file

@ -27,12 +27,12 @@ ircd::m::user::mitsein::has(const m::user &other,
const const
{ {
// Return true if broken out of loop. // 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 &) (const m::room &, const string_view &)
{ {
// Break out of loop at first shared room // Break out of loop at first shared room
return false; return false;
}}); });
} }
size_t size_t
@ -44,6 +44,7 @@ const
for_each(membership, [&ret](const m::user &) for_each(membership, [&ret](const m::user &)
{ {
++ret; ++ret;
return true;
}); });
return ret; return ret;
@ -59,19 +60,12 @@ const
for_each(user, membership, [&ret](const m::room &, const string_view &) for_each(user, membership, [&ret](const m::room &, const string_view &)
{ {
++ret; ++ret;
return true;
}); });
return ret; return ret;
} }
void
IRCD_MODULE_EXPORT
ircd::m::user::mitsein::for_each(const closure &closure)
const
{
for_each(string_view{}, closure);
}
bool bool
IRCD_MODULE_EXPORT IRCD_MODULE_EXPORT
ircd::m::user::mitsein::for_each(const closure_bool &closure) ircd::m::user::mitsein::for_each(const closure_bool &closure)
@ -80,20 +74,6 @@ const
return for_each(string_view{}, closure); 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 bool
IRCD_MODULE_EXPORT IRCD_MODULE_EXPORT
ircd::m::user::mitsein::for_each(const string_view &membership, 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 bool
IRCD_MODULE_EXPORT IRCD_MODULE_EXPORT
ircd::m::user::mitsein::for_each(const m::user &user, ircd::m::user::mitsein::for_each(const m::user &user,
@ -158,21 +129,6 @@ const
return for_each(user, string_view{}, closure); 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 bool
IRCD_MODULE_EXPORT IRCD_MODULE_EXPORT
ircd::m::user::mitsein::for_each(const m::user &user, ircd::m::user::mitsein::for_each(const m::user &user,