Skip to content

Use the new dedicated Synapse API #4801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions crates/cli/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use mas_data_model::{SessionExpirationConfig, SiteConfig};
use mas_email::{MailTransport, Mailer};
use mas_handlers::passwords::PasswordManager;
use mas_matrix::{HomeserverConnection, ReadOnlyHomeserverConnection};
use mas_matrix_synapse::SynapseConnection;
use mas_matrix_synapse::{LegacySynapseConnection, SynapseConnection};
use mas_policy::PolicyFactory;
use mas_router::UrlBuilder;
use mas_storage::{BoxRepositoryFactory, RepositoryAccess, RepositoryFactory};
Expand Down Expand Up @@ -469,14 +469,22 @@ pub fn homeserver_connection_from_config(
http_client: reqwest::Client,
) -> Arc<dyn HomeserverConnection> {
match config.kind {
HomeserverKind::Synapse => Arc::new(SynapseConnection::new(
HomeserverKind::Synapse | HomeserverKind::SynapseLegacy => {
Arc::new(LegacySynapseConnection::new(
config.homeserver.clone(),
config.endpoint.clone(),
config.secret.clone(),
http_client,
))
}
HomeserverKind::SynapseModern => Arc::new(SynapseConnection::new(
config.homeserver.clone(),
config.endpoint.clone(),
config.secret.clone(),
http_client,
)),
HomeserverKind::SynapseReadOnly => {
let connection = SynapseConnection::new(
let connection = LegacySynapseConnection::new(
config.homeserver.clone(),
config.endpoint.clone(),
config.secret.clone(),
Expand Down
12 changes: 10 additions & 2 deletions crates/config/src/sections/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,23 @@ fn default_endpoint() -> Url {
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "snake_case")]
pub enum HomeserverKind {
/// Homeserver is Synapse
/// Homeserver is Synapse, using the legacy API
///
/// This will switch to using the modern API in a few releases.
#[default]
Synapse,

/// Homeserver is Synapse, in read-only mode
/// Homeserver is Synapse, using the legacy API, in read-only mode
///
/// This is meant for testing rolling out Matrix Authentication Service with
/// no risk of writing data to the homeserver.
SynapseReadOnly,

/// Homeserver is Synapse, using the legacy API,
SynapseLegacy,

/// Homeserver is Synapse, with the modern API available
SynapseModern,
}

/// Configuration related to the Matrix homeserver
Expand Down
10 changes: 10 additions & 0 deletions crates/matrix-synapse/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ use async_trait::async_trait;
use serde::Deserialize;
use thiserror::Error;

/// Encountered when trying to register a user ID which has been taken.
/// — <https://spec.matrix.org/v1.10/client-server-api/#other-error-codes>
pub(crate) const M_USER_IN_USE: &str = "M_USER_IN_USE";
/// Encountered when trying to register a user ID which is not valid.
/// — <https://spec.matrix.org/v1.10/client-server-api/#other-error-codes>
pub(crate) const M_INVALID_USERNAME: &str = "M_INVALID_USERNAME";
/// Encountered when trying to register a user ID reserved by an appservice.
/// — <https://spec.matrix.org/v1.10/client-server-api/#other-error-codes>
pub(crate) const M_EXCLUSIVE: &str = "M_EXCLUSIVE";

/// Represents a Matrix error
/// Ref: <https://spec.matrix.org/v1.10/client-server-api/#standard-error-response>
#[derive(Debug, Deserialize)]
Expand Down
Loading
Loading