forked from mirror/grapevine
Compare commits
1 commit
custom
...
charles/we
Author | SHA1 | Date | |
---|---|---|---|
|
832d9a6e90 |
2 changed files with 8 additions and 27 deletions
|
@ -30,24 +30,10 @@ pub(crate) async fn server(
|
||||||
|
|
||||||
/// Handler for `/.well-known/matrix/client`
|
/// Handler for `/.well-known/matrix/client`
|
||||||
pub(crate) async fn client(_: Ar<client::Request>) -> Ra<client::Response> {
|
pub(crate) async fn client(_: Ar<client::Request>) -> Ra<client::Response> {
|
||||||
let authority = services()
|
|
||||||
.globals
|
|
||||||
.config
|
|
||||||
.server_discovery
|
|
||||||
.client
|
|
||||||
.authority
|
|
||||||
.clone()
|
|
||||||
.unwrap_or_else(|| services().globals.config.server_name.clone());
|
|
||||||
|
|
||||||
let scheme = if services().globals.config.server_discovery.client.insecure {
|
|
||||||
"http"
|
|
||||||
} else {
|
|
||||||
"https"
|
|
||||||
};
|
|
||||||
|
|
||||||
let base_url = format!("{scheme}://{authority}");
|
|
||||||
|
|
||||||
// I wish ruma used an actual URL type instead of `String`
|
// I wish ruma used an actual URL type instead of `String`
|
||||||
|
let base_url =
|
||||||
|
services().globals.config.server_discovery.client.base_url.to_string();
|
||||||
|
|
||||||
Ra(client::Response {
|
Ra(client::Response {
|
||||||
homeserver: client::HomeserverInfo::new(base_url.clone()),
|
homeserver: client::HomeserverInfo::new(base_url.clone()),
|
||||||
identity_server: None,
|
identity_server: None,
|
||||||
|
|
|
@ -6,6 +6,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
use reqwest::Url;
|
||||||
use ruma::{OwnedServerName, RoomVersionId};
|
use ruma::{OwnedServerName, RoomVersionId};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
@ -35,7 +36,6 @@ pub(crate) struct Config {
|
||||||
/// This is the value that will appear e.g. in user IDs and room aliases.
|
/// This is the value that will appear e.g. in user IDs and room aliases.
|
||||||
pub(crate) server_name: OwnedServerName,
|
pub(crate) server_name: OwnedServerName,
|
||||||
|
|
||||||
#[serde(default)]
|
|
||||||
pub(crate) server_discovery: ServerDiscovery,
|
pub(crate) server_discovery: ServerDiscovery,
|
||||||
pub(crate) database: DatabaseConfig,
|
pub(crate) database: DatabaseConfig,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
@ -69,14 +69,13 @@ pub(crate) struct Config {
|
||||||
pub(crate) emergency_password: Option<String>,
|
pub(crate) emergency_password: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub(crate) struct ServerDiscovery {
|
pub(crate) struct ServerDiscovery {
|
||||||
/// Server-server discovery configuration
|
/// Server-server discovery configuration
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub(crate) server: ServerServerDiscovery,
|
pub(crate) server: ServerServerDiscovery,
|
||||||
|
|
||||||
/// Client-server discovery configuration
|
/// Client-server discovery configuration
|
||||||
#[serde(default)]
|
|
||||||
pub(crate) client: ClientServerDiscovery,
|
pub(crate) client: ClientServerDiscovery,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,14 +87,10 @@ pub(crate) struct ServerServerDiscovery {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Client-server discovery configuration
|
/// Client-server discovery configuration
|
||||||
#[derive(Debug, Default, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub(crate) struct ClientServerDiscovery {
|
pub(crate) struct ClientServerDiscovery {
|
||||||
/// The alternative authority to make client-server API requests to
|
/// The base URL to make client-server API requests to
|
||||||
pub(crate) authority: Option<OwnedServerName>,
|
pub(crate) base_url: Url,
|
||||||
|
|
||||||
/// Controls whether HTTPS is used
|
|
||||||
#[serde(default)]
|
|
||||||
pub(crate) insecure: bool,
|
|
||||||
|
|
||||||
#[serde(default, rename = "advertise_buggy_sliding_sync")]
|
#[serde(default, rename = "advertise_buggy_sliding_sync")]
|
||||||
pub(crate) advertise_sliding_sync: bool,
|
pub(crate) advertise_sliding_sync: bool,
|
||||||
|
|
Loading…
Reference in a new issue