0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-01-13 08:23:56 +01:00

ircd:Ⓜ️ Improve room_version event_id related conditions.

This commit is contained in:
Jason Volk 2019-08-15 22:37:37 -07:00
parent cd347d53cb
commit 65e79a584a
2 changed files with 19 additions and 12 deletions

View file

@ -3449,9 +3449,10 @@ ircd::m::check_id(const event &event,
const string_view &room_version)
noexcept try
{
assert(event.event_id);
const auto &version
{
room_version?: json::get<"event_id"_>(event)? "1"_sv: "4"_sv
room_version?: event.event_id.version()
};
thread_local char buf[64];
@ -3463,9 +3464,6 @@ noexcept try
version == "3"?
event::id{event::id::v3{buf, event}}:
version == "4" || version == "5"?
event::id{event::id::v4{buf, event}}:
event::id{event::id::v4{buf, event}}
};

View file

@ -127,7 +127,19 @@ ircd::m::auth_room_create(const event &event,
event.event_id.version()
};
if(claim_version == "3")
if(claim_version == "1" || claim_version == "2")
{
// When the claimed version is 1 or 2 we don't actually
// care if the event_id is version 1, 3 or 4 etc; the server
// has eliminated use of the event_id hostpart in all rooms.
//if(id_version != "1")
// throw FAIL
// {
// "m.room.create room_version not 1"
// };
}
else if(claim_version == "3")
{
if(id_version != "3")
throw FAIL
@ -143,20 +155,17 @@ ircd::m::auth_room_create(const event &event,
"m.room.create room_version not 4"
};
}
else if(claim_version == "1" || claim_version == "2")
{
//if(id_version != "1")
// return "m.room.create room_version not 1";
}
else if(claim_version != "1" && claim_version != "2")
else
{
// Note that id_version reports "4" even for version "5"
// and beyond room versions. When a room version requires
// a new ID version these branches must be updated.
if(id_version != "4")
throw FAIL
{
"m.room.create room_version not 4"
};
}
else assert(0);
}
// d. If content has no creator field, reject.