0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-28 15:53:46 +02:00

ircd:Ⓜ️:homeserver: Additional my_ tools.

This commit is contained in:
Jason Volk 2019-10-04 13:39:55 -07:00
parent 1add5349ac
commit 1f88439bc1
2 changed files with 23 additions and 0 deletions

View file

@ -29,6 +29,9 @@ namespace ircd::m
bool for_each(const std::function<bool (homeserver &)> &);
bool my_origin(const string_view &origin);
bool myself(const m::user::id &);
homeserver &my(const string_view &origin);
homeserver &my(); // primary

View file

@ -85,6 +85,26 @@ ircd::m::my(const string_view &name)
return *ptr;
}
bool
ircd::m::myself(const m::user::id &user_id)
{
return !for_each([&user_id]
(const auto &homeserver)
{
return homeserver.self != user_id;
});
}
bool
ircd::m::my_origin(const string_view &origin)
{
return !for_each([&origin]
(const auto &homeserver)
{
return m::origin(homeserver) != origin;
});
}
bool
ircd::m::for_each(const std::function<bool (homeserver &)> &closure)
{