mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 15:04:10 +01:00
ircd:Ⓜ️:fed: Upgrade to v2 send_join.
This commit is contained in:
parent
679ed39ccc
commit
08ea4b0e72
4 changed files with 49 additions and 19 deletions
|
@ -21,9 +21,9 @@ struct ircd::m::fed::send_join
|
||||||
{
|
{
|
||||||
struct opts;
|
struct opts;
|
||||||
|
|
||||||
explicit operator json::array() const
|
explicit operator json::object() const
|
||||||
{
|
{
|
||||||
return json::array
|
return json::object
|
||||||
{
|
{
|
||||||
in.content
|
in.content
|
||||||
};
|
};
|
||||||
|
@ -42,4 +42,5 @@ struct ircd::m::fed::send_join::opts
|
||||||
:request::opts
|
:request::opts
|
||||||
{
|
{
|
||||||
bool knock {false};
|
bool knock {false};
|
||||||
|
bool omit_members {false};
|
||||||
};
|
};
|
||||||
|
|
|
@ -835,10 +835,11 @@ ircd::m::fed::send_join::send_join(const room::id &room_id,
|
||||||
thread_local char ridbuf[768], uidbuf[768];
|
thread_local char ridbuf[768], uidbuf[768];
|
||||||
json::get<"uri"_>(opts.request) = fmt::sprintf
|
json::get<"uri"_>(opts.request) = fmt::sprintf
|
||||||
{
|
{
|
||||||
buf, "/_matrix/federation/v1/send_%s/%s/%s",
|
buf, "/_matrix/federation/v2/send_%s/%s/%s?omit_members=%s",
|
||||||
opts.knock? "knock"_sv: "join"_sv,
|
opts.knock? "knock"_sv: "join"_sv,
|
||||||
url::encode(ridbuf, room_id),
|
url::encode(ridbuf, room_id),
|
||||||
url::encode(uidbuf, event_id)
|
url::encode(uidbuf, event_id),
|
||||||
|
opts.omit_members? "true": "false",
|
||||||
};
|
};
|
||||||
|
|
||||||
consume(buf, size(json::get<"uri"_>(opts.request)));
|
consume(buf, size(json::get<"uri"_>(opts.request)));
|
||||||
|
|
|
@ -589,25 +589,15 @@ try
|
||||||
send_join.get(seconds(send_join_timeout))
|
send_join.get(seconds(send_join_timeout))
|
||||||
};
|
};
|
||||||
|
|
||||||
const json::array send_join_response
|
const json::object send_join_response
|
||||||
{
|
{
|
||||||
send_join
|
send_join
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint more_send_join_code
|
|
||||||
{
|
|
||||||
send_join_response.at<uint>(0)
|
|
||||||
};
|
|
||||||
|
|
||||||
const json::object &send_join_response_data
|
|
||||||
{
|
|
||||||
send_join_response[1]
|
|
||||||
};
|
|
||||||
|
|
||||||
assert(!!send_join.in.dynamic);
|
assert(!!send_join.in.dynamic);
|
||||||
return
|
return
|
||||||
{
|
{
|
||||||
send_join_response_data,
|
send_join_response,
|
||||||
std::move(send_join.in.dynamic)
|
std::move(send_join.in.dynamic)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -15592,6 +15592,7 @@ console_cmd__fed__join(opt &out, const string_view &line)
|
||||||
m::fed::send_join::opts opts;
|
m::fed::send_join::opts opts;
|
||||||
opts.remote = remote;
|
opts.remote = remote;
|
||||||
opts.knock = has(op, "knock");
|
opts.knock = has(op, "knock");
|
||||||
|
opts.omit_members = has(op, "lazy");
|
||||||
const unique_buffer<mutable_buffer> buf
|
const unique_buffer<mutable_buffer> buf
|
||||||
{
|
{
|
||||||
16_KiB
|
16_KiB
|
||||||
|
@ -15605,7 +15606,7 @@ console_cmd__fed__join(opt &out, const string_view &line)
|
||||||
request.get(out.timeout);
|
request.get(out.timeout);
|
||||||
const json::object response
|
const json::object response
|
||||||
{
|
{
|
||||||
json::array(request.in.content)[1]
|
request
|
||||||
};
|
};
|
||||||
|
|
||||||
const json::array auth_chain
|
const json::array auth_chain
|
||||||
|
@ -15613,11 +15614,31 @@ console_cmd__fed__join(opt &out, const string_view &line)
|
||||||
response["auth_chain"]
|
response["auth_chain"]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const json::object signed_event
|
||||||
|
{
|
||||||
|
response["event"]
|
||||||
|
};
|
||||||
|
|
||||||
|
const bool members_omitted
|
||||||
|
{
|
||||||
|
response.get("members_omitted", false)
|
||||||
|
};
|
||||||
|
|
||||||
|
const json::string origin
|
||||||
|
{
|
||||||
|
response["origin"]
|
||||||
|
};
|
||||||
|
|
||||||
const json::array state
|
const json::array state
|
||||||
{
|
{
|
||||||
response["state"]
|
response["state"]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const json::array servers_in_room
|
||||||
|
{
|
||||||
|
response["servers_in_room"]
|
||||||
|
};
|
||||||
|
|
||||||
if(has(op, "eval"))
|
if(has(op, "eval"))
|
||||||
{
|
{
|
||||||
m::vm::opts vmopts;
|
m::vm::opts vmopts;
|
||||||
|
@ -15643,12 +15664,29 @@ console_cmd__fed__join(opt &out, const string_view &line)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(has(op, "raw"))
|
||||||
|
{
|
||||||
for(const json::object event : auth_chain)
|
for(const json::object event : auth_chain)
|
||||||
out << event << std::endl;
|
out << event << std::endl;
|
||||||
|
|
||||||
for(const json::object event : state)
|
for(const json::object event : state)
|
||||||
out << event << std::endl;
|
out << event << std::endl;
|
||||||
|
|
||||||
|
for(const json::string server : servers_in_room)
|
||||||
|
out << server << std::endl;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(const json::object event : auth_chain)
|
||||||
|
out << pretty_oneline(m::event{event}) << std::endl;
|
||||||
|
|
||||||
|
for(const json::object event : state)
|
||||||
|
out << pretty_oneline(m::event{event}) << std::endl;
|
||||||
|
|
||||||
|
for(const json::string server : servers_in_room)
|
||||||
|
out << server << std::endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue