ircd:Ⓜ️:room: Add boolean query for room type.
This commit is contained in:
parent
f08b9e85cd
commit
1a032b28b7
|
@ -31,6 +31,7 @@ namespace ircd::m
|
||||||
bool exists(const id::room_alias &, const bool &remote = false);
|
bool exists(const id::room_alias &, const bool &remote = false);
|
||||||
bool internal(const id::room &);
|
bool internal(const id::room &);
|
||||||
bool federated(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 creator(const id::room &, const id::user &);
|
||||||
bool contains(const id::room &, const event::idx &);
|
bool contains(const id::room &, const event::idx &);
|
||||||
bool membership(const room &, const id::user &, const string_view & = "join");
|
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;
|
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
|
bool
|
||||||
ircd::m::creator(const room::id &room_id,
|
ircd::m::creator(const room::id &room_id,
|
||||||
const user::id &user_id)
|
const user::id &user_id)
|
||||||
|
|
Loading…
Reference in New Issue