0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 08:12:37 +01: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 struct ircd::m::fed::make_join
:request :request
{ {
struct opts;
explicit operator json::object() const explicit operator json::object() const
{ {
return json::object return json::object
@ -34,3 +36,9 @@ struct ircd::m::fed::make_join
make_join() = default; 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 struct ircd::m::fed::send_join
:request :request
{ {
struct opts;
explicit operator json::array() const explicit operator json::array() const
{ {
return json::array return json::array
@ -35,3 +37,9 @@ struct ircd::m::fed::send_join
send_join() = default; 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]; 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_join/%s/%s", buf, "/_matrix/federation/v1/send_%s/%s/%s",
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)
}; };
@ -883,7 +884,7 @@ ircd::m::fed::make_join::make_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/make_join/%s/%s" buf, "/_matrix/federation/v1/make_%s/%s/%s"
"?ver=1" "?ver=1"
"&ver=2" "&ver=2"
"&ver=3" "&ver=3"
@ -901,6 +902,7 @@ ircd::m::fed::make_join::make_join(const room::id &room_id,
"&ver=15" "&ver=15"
"&ver=16" "&ver=16"
"&ver=org.matrix.msc2432" "&ver=org.matrix.msc2432"
,opts.knock? "knock"_sv: "join"_sv
,url::encode(ridbuf, room_id) ,url::encode(ridbuf, room_id)
,url::encode(uidbuf, user_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, " ", const params param{line, " ",
{ {
"room_id", "remote", "user_id", "op" "room_id", "remote", "user_id", "op", "knock"
}}; }};
const auto &room_id const auto &room_id
@ -15005,8 +15005,16 @@ console_cmd__fed__head(opt &out, const string_view &line)
16_KiB 16_KiB
}; };
m::fed::make_join::opts opts; m::fed::make_join::opts opts
opts.remote = remote; {
m::fed::request::opts
{
.remote = remote
},
.knock = param["knock"] == "knock",
};
m::fed::make_join request m::fed::make_join request
{ {
room_id, user_id, buf, std::move(opts) room_id, user_id, buf, std::move(opts)