diff --git a/include/ircd/m/room/room.h b/include/ircd/m/room/room.h index 411fc0b72..424ee39f8 100644 --- a/include/ircd/m/room/room.h +++ b/include/ircd/m/room/room.h @@ -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"); diff --git a/matrix/room.cc b/matrix/room.cc index 28264c8df..cebc495d4 100644 --- a/matrix/room.cc +++ b/matrix/room.cc @@ -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)