Compare commits

..

6 commits

Author SHA1 Message Date
Jade Ellis
9eb1d098bd
feat: Support logging to journald with tracing-journald
Some checks failed
Release Docker Image / define-variables (push) Failing after 1s
Release Docker Image / build-image (linux/amd64, linux-amd64) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, linux-arm64) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Rust Checks / Format (push) Failing after 1s
Rust Checks / Clippy (push) Failing after 19s
Rust Checks / Cargo Test (push) Failing after 8s
This stubs out on non-unix platforms.
2025-05-23 21:20:11 +01:00
Jade Ellis
843ffa0ab9
fix: Use correct brand in clap version string
Some checks failed
Release Docker Image / define-variables (push) Failing after 2s
Release Docker Image / build-image (linux/amd64, linux-amd64) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, linux-arm64) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Rust Checks / Format (push) Failing after 8s
Rust Checks / Clippy (push) Failing after 9s
Rust Checks / Cargo Test (push) Failing after 7s
2025-05-23 21:10:48 +01:00
Jade Ellis
015fb4e8e1
ci: Don't specify container for image builder 2025-05-23 19:40:52 +01:00
Jade Ellis
bd67c581c9
ci: Don't install rustup if it's already there 2025-05-23 19:40:44 +01:00
Jade Ellis
2ccbd7d60b
fix: Reference config directly 2025-05-21 21:06:44 +01:00
Jade Ellis
60960c6e09
feat: Automatically set well-known support contacts 2025-05-21 20:32:53 +01:00
7 changed files with 88 additions and 31 deletions

View file

@ -19,11 +19,20 @@ outputs:
rustc_version: rustc_version:
description: The rustc version installed description: The rustc version installed
value: ${{ steps.rustc-version.outputs.version }} value: ${{ steps.rustc-version.outputs.version }}
rustup_version:
description: The rustup version installed
value: ${{ steps.rustup-version.outputs.version }}
runs: runs:
using: composite using: composite
steps: steps:
- name: Check if rustup is already installed
shell: bash
id: rustup-version
run: |
echo "version=$(rustup --version)" >> $GITHUB_OUTPUT
- name: Cache rustup toolchains - name: Cache rustup toolchains
if: steps.rustup-version.outputs.version == ''
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: | path: |
@ -33,6 +42,7 @@ runs:
# Requires repo to be cloned if toolchain is not specified # Requires repo to be cloned if toolchain is not specified
key: ${{ runner.os }}-rustup-${{ inputs.toolchain || hashFiles('**/rust-toolchain.toml') }} key: ${{ runner.os }}-rustup-${{ inputs.toolchain || hashFiles('**/rust-toolchain.toml') }}
- name: Install Rust toolchain - name: Install Rust toolchain
if: steps.rustup-version.outputs.version == ''
shell: bash shell: bash
run: | run: |
if ! command -v rustup &> /dev/null ; then if ! command -v rustup &> /dev/null ; then

View file

@ -57,7 +57,6 @@ jobs:
build-image: build-image:
runs-on: dind runs-on: dind
container: ghcr.io/catthehacker/ubuntu:act-latest
needs: define-variables needs: define-variables
permissions: permissions:
contents: read contents: read
@ -211,7 +210,6 @@ jobs:
merge: merge:
runs-on: dind runs-on: dind
container: ghcr.io/catthehacker/ubuntu:act-latest
needs: [define-variables, build-image] needs: [define-variables, build-image]
steps: steps:
- name: Download digests - name: Download digests

View file

@ -1650,19 +1650,29 @@
# #
#server = #server =
# This item is undocumented. Please contribute documentation for it. # URL to a support page for the server, which will be served as part of
# the MSC1929 server support endpoint at /.well-known/matrix/support.
# Will be included alongside any contact information
# #
#support_page = #support_page =
# This item is undocumented. Please contribute documentation for it. # Role string for server support contacts, to be served as part of the
# MSC1929 server support endpoint at /.well-known/matrix/support.
# #
#support_role = #support_role = "m.role.admin"
# This item is undocumented. Please contribute documentation for it. # Email address for server support contacts, to be served as part of the
# MSC1929 server support endpoint.
# This will be used along with support_mxid if specified.
# #
#support_email = #support_email =
# This item is undocumented. Please contribute documentation for it. # Matrix ID for server support contacts, to be served as part of the
# MSC1929 server support endpoint.
# This will be used along with support_email if specified.
#
# If no email or mxid is specified, all of the server's admins will be
# listed.
# #
#support_mxid = #support_mxid =

View file

