0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-07-02 16:58:19 +02:00

modules/federation/make_join: Room version match against query string params.

This commit is contained in:
Jason Volk 2019-07-15 17:30:18 -07:00
parent 477fc25687
commit 4e5b9696f5

View file

@ -91,6 +91,30 @@ get__make_join(client &client,
"You are not permitted to view the room at this event."
};
char room_version_buf[32];
const string_view &room_version
{
m::version(room_version_buf, room, std::nothrow)
};
const bool version_mismatch
{
request.query.for_each("ver", [&room_version]
(const auto &val)
{
return val.second != room_version;
})
};
if(version_mismatch)
throw m::error
{
http::NOT_IMPLEMENTED, "M_INCOMPATIBLE_ROOM_VERSION",
"Your homeserver does not support the room version %s.",
room_version?
room_version : "?????",
};
const unique_buffer<mutable_buffer> buf
{
8_KiB
@ -99,12 +123,11 @@ get__make_join(client &client,
json::stack out{buf};
json::stack::object top{out};
char room_version_buf[32];
json::stack::member
{
top, "room_version", json::value
{
m::version(room_version_buf, room, std::nothrow), json::STRING
room_version, json::STRING
}
};