mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
fix: Return Forbidden instead of internal error when PS doesn't sign
This commit is contained in:
@@ -6,18 +6,18 @@
|
|||||||
use std::{collections::BTreeMap, time::Duration};
|
use std::{collections::BTreeMap, time::Duration};
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Error, Event, PduEvent, Result, debug, debug_error, debug_info, debug_warn, error,
|
debug, debug_error, debug_info, debug_warn, error, implement, info, state_res::EventTypeExt, trace, utils::to_canonical_object,
|
||||||
implement, info, state_res::EventTypeExt, trace, utils::to_canonical_object, warn,
|
warn, Err, Error, Event, PduEvent, Result,
|
||||||
};
|
};
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, CanonicalJsonValue, KeyId, RoomId, ServerName, SigningKeyAlgorithm,
|
api::error::ErrorKind, canonical_json::redact, events::{room::policy::RoomPolicyEventContent, StateEventType}, room_version_rules::{RedactionRules, RoomVersionRules}, serde::{base64::Standard, Base64}, signatures::{to_canonical_json_string_for_signing, verify_canonical_json_bytes},
|
||||||
api::error::ErrorKind,
|
CanonicalJsonObject,
|
||||||
canonical_json::redact,
|
CanonicalJsonValue,
|
||||||
events::{StateEventType, room::policy::RoomPolicyEventContent},
|
KeyId,
|
||||||
room_version_rules::{RedactionRules, RoomVersionRules},
|
RoomId,
|
||||||
serde::{Base64, base64::Standard},
|
ServerName,
|
||||||
signatures::{to_canonical_json_string_for_signing, verify_canonical_json_bytes},
|
SigningKeyAlgorithm,
|
||||||
};
|
};
|
||||||
use ruminuwuity::policy::policy_sign::unstable::Request as PolicySignRequest;
|
use ruminuwuity::policy::policy_sign::unstable::Request as PolicySignRequest;
|
||||||
use serde_json::value::RawValue;
|
use serde_json::value::RawValue;
|
||||||
@@ -360,7 +360,10 @@ pub async fn fetch_policy_server_signature(
|
|||||||
"Policy server did not sign event: {:?}",
|
"Policy server did not sign event: {:?}",
|
||||||
response.signatures
|
response.signatures
|
||||||
);
|
);
|
||||||
return Err!(BadServerResponse("Policy server did not sign the event"));
|
// NOTE: Legacy policy servers return a `200 {}` to indicate that the event was
|
||||||
|
// flagged as spam. We'll make a distinction in the error message in case
|
||||||
|
// it's unexpected.
|
||||||
|
return Err!(Request(Forbidden("Policy server did not sign the event")));
|
||||||
}
|
}
|
||||||
// Unwraps are safe here because we checked both in the above if statement
|
// Unwraps are safe here because we checked both in the above if statement
|
||||||
let signatures = response.signatures.unwrap();
|
let signatures = response.signatures.unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user