@ -1,5 +1,6 @@
use axum::{Json, extract::State, response::IntoResponse}; use axum::{Json, extract::State, response::IntoResponse};
use conduwuit::{Error, Result}; use conduwuit::{Error, Result};
use futures::StreamExt;
use ruma::api::client::{ use ruma::api::client::{
discovery::{ discovery::{
discover_homeserver::{self, HomeserverInfo, SlidingSyncProxyInfo}, discover_homeserver::{self, HomeserverInfo, SlidingSyncProxyInfo},
@ -17,7 +18,7 @@ pub(crate) async fn well_known_client(
State(services): State<crate::State>, State(services): State<crate::State>,
_body: Ruma<discover_homeserver::Request>, _body: Ruma<discover_homeserver::Request>,
) -> Result<discover_homeserver::Response> { ) -> Result<discover_homeserver::Response> {
let client_url = match services.server.config.well_known.client.as_ref() { let client_url = match services.config.well_known.client.as_ref() {
| Some(url) => url.to_string(), | Some(url) => url.to_string(),
| None => return Err(Error::BadRequest(ErrorKind::NotFound, "Not found.")), | None => return Err(Error::BadRequest(ErrorKind::NotFound, "Not found.")),
}; };
@ -33,44 +34,63 @@ pub(crate) async fn well_known_client(
/// # `GET /.well-known/matrix/support` /// # `GET /.well-known/matrix/support`
/// ///
/// Server support contact and support page of a homeserver's domain. /// 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( pub(crate) async fn well_known_support(
State(services): State<crate::State>, State(services): State<crate::State>,
_body: Ruma<discover_support::Request>, _body: Ruma<discover_support::Request>,
) -> Result<discover_support::Response> { ) -> Result<discover_support::Response> {
let support_page = services let support_page = services
.server
.config .config
.well_known .well_known
.support_page .support_page
.as_ref() .as_ref()
.map(ToString::to_string); .map(ToString::to_string);
let role = services.server.config.well_known.support_role.clone(); let email_address = services.config.well_known.support_email.clone();
let matrix_id = services.config.well_known.support_mxid.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 // TODO: support defining multiple contacts in the config
let mut contacts: Vec<Contact> = vec![]; let mut contacts: Vec<Contact> = vec![];
if let Some(role) = role { let role_value = services
let contact = Contact { role, email_address, matrix_id }; .config
.well_known
.support_role
.clone()
.unwrap_or_else(|| "m.role.admin".to_owned().into());
contacts.push(contact); // 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()),
});
}
}
} }
// support page or role+contacts must be either defined for this to be valid
if contacts.is_empty() && support_page.is_none() { 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.")); return Err(Error::BadRequest(ErrorKind::NotFound, "Not found."));
} }
@ -84,9 +104,9 @@ pub(crate) async fn well_known_support(
pub(crate) async fn syncv3_client_server_json( pub(crate) async fn syncv3_client_server_json(
State(services): State<crate::State>, State(services): State<crate::State>,
) -> Result<impl IntoResponse> { ) -> Result<impl IntoResponse> {
let server_url = match services.server.config.well_known.client.as_ref() { let server_url = match services.config.well_known.client.as_ref() {
| Some(url) => url.to_string(), | Some(url) => url.to_string(),
| None => match services.server.config.well_known.server.as_ref() { | None => match services.config.well_known.server.as_ref() {
| Some(url) => url.to_string(), | Some(url) => url.to_string(),
| None => return Err(Error::BadRequest(ErrorKind::NotFound, "Not found.")), | None => return Err(Error::BadRequest(ErrorKind::NotFound, "Not found.")),
}, },

View file

@ -1915,12 +1915,28 @@ pub struct WellKnownConfig {
/// example: "matrix.example.com:443" /// example: "matrix.example.com:443"
pub server: Option<OwnedServerName>, pub server: Option<OwnedServerName>,
/// URL to a support page for the server, which will be served as part of
/// the MSC1929 server support endpoint at /.well-known/matrix/support.
/// Will be included alongside any contact information
pub support_page: Option<Url>, pub support_page: Option<Url>,
/// Role string for server support contacts, to be served as part of the
/// MSC1929 server support endpoint at /.well-known/matrix/support.
///
/// default: "m.role.admin"
pub support_role: Option<ContactRole>, pub support_role: Option<ContactRole>,
/// Email address for server support contacts, to be served as part of the
/// MSC1929 server support endpoint.
/// This will be used along with support_mxid if specified.
pub support_email: Option<String>, pub support_email: Option<String>,
/// Matrix ID for server support contacts, to be served as part of the
/// MSC1929 server support endpoint.
/// This will be used along with support_email if specified.
///
/// If no email or mxid is specified, all of the server's admins will be
/// listed.
pub support_mxid: Option<OwnedUserId>, pub support_mxid: Option<OwnedUserId>,
} }

View file

@ -21,7 +21,10 @@ pub use ::toml;
pub use ::tracing; pub use ::tracing;
pub use config::Config; pub use config::Config;
pub use error::Error; pub use error::Error;
pub use info::{rustc_flags_capture, version, version::version}; pub use info::{
rustc_flags_capture, version,
version::{name, version},
};
pub use matrix::{Event, EventTypeExt, PduCount, PduEvent, PduId, RoomVersion, pdu, state_res}; pub use matrix::{Event, EventTypeExt, PduCount, PduEvent, PduId, RoomVersion, pdu, state_res};
pub use server::Server; pub use server::Server;
pub use utils::{ctor, dtor, implement, result, result::Result}; pub use utils::{ctor, dtor, implement, result, result::Result};

View file

@ -15,7 +15,7 @@ use conduwuit_core::{
#[clap( #[clap(
about, about,
long_about = None, long_about = None,
name = "conduwuit", name = conduwuit_core::name(),
version = conduwuit_core::version(), version = conduwuit_core::version(),
)] )]
pub(crate) struct Args { pub(crate) struct Args {