mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-16 23:31:24 +01:00
fix room version comparisons
Fixes a set of bugs introduced by00b77144c1, where we replaced explicit `RoomVersionId` matches with `version < V11` comparisons. The `Ord` impl on `RoomVersionId` does not work like that, and is in fact a lexicographic string comparison[1]. The most visible effect of these bugs is that incoming redaction events would sometimes be ignored. Instead of reverting to the explicit matches, which were quite verbose, I implemented a `RoomVersion` struct that has flags for each property that we care about. This is similar to the approach used by ruma[2] and synapse[3]. [1]:7cfa3be0c6/crates/ruma-common/src/identifiers/room_version_id.rs (L136)[2]:7cfa3be0c6/crates/ruma-state-res/src/room_version.rs[3]:c856ae4724/synapse/api/room_versions.py
This commit is contained in:
parent
ad37eae869
commit
9add9a1e96
8 changed files with 237 additions and 199 deletions
|
|
@ -80,6 +80,8 @@ pub(crate) enum Error {
|
|||
AdminCommand(&'static str),
|
||||
#[error("from {0}: {1}")]
|
||||
Redaction(OwnedServerName, ruma::canonical_json::RedactionError),
|
||||
#[error("unsupported room version {0}")]
|
||||
UnsupportedRoomVersion(ruma::RoomVersionId),
|
||||
#[error("{0} in {1}")]
|
||||
InconsistentRoomState(&'static str, ruma::OwnedRoomId),
|
||||
}
|
||||
|
|
@ -146,6 +148,10 @@ impl Error {
|
|||
_ => StatusCode::BAD_REQUEST,
|
||||
},
|
||||
),
|
||||
Self::UnsupportedRoomVersion(_) => (
|
||||
ErrorKind::UnsupportedRoomVersion,
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
),
|
||||
Self::Conflict(_) => (Unknown, StatusCode::CONFLICT),
|
||||
_ => (Unknown, StatusCode::INTERNAL_SERVER_ERROR),
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue