0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-29 00:03:45 +02:00

ircd:Ⓜ️:fed: Implement request-side for knock suite.

This commit is contained in:
Jason Volk 2022-06-19 18:13:15 -07:00
parent da022616d9
commit 9ffbd8be37
4 changed files with 31 additions and 5 deletions

View file

@ -19,6 +19,8 @@ namespace ircd::m::fed
struct ircd::m::fed::make_join
:request
{
struct opts;
explicit operator json::object() const
{
return json::object
@ -34,3 +36,9 @@ struct ircd::m::fed::make_join
make_join() = default;
};
struct ircd::m::fed::make_join::opts
:request::opts
{
bool knock {false};
};

View file

@ -19,6 +19,8 @@ namespace ircd::m::fed
struct ircd::m::fed::send_join
:request
{
struct opts;
explicit operator json::array() const
{
return json::array
@ -35,3 +37,9 @@ struct ircd::m::fed::send_join
send_join() = default;
};
struct ircd::m::fed::send_join::opts
:request::opts
{
bool knock {false};
};

View file

@ -835,7 +835,8 @@ 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_join/%s/%s",
buf, "/_matrix/federation/v1/send_%s/%s/%s",
opts.knock? "knock"_sv: "join"_sv,
url::encode(ridbuf, room_id),
url::encode(uidbuf, event_id)
};
@ -883,7 +884,7 @@ ircd::m::fed::make_join::make_join(const room::id &room_id,
thread_local char ridbuf[768], uidbuf[768];
json::get<"uri"_>(opts.request) = fmt::sprintf
{
buf, "/_matrix/federation/v1/make_join/%s/%s"
buf, "/_matrix/federation/v1/make_%s/%s/%s"
"?ver=1"
"&ver=2"
"&ver=3"
@ -901,6 +902,7 @@ ircd::m::fed::make_join::make_join(const room::id &room_id,
"&ver=15"
"&ver=16"
"&ver=org.matrix.msc2432"
,opts.knock? "knock"_sv: "join"_sv
,url::encode(ridbuf, room_id)
,url::encode(uidbuf, user_id)
};

View file

@ -14973,7 +14973,7 @@ console_cmd__fed__head(opt &out, const string_view &line)
{
const params param{line, " ",
{
"room_id", "remote", "user_id", "op"
"room_id", "remote", "user_id", "op", "knock"
}};
const auto &room_id
@ -15005,8 +15005,16 @@ console_cmd__fed__head(opt &out, const string_view &line)
16_KiB
};
m::fed::make_join::opts opts;
opts.remote = remote;
m::fed::make_join::opts opts
{
m::fed::request::opts
{
.remote = remote
},
.knock = param["knock"] == "knock",
};
m::fed::make_join request
{
room_id, user_id, buf, std::move(opts)