diff --git a/include/ircd/m/fed/send_join.h b/include/ircd/m/fed/send_join.h index db32cd458..d51f3c882 100644 --- a/include/ircd/m/fed/send_join.h +++ b/include/ircd/m/fed/send_join.h @@ -21,9 +21,9 @@ struct ircd::m::fed::send_join { struct opts; - explicit operator json::array() const + explicit operator json::object() const { - return json::array + return json::object { in.content }; @@ -42,4 +42,5 @@ struct ircd::m::fed::send_join::opts :request::opts { bool knock {false}; + bool omit_members {false}; }; diff --git a/matrix/fed.cc b/matrix/fed.cc index 2959f1f97..d90039fbd 100644 --- a/matrix/fed.cc +++ b/matrix/fed.cc @@ -835,10 +835,11 @@ ircd::m::fed::send_join::send_join(const room::id &room_id, thread_local char ridbuf[768], uidbuf[768]; 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, 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))); diff --git a/matrix/room_bootstrap.cc b/matrix/room_bootstrap.cc index 5d49ae984..71f1c3f9a 100644 --- a/matrix/room_bootstrap.cc +++ b/matrix/room_bootstrap.cc @@ -589,25 +589,15 @@ try send_join.get(seconds(send_join_timeout)) }; - const json::array send_join_response + const json::object send_join_response { send_join }; - const uint more_send_join_code - { - send_join_response.at(0) - }; - - const json::object &send_join_response_data - { - send_join_response[1] - }; - assert(!!send_join.in.dynamic); return { - send_join_response_data, + send_join_response, std::move(send_join.in.dynamic) }; } diff --git a/modules/console.cc b/modules/console.cc index b81908831..c0b21664e 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -15592,6 +15592,7 @@ console_cmd__fed__join(opt &out, const string_view &line) m::fed::send_join::opts opts; opts.remote = remote; opts.knock = has(op, "knock"); + opts.omit_members = has(op, "lazy"); const unique_buffer buf { 16_KiB @@ -15605,7 +15606,7 @@ console_cmd__fed__join(opt &out, const string_view &line) request.get(out.timeout); const json::object response { - json::array(request.in.content)[1] + request }; const json::array auth_chain @@ -15613,11 +15614,31 @@ console_cmd__fed__join(opt &out, const string_view &line) 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 { response["state"] }; + const json::array servers_in_room + { + response["servers_in_room"] + }; + if(has(op, "eval")) { m::vm::opts vmopts; @@ -15643,11 +15664,28 @@ console_cmd__fed__join(opt &out, const string_view &line) return true; } + if(has(op, "raw")) + { + for(const json::object event : auth_chain) + out << event << std::endl; + + for(const json::object event : state) + 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 << event << std::endl; + out << pretty_oneline(m::event{event}) << std::endl; for(const json::object event : state) - out << event << std::endl; + out << pretty_oneline(m::event{event}) << std::endl; + + for(const json::string server : servers_in_room) + out << server << std::endl; return true; }