0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 08:42:34 +01:00

ircd:Ⓜ️ Add util to get membership from either event.membership or event.content.

This commit is contained in:
Jason Volk 2018-03-03 06:03:15 -08:00
parent e95b61d46b
commit 8a5462063e
2 changed files with 9 additions and 0 deletions

View file

@ -19,6 +19,7 @@ namespace ircd::m
bool my(const event &);
size_t degree(const event &);
string_view membership(const event &);
bool check_size(std::nothrow_t, const event &);
void check_size(const event &);

View file

@ -74,6 +74,14 @@ ircd::m::check_size(std::nothrow_t,
return event_size <= size_t(event_max_size);
}
ircd::string_view
ircd::m::membership(const m::event &event)
{
return json::get<"membership"_>(event)?
string_view{json::get<"membership"_>(event)}:
unquote(json::get<"content"_>(event).get("membership"));
}
size_t
ircd::m::degree(const event &event)
{