mirror of
https://github.com/matrix-construct/construct
synced 2024-11-24 15:52:34 +01:00
ircd:Ⓜ️:room: Add boolean query for room type.
This commit is contained in:
parent
f08b9e85cd
commit
1a032b28b7
2 changed files with 27 additions and 0 deletions
|
@ -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");
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue