ircd:Ⓜ️:room: Add boolean query for room type.

This commit is contained in:
Jason Volk 2023-04-21 21:14:15 -07:00
parent f08b9e85cd
commit 1a032b28b7
2 changed files with 27 additions and 0 deletions

View File

@ -31,6 +31,7 @@ namespace ircd::m
bool exists(const id::room_alias &, const bool &remote = false);
bool internal(const id::room &);
bool federated(const id::room &);
bool type(const id::room &, const string_view &);
bool creator(const id::room &, const id::user &);
bool contains(const id::room &, const event::idx &);
bool membership(const room &, const id::user &, const string_view & = "join");

View File

@ -892,6 +892,32 @@ ircd::m::join_rule(const room &room,
return join_rule(buf, room) == rule;
}
bool
ircd::m::type(const room::id &room_id,
const string_view &type_)
{
const m::room room
{
room_id
};
const auto event_idx
{
room.get(std::nothrow, "m.room.create", "")
};
return m::query(std::nothrow, event_idx, "content", false, [&type_]
(const json::object &content)
{
const json::string &type
{
content.get("type")
};
return type == type_;
});
}
bool
ircd::m::creator(const room::id &room_id,
const user::id &user_id)