From c04378e9a77eefa30ca0701de42b523297810eff Mon Sep 17 00:00:00 2001 From: Jade Ellis Date: Tue, 6 May 2025 20:51:12 +0100 Subject: [PATCH] chore: Fix typos across the codebase --- .typos.toml | 4 -- docs/deploying/docker-compose.for-traefik.yml | 38 +++++------ .../deploying/docker-compose.with-traefik.yml | 48 +++++++------- src/api/client/well_known.rs | 64 +++++++------------ 4 files changed, 65 insertions(+), 89 deletions(-) diff --git a/.typos.toml b/.typos.toml index 41c81085..1e46469c 100644 --- a/.typos.toml +++ b/.typos.toml @@ -1,9 +1,5 @@ -[files] -extend-exclude = ["*.csr"] - [default.extend-words] "allocatedp" = "allocatedp" "conduwuit" = "conduwuit" "continuwuity" = "continuwuity" -"continuwity" = "continuwuity" "execuse" = "execuse" diff --git a/docs/deploying/docker-compose.for-traefik.yml b/docs/deploying/docker-compose.for-traefik.yml index 547712b6..83fb64ff 100644 --- a/docs/deploying/docker-compose.for-traefik.yml +++ b/docs/deploying/docker-compose.for-traefik.yml @@ -7,30 +7,30 @@ services: image: forgejo.ellis.link/continuwuation/continuwuity:latest restart: unless-stopped volumes: - - db:/var/lib/continuwuity - - /etc/resolv.conf:/etc/resolv.conf:ro # Use the host's DNS resolver rather than Docker's. - #- ./continuwuity.toml:/etc/continuwuity.toml + - db:/var/lib/conduwuit + - /etc/resolv.conf:/etc/resolv.conf:ro # Use the host's DNS resolver rather than Docker's. + #- ./conduwuit.toml:/etc/conduwuit.toml networks: - proxy environment: - CONTINUWUITY_SERVER_NAME: your.server.name.example # EDIT THIS - CONTINUWUITY_DATABASE_PATH: /var/lib/continuwuity - CONTINUWUITY_PORT: 6167 # should match the loadbalancer traefik label - CONTINUWUITY_MAX_REQUEST_SIZE: 20000000 # in bytes, ~20 MB - CONTINUWUITY_ALLOW_REGISTRATION: 'true' - CONTINUWUITY_REGISTRATION_TOKEN: 'YOUR_TOKEN' # A registration token is required when registration is allowed. - #CONTINUWUITY_YES_I_AM_VERY_VERY_SURE_I_WANT_AN_OPEN_REGISTRATION_SERVER_PRONE_TO_ABUSE: 'true' - CONTINUWUITY_ALLOW_FEDERATION: 'true' - CONTINUWUITY_ALLOW_CHECK_FOR_UPDATES: 'true' - CONTINUWUITY_TRUSTED_SERVERS: '["matrix.org"]' - #CONTINUWUITY_LOG: warn,state_res=warn - CONTINUWUITY_ADDRESS: 0.0.0.0 - #CONTINUWUITY_CONFIG: '/etc/continuwuity.toml' # Uncomment if you mapped config toml above + CONDUWUIT_SERVER_NAME: your.server.name.example # EDIT THIS + CONDUWUIT_DATABASE_PATH: /var/lib/conduwuit + CONDUWUIT_PORT: 6167 # should match the loadbalancer traefik label + CONDUWUIT_MAX_REQUEST_SIZE: 20000000 # in bytes, ~20 MB + CONDUWUIT_ALLOW_REGISTRATION: 'true' + CONDUWUIT_REGISTRATION_TOKEN: 'YOUR_TOKEN' # A registration token is required when registration is allowed. + #CONDUWUIT_YES_I_AM_VERY_VERY_SURE_I_WANT_AN_OPEN_REGISTRATION_SERVER_PRONE_TO_ABUSE: 'true' + CONDUWUIT_ALLOW_FEDERATION: 'true' + CONDUWUIT_ALLOW_CHECK_FOR_UPDATES: 'true' + CONDUWUIT_TRUSTED_SERVERS: '["matrix.org"]' + #CONDUWUIT_LOG: warn,state_res=warn + CONDUWUIT_ADDRESS: 0.0.0.0 + #CONDUWUIT_CONFIG: '/etc/conduwuit.toml' # Uncomment if you mapped config toml above - # We need some way to serve the client and server .well-known json. The simplest way is via the CONTINUWUITY_WELL_KNOWN - # variable / config option, there are multiple ways to do this, e.g. in the continuwuity.toml file, and in a separate + # We need some way to serve the client and server .well-known json. The simplest way is via the CONDUWUIT_WELL_KNOWN + # variable / config option, there are multiple ways to do this, e.g. in the conduwuit.toml file, and in a separate # see the override file for more information about delegation - CONTINUWUITY_WELL_KNOWN: | + CONDUWUIT_WELL_KNOWN: | { client=https://your.server.name.example, server=your.server.name.example:443 diff --git a/docs/deploying/docker-compose.with-traefik.yml b/docs/deploying/docker-compose.with-traefik.yml index 9acc4221..a45893da 100644 --- a/docs/deploying/docker-compose.with-traefik.yml +++ b/docs/deploying/docker-compose.with-traefik.yml @@ -7,38 +7,38 @@ services: image: forgejo.ellis.link/continuwuation/continuwuity:latest restart: unless-stopped volumes: - - db:/var/lib/continuwuity + - db:/var/lib/conduwuit - /etc/resolv.conf:/etc/resolv.conf:ro # Use the host's DNS resolver rather than Docker's. - #- ./continuwuity.toml:/etc/continuwuity.toml + #- ./conduwuit.toml:/etc/conduwuit.toml networks: - proxy environment: - CONTINUWUITY_SERVER_NAME: your.server.name.example # EDIT THIS - CONTINUWUITY_TRUSTED_SERVERS: '["matrix.org"]' - CONTINUWUITY_ALLOW_REGISTRATION: 'false' # After setting a secure registration token, you can enable this - CONTINUWUITY_REGISTRATION_TOKEN: "" # This is a token you can use to register on the server - #CONTINUWUITY_REGISTRATION_TOKEN_FILE: "" # Alternatively you can configure a path to a token file to read - CONTINUWUITY_ADDRESS: 0.0.0.0 - CONTINUWUITY_PORT: 6167 # you need to match this with the traefik load balancer label if you're want to change it - CONTINUWUITY_DATABASE_PATH: /var/lib/continuwuity - #CONTINUWUITY_CONFIG: '/etc/continuwuity.toml' # Uncomment if you mapped config toml above + CONDUWUIT_SERVER_NAME: your.server.name.example # EDIT THIS + CONDUWUIT_TRUSTED_SERVERS: '["matrix.org"]' + CONDUWUIT_ALLOW_REGISTRATION: 'false' # After setting a secure registration token, you can enable this + CONDUWUIT_REGISTRATION_TOKEN: "" # This is a token you can use to register on the server + #CONDUWUIT_REGISTRATION_TOKEN_FILE: "" # Alternatively you can configure a path to a token file to read + CONDUWUIT_ADDRESS: 0.0.0.0 + CONDUWUIT_PORT: 6167 # you need to match this with the traefik load balancer label if you're want to change it + CONDUWUIT_DATABASE_PATH: /var/lib/conduwuit + #CONDUWUIT_CONFIG: '/etc/conduit.toml' # Uncomment if you mapped config toml above ### Uncomment and change values as desired, note that Continuwuity has plenty of config options, so you should check out the example example config too # Available levels are: error, warn, info, debug, trace - more info at: https://docs.rs/env_logger/*/env_logger/#enabling-logging - # CONTINUWUITY_LOG: info # default is: "warn,state_res=warn" - # CONTINUWUITY_ALLOW_ENCRYPTION: 'true' - # CONTINUWUITY_ALLOW_FEDERATION: 'true' - # CONTINUWUITY_ALLOW_CHECK_FOR_UPDATES: 'true' - # CONTINUWUITY_ALLOW_INCOMING_PRESENCE: true - # CONTINUWUITY_ALLOW_OUTGOING_PRESENCE: true - # CONTINUWUITY_ALLOW_LOCAL_PRESENCE: true - # CONTINUWUITY_WORKERS: 10 - # CONTINUWUITY_MAX_REQUEST_SIZE: 20000000 # in bytes, ~20 MB - # CONTINUWUITY_NEW_USER_DISPLAYNAME_SUFFIX = "🏳<200d>⚧" + # CONDUWUIT_LOG: info # default is: "warn,state_res=warn" + # CONDUWUIT_ALLOW_ENCRYPTION: 'true' + # CONDUWUIT_ALLOW_FEDERATION: 'true' + # CONDUWUIT_ALLOW_CHECK_FOR_UPDATES: 'true' + # CONDUWUIT_ALLOW_INCOMING_PRESENCE: true + # CONDUWUIT_ALLOW_OUTGOING_PRESENCE: true + # CONDUWUIT_ALLOW_LOCAL_PRESENCE: true + # CONDUWUIT_WORKERS: 10 + # CONDUWUIT_MAX_REQUEST_SIZE: 20000000 # in bytes, ~20 MB + # CONDUWUIT_NEW_USER_DISPLAYNAME_SUFFIX = "🏳<200d>⚧" - # We need some way to serve the client and server .well-known json. The simplest way is via the CONTINUWUITY_WELL_KNOWN - # variable / config option, there are multiple ways to do this, e.g. in the continuwuity.toml file, and in a separate + # We need some way to serve the client and server .well-known json. The simplest way is via the CONDUWUIT_WELL_KNOWN + # variable / config option, there are multiple ways to do this, e.g. in the conduwuit.toml file, and in a separate # reverse proxy, but since you do not have a reverse proxy and following this guide, this example is included - CONTINUWUITY_WELL_KNOWN: | + CONDUWUIT_WELL_KNOWN: | { client=https://your.server.name.example, server=your.server.name.example:443 diff --git a/src/api/client/well_known.rs b/src/api/client/well_known.rs index fe2281ba..35b7fc1e 100644 --- a/src/api/client/well_known.rs +++ b/src/api/client/well_known.rs @@ -1,6 +1,5 @@ use axum::{Json, extract::State, response::IntoResponse}; use conduwuit::{Error, Result}; -use futures::StreamExt; use ruma::api::client::{ discovery::{ discover_homeserver::{self, HomeserverInfo, SlidingSyncProxyInfo}, @@ -18,7 +17,7 @@ pub(crate) async fn well_known_client( State(services): State, _body: Ruma, ) -> Result { - let client_url = match services.config.well_known.client.as_ref() { + let client_url = match services.server.config.well_known.client.as_ref() { | Some(url) => url.to_string(), | None => return Err(Error::BadRequest(ErrorKind::NotFound, "Not found.")), }; @@ -34,63 +33,44 @@ pub(crate) async fn well_known_client( /// # `GET /.well-known/matrix/support` /// /// Server support contact and support page of a homeserver's domain. -/// Implements MSC1929 for server discovery. -/// If no configuration is set, uses admin users as contacts. pub(crate) async fn well_known_support( State(services): State, _body: Ruma, ) -> Result { let support_page = services + .server .config .well_known .support_page .as_ref() .map(ToString::to_string); - let email_address = services.config.well_known.support_email.clone(); - let matrix_id = services.config.well_known.support_mxid.clone(); + let role = services.server.config.well_known.support_role.clone(); + + // support page or role must be either defined for this to be valid + if support_page.is_none() && role.is_none() { + return Err(Error::BadRequest(ErrorKind::NotFound, "Not found.")); + } + + let email_address = services.server.config.well_known.support_email.clone(); + let matrix_id = services.server.config.well_known.support_mxid.clone(); + + // if a role is specified, an email address or matrix id is required + if role.is_some() && (email_address.is_none() && matrix_id.is_none()) { + return Err(Error::BadRequest(ErrorKind::NotFound, "Not found.")); + } // TODO: support defining multiple contacts in the config let mut contacts: Vec = vec![]; - let role_value = services - .config - .well_known - .support_role - .clone() - .unwrap_or_else(|| "m.role.admin".to_owned().into()); + if let Some(role) = role { + let contact = Contact { role, email_address, matrix_id }; - // Add configured contact if at least one contact method is specified - if email_address.is_some() || matrix_id.is_some() { - contacts.push(Contact { - role: role_value.clone(), - email_address: email_address.clone(), - matrix_id: matrix_id.clone(), - }); - } - - // Try to add admin users as contacts if no contacts are configured - if contacts.is_empty() { - if let Ok(admin_room) = services.admin.get_admin_room().await { - let admin_users = services.rooms.state_cache.room_members(&admin_room); - let mut stream = admin_users; - - while let Some(user_id) = stream.next().await { - // Skip server user - if *user_id == services.globals.server_user { - break; - } - contacts.push(Contact { - role: role_value.clone(), - email_address: None, - matrix_id: Some(user_id.to_owned()), - }); - } - } + contacts.push(contact); } + // support page or role+contacts must be either defined for this to be valid if contacts.is_empty() && support_page.is_none() { - // No admin room, no configured contacts, and no support page return Err(Error::BadRequest(ErrorKind::NotFound, "Not found.")); } @@ -104,9 +84,9 @@ pub(crate) async fn well_known_support( pub(crate) async fn syncv3_client_server_json( State(services): State, ) -> Result { - let server_url = match services.config.well_known.client.as_ref() { + let server_url = match services.server.config.well_known.client.as_ref() { | Some(url) => url.to_string(), - | None => match services.config.well_known.server.as_ref() { + | None => match services.server.config.well_known.server.as_ref() { | Some(url) => url.to_string(), | None => return Err(Error::BadRequest(ErrorKind::NotFound, "Not found.")), },