Skip to main content Module policy_server Copy item path Source use std::collections::BTreeMap ; π use std::time::Duration ; π use std::time::SystemTime ; π use std::time::UNIX_EPOCH ; π use http::StatusCode; π use ruma::CanonicalJsonObject; π use ruma::CanonicalJsonValue; π use ruma::EventId; π use ruma::OwnedServerName; π use ruma::RoomId; π use ruma::RoomVersionId; π use ruma::ServerName; π use ruma::SigningKeyAlgorithm; π use ruma::api::error::ErrorKind; π use ruma::api::error::RetryAfter; π use ruma::api::federation::policy::sign_event::v1 as sign_event; π use ruma::events::StateEventType; π use ruma::events::room::policy::POLICY_SERVER_ED25519_SIGNING_KEY_ID; π use ruma::events::room::policy::RoomPolicyEventContent; π use ruma::serde::Base64; π use ruma::signatures::to_canonical_json_string_for_signing; π use ruma::signatures::verify_canonical_json_bytes; π use serde::Deserialize ; π use serde::Deserialize ; π use serde::Serialize ; π use serde::Serialize ; π use serde_json::value::to_raw_value ; π use tuwunel_core::Err ; π use tuwunel_core::Result ; π use tuwunel_core::at ; π use tuwunel_core::debug ; π use tuwunel_core::debug ; π use tuwunel_core::implement; π use tuwunel_core::trace ; π use tuwunel_core::utils::BoolExt as _; π use tuwunel_core::utils::time::now_secs ; π use tuwunel_core::warn ; π use tuwunel_database::Cbor ; π use tuwunel_database::Deserialized ; π use tuwunel_matrix::Event ; π use tuwunel_matrix::pdu::into_outgoing_federation ; π use tuwunel_matrix::room_version::rules as room_version_rules; π UnstablePolicyContent π Lenient deserialiser that accepts either the stable
public_keys: { ed25519: ... } shape or the MSC4284 unstable singular
public_key: <ed25519> shape, and folds the latter into the former. FetchOutcome π Outcome of a /sign round-trip to the policy server. PolicyCheck Outcome of an inbound policy-server signature check. PolicySigState π Persisted per-event policy-server outcome in eventid_policysigstate.
Absence of a row means βno prior decision recorded; proceed with /signβ. POLICY_REFUSAL_TTL π UNSTABLE_POLICY_TYPE π MSC4284 unstable state event type. The merged spec stabilised this to
m.room.policy, but the reference policy server (and Elementβs default
deployments as of 2026-05) still write the unstable type with the singular
public_key field; reading both keeps the gate live for those rooms. check_policy_signature π classify_fetch_error π current_policy_state π extract_policy_signature π insert_policy_signature π is_policy_state_event π parse_rate_limit π