mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 23:14:13 +01:00
modules/federation/query: Respond to directory for room_alias.
This commit is contained in:
parent
2b4a727671
commit
3278324db0
1 changed files with 52 additions and 0 deletions
|
@ -40,6 +40,10 @@ static resource::response
|
|||
get__query_profile(client &client,
|
||||
const resource::request &request);
|
||||
|
||||
static resource::response
|
||||
get__query_directory(client &client,
|
||||
const resource::request &request);
|
||||
|
||||
resource::response
|
||||
get__query(client &client,
|
||||
const resource::request &request)
|
||||
|
@ -52,6 +56,9 @@ get__query(client &client,
|
|||
if(type == "profile")
|
||||
return get__query_profile(client, request);
|
||||
|
||||
if(type == "directory")
|
||||
return get__query_directory(client, request);
|
||||
|
||||
throw m::NOT_FOUND
|
||||
{
|
||||
"Query type not found."
|
||||
|
@ -101,3 +108,48 @@ get__query_profile(client &client,
|
|||
|
||||
return {}; // responded from closure
|
||||
}
|
||||
|
||||
resource::response
|
||||
get__query_directory(client &client,
|
||||
const resource::request &request)
|
||||
{
|
||||
m::room::alias::buf room_alias
|
||||
{
|
||||
url::decode(request.query.at("room_alias"), room_alias)
|
||||
};
|
||||
|
||||
const ircd::m::room::id::buf
|
||||
alias_room_id
|
||||
{
|
||||
"alias", ircd::my_host()
|
||||
};
|
||||
|
||||
const m::room alias_room
|
||||
{
|
||||
alias_room_id
|
||||
};
|
||||
|
||||
const m::room::state state
|
||||
{
|
||||
alias_room
|
||||
};
|
||||
|
||||
state.get("ircd.alias", room_alias, [&client, &room_alias]
|
||||
(const m::event &event)
|
||||
{
|
||||
const m::room::id &room_id
|
||||
{
|
||||
unquote(at<"content"_>(event).at("room_id"))
|
||||
};
|
||||
|
||||
resource::response
|
||||
{
|
||||
client, json::members
|
||||
{
|
||||
{ "room_id", room_id }
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue