mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
feat: Support advertising a policy server public key in well-known
# Conflicts: # src/api/client/well_known.rs # src/core/config/mod.rs
This commit is contained in:
@@ -3,6 +3,7 @@ use conduwuit::{Err, Result};
|
||||
use ruma::{
|
||||
api::client::discovery::{
|
||||
discover_homeserver::{self, HomeserverInfo},
|
||||
discover_policy_server,
|
||||
discover_support::{self, Contact, ContactRole},
|
||||
},
|
||||
assign,
|
||||
@@ -114,3 +115,18 @@ pub(crate) async fn well_known_support(
|
||||
|
||||
Ok(assign!(discover_support::Response::with_contacts(contacts), { support_page }))
|
||||
}
|
||||
|
||||
/// # `GET /.well-known/matrix/policy_server`
|
||||
///
|
||||
/// Advertises the policy server's public key, allowing clients to discover the
|
||||
/// values to be set in m.room.policy. Introduced in spec v1.18.
|
||||
pub(crate) async fn well_known_policy_server(
|
||||
State(services): State<crate::State>,
|
||||
_body: Ruma<discover_policy_server::Request>,
|
||||
) -> Result<discover_policy_server::Response> {
|
||||
if let Some(key) = services.config.well_known.policy_server_public_key.clone() {
|
||||
Ok(discover_policy_server::Response::new(key))
|
||||
} else {
|
||||
Err!(Request(NotFound("No policy server available.")))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +183,7 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
|
||||
.ruma_route(&client::put_suspended_status)
|
||||
.ruma_route(&client::well_known_support)
|
||||
.ruma_route(&client::well_known_client)
|
||||
.ruma_route(&client::well_known_policy_server)
|
||||
.ruma_route(&client::get_rtc_transports)
|
||||
.ruma_route(&client::room_initial_sync_route)
|
||||
.route("/_conduwuit/server_version", get(client::conduwuit_server_version))
|
||||
|
||||
Reference in New Issue
Block a user