stop sending make_join if 15 servers responded with unsupported/invalid room version

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-31 14:25:50 -04:00 committed by June
parent ce414023a4
commit af6c72fa84
2 changed files with 47 additions and 4 deletions

View file

@ -101,7 +101,7 @@ impl Error {
if let Self::FederationError(origin, error) = self {
let mut error = error.clone();
error.body = ErrorBody::Standard {
kind: Unknown,
kind: error.error_kind().unwrap_or(&Unknown).clone(),
message: format!("Answer from {origin}: {error}"),
};
return RumaResponse(UiaaResponse::MatrixError(error));
@ -138,7 +138,7 @@ impl Error {
_ => (Unknown, StatusCode::INTERNAL_SERVER_ERROR),
};
info!("Returning an error: {}: {}", status_code, message);
info!("Returning an error: {status_code}: {message}");
RumaResponse(UiaaResponse::MatrixError(RumaError {
body: ErrorBody::Standard {
@ -149,6 +149,18 @@ impl Error {
}))
}
/// Returns the Matrix error code / error kind
pub fn error_code(&self) -> ErrorKind {
if let Self::FederationError(_, error) = self {
return error.error_kind().unwrap_or(&Unknown).clone();
}
match self {
Self::BadRequest(kind, _) => kind.clone(),
_ => Unknown,
}
}
/// Sanitizes public-facing errors that can leak sensitive information.
pub fn sanitized_error(&self) -> String {
let db_error = String::from("Database or I/O error occurred.");