0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd:Ⓜ️ Add type(room) to interface.

This commit is contained in:
Jason Volk 2019-07-19 13:59:09 -07:00
parent bdc88e6c7e
commit e57561e8c1
2 changed files with 29 additions and 0 deletions

View file

@ -32,6 +32,7 @@ namespace ircd::m
bool federate(const id::room &);
id::user::buf creator(const id::room &);
bool creator(const id::room &, const id::user &);
string_view type(const mutable_buffer &, const room &);
string_view version(const mutable_buffer &, const room &, std::nothrow_t);
string_view version(const mutable_buffer &, const room &);

View file

@ -1031,6 +1031,34 @@ ircd::m::version(const mutable_buffer &buf,
return ret;
}
ircd::string_view
ircd::m::type(const mutable_buffer &buf,
const room &room)
{
string_view ret;
const auto event_idx
{
room.get(std::nothrow, "m.room.create", "")
};
if(event_idx)
m::get(std::nothrow, event_idx, "content", [&buf, &ret]
(const json::object &content)
{
const json::string &type
{
content.get("type")
};
ret = strlcpy
{
buf, type
};
});
return ret;
}
bool
ircd::m::creator(const id::room &room_id,
const id::user &user_id)