Skip to content

Commit 4bb422f

Browse files
committed
Use the new dedicated Synapse API
1 parent 28ef1b9 commit 4bb422f

File tree

7 files changed

+1309
-694
lines changed

7 files changed

+1309
-694
lines changed

crates/cli/src/util.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use mas_data_model::{SessionExpirationConfig, SiteConfig};
1717
use mas_email::{MailTransport, Mailer};
1818
use mas_handlers::passwords::PasswordManager;
1919
use mas_matrix::{HomeserverConnection, ReadOnlyHomeserverConnection};
20-
use mas_matrix_synapse::SynapseConnection;
20+
use mas_matrix_synapse::{LegacySynapseConnection, SynapseConnection};
2121
use mas_policy::PolicyFactory;
2222
use mas_router::UrlBuilder;
2323
use mas_storage::{BoxRepositoryFactory, RepositoryAccess, RepositoryFactory};
@@ -469,14 +469,22 @@ pub fn homeserver_connection_from_config(
469469
http_client: reqwest::Client,
470470
) -> Arc<dyn HomeserverConnection> {
471471
match config.kind {
472-
HomeserverKind::Synapse => Arc::new(SynapseConnection::new(
472+
HomeserverKind::Synapse | HomeserverKind::SynapseLegacy => {
473+
Arc::new(LegacySynapseConnection::new(
474+
config.homeserver.clone(),
475+
config.endpoint.clone(),
476+
config.secret.clone(),
477+
http_client,
478+
))
479+
}
480+
HomeserverKind::SynapseModern => Arc::new(SynapseConnection::new(
473481
config.homeserver.clone(),
474482
config.endpoint.clone(),
475483
config.secret.clone(),
476484
http_client,
477485
)),
478486
HomeserverKind::SynapseReadOnly => {
479-
let connection = SynapseConnection::new(
487+
let connection = LegacySynapseConnection::new(
480488
config.homeserver.clone(),
481489
config.endpoint.clone(),
482490
config.secret.clone(),

crates/config/src/sections/matrix.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,23 @@ fn default_endpoint() -> Url {
2727
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Default)]
2828
#[serde(rename_all = "snake_case")]
2929
pub enum HomeserverKind {
30-
/// Homeserver is Synapse
30+
/// Homeserver is Synapse, using the legacy API
31+
///
32+
/// This will switch to using the modern API in a few releases.
3133
#[default]
3234
Synapse,
3335

34-
/// Homeserver is Synapse, in read-only mode
36+
/// Homeserver is Synapse, using the legacy API, in read-only mode
3537
///
3638
/// This is meant for testing rolling out Matrix Authentication Service with
3739
/// no risk of writing data to the homeserver.
3840
SynapseReadOnly,
41+
42+
/// Homeserver is Synapse, using the legacy API,
43+
SynapseLegacy,
44+
45+
/// Homeserver is Synapse, with the modern API available
46+
SynapseModern,
3947
}
4048

4149
/// Configuration related to the Matrix homeserver

crates/matrix-synapse/src/error.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ use async_trait::async_trait;
99
use serde::Deserialize;
1010
use thiserror::Error;
1111

12+
/// Encountered when trying to register a user ID which has been taken.
13+
/// — <https://spec.matrix.org/v1.10/client-server-api/#other-error-codes>
14+
pub(crate) const M_USER_IN_USE: &str = "M_USER_IN_USE";
15+
/// Encountered when trying to register a user ID which is not valid.
16+
/// — <https://spec.matrix.org/v1.10/client-server-api/#other-error-codes>
17+
pub(crate) const M_INVALID_USERNAME: &str = "M_INVALID_USERNAME";
18+
/// Encountered when trying to register a user ID reserved by an appservice.
19+
/// — <https://spec.matrix.org/v1.10/client-server-api/#other-error-codes>
20+
pub(crate) const M_EXCLUSIVE: &str = "M_EXCLUSIVE";
21+
1222
/// Represents a Matrix error
1323
/// Ref: <https://spec.matrix.org/v1.10/client-server-api/#standard-error-response>
1424
#[derive(Debug, Deserialize)]

0 commit comments

Comments
 (0)