mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
fix: Treat malformed policy config events as missing
This commit is contained in:
@@ -90,29 +90,27 @@ pub async fn policy_server_allows_event(
|
|||||||
room_version_rules: &RoomVersionRules,
|
room_version_rules: &RoomVersionRules,
|
||||||
incoming: bool,
|
incoming: bool,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let ps = match pdu.event_type().with_state_key("").0 {
|
if pdu.event_type().with_state_key("") == (StateEventType::RoomPolicy, "".into()) {
|
||||||
| StateEventType::RoomPolicy => return Ok(()),
|
return Ok(());
|
||||||
| _ =>
|
}
|
||||||
self.services
|
let ps = match self
|
||||||
.state_accessor
|
.services
|
||||||
.room_state_get_content::<RoomPolicyEventContent>(
|
.state_accessor
|
||||||
room_id,
|
.room_state_get_content::<RoomPolicyEventContent>(
|
||||||
&StateEventType::RoomPolicy,
|
room_id,
|
||||||
"",
|
&StateEventType::RoomPolicy,
|
||||||
)
|
"",
|
||||||
.await,
|
)
|
||||||
};
|
.await
|
||||||
let ps: RoomPolicyEventContent = match ps {
|
{
|
||||||
| Ok(ps) => ps,
|
| Ok(s) => s,
|
||||||
| Err(e) => {
|
| Err(e) =>
|
||||||
if e.is_not_found() {
|
return if e.is_not_found() || e.kind() == ErrorKind::BadJson {
|
||||||
trace!("no policy server configured");
|
debug!(%e, "no policy server configured");
|
||||||
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
error!("failed to load policy server event: {e}");
|
Err!("failed to load m.room.policy state event: {e}")
|
||||||
// TODO: Should this fail closed?
|
},
|
||||||
}
|
|
||||||
return Ok(());
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some(ps_key) = ps.public_keys.get(&SigningKeyAlgorithm::Ed25519) else {
|
let Some(ps_key) = ps.public_keys.get(&SigningKeyAlgorithm::Ed25519) else {
|
||||||
|
|||||||
Reference in New Issue
Block a user