eliminate references to services.globals.config
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
7c6b8b132a
commit
5be07ebc0f
26 changed files with 116 additions and 114 deletions
|
@ -299,7 +299,7 @@ pub(crate) async fn register_route(
|
|||
if !services.globals.new_user_displayname_suffix().is_empty()
|
||||
&& body.appservice_info.is_none()
|
||||
{
|
||||
write!(displayname, " {}", services.globals.config.new_user_displayname_suffix)
|
||||
write!(displayname, " {}", services.server.config.new_user_displayname_suffix)
|
||||
.expect("should be able to write to string buffer");
|
||||
}
|
||||
|
||||
|
@ -365,7 +365,7 @@ pub(crate) async fn register_route(
|
|||
\"{device_display_name}\""
|
||||
);
|
||||
|
||||
if services.globals.config.admin_room_notices {
|
||||
if services.server.config.admin_room_notices {
|
||||
services
|
||||
.admin
|
||||
.send_message(RoomMessageEventContent::notice_plain(format!(
|
||||
|
@ -378,7 +378,7 @@ pub(crate) async fn register_route(
|
|||
} else {
|
||||
info!("New user \"{user_id}\" registered on this server.");
|
||||
|
||||
if services.globals.config.admin_room_notices {
|
||||
if services.server.config.admin_room_notices {
|
||||
services
|
||||
.admin
|
||||
.send_message(RoomMessageEventContent::notice_plain(format!(
|
||||
|
@ -395,7 +395,7 @@ pub(crate) async fn register_route(
|
|||
info!("New guest user \"{user_id}\" registered on this server.");
|
||||
|
||||
if !device_display_name.is_empty() {
|
||||
if services.globals.config.admin_room_notices {
|
||||
if services.server.config.admin_room_notices {
|
||||
services
|
||||
.admin
|
||||
.send_message(RoomMessageEventContent::notice_plain(format!(
|
||||
|
@ -407,7 +407,7 @@ pub(crate) async fn register_route(
|
|||
}
|
||||
} else {
|
||||
#[allow(clippy::collapsible_else_if)]
|
||||
if services.globals.config.admin_room_notices {
|
||||
if services.server.config.admin_room_notices {
|
||||
services
|
||||
.admin
|
||||
.send_message(RoomMessageEventContent::notice_plain(format!(
|
||||
|
@ -438,10 +438,10 @@ pub(crate) async fn register_route(
|
|||
}
|
||||
|
||||
if body.appservice_info.is_none()
|
||||
&& !services.globals.config.auto_join_rooms.is_empty()
|
||||
&& !services.server.config.auto_join_rooms.is_empty()
|
||||
&& (services.globals.allow_guests_auto_join_rooms() || !is_guest)
|
||||
{
|
||||
for room in &services.globals.config.auto_join_rooms {
|
||||
for room in &services.server.config.auto_join_rooms {
|
||||
let Ok(room_id) = services.rooms.alias.resolve(room).await else {
|
||||
error!(
|
||||
"Failed to resolve room alias to room ID when attempting to auto join \
|
||||
|
@ -570,7 +570,7 @@ pub(crate) async fn change_password_route(
|
|||
|
||||
info!("User {sender_user} changed their password.");
|
||||
|
||||
if services.globals.config.admin_room_notices {
|
||||
if services.server.config.admin_room_notices {
|
||||
services
|
||||
.admin
|
||||
.send_message(RoomMessageEventContent::notice_plain(format!(
|
||||
|
@ -673,7 +673,7 @@ pub(crate) async fn deactivate_route(
|
|||
|
||||
info!("User {sender_user} deactivated their account.");
|
||||
|
||||
if services.globals.config.admin_room_notices {
|
||||
if services.server.config.admin_room_notices {
|
||||
services
|
||||
.admin
|
||||
.send_message(RoomMessageEventContent::notice_plain(format!(
|
||||
|
|
|
@ -152,7 +152,7 @@ pub(crate) async fn set_room_visibility_route(
|
|||
|
||||
match &body.visibility {
|
||||
| room::Visibility::Public => {
|
||||
if services.globals.config.lockdown_public_room_directory
|
||||
if services.server.config.lockdown_public_room_directory
|
||||
&& !services.users.is_admin(sender_user).await
|
||||
&& body.appservice_info.is_none()
|
||||
{
|
||||
|
@ -162,7 +162,7 @@ pub(crate) async fn set_room_visibility_route(
|
|||
body.room_id
|
||||
);
|
||||
|
||||
if services.globals.config.admin_room_notices {
|
||||
if services.server.config.admin_room_notices {
|
||||
services
|
||||
.admin
|
||||
.send_text(&format!(
|
||||
|
@ -181,7 +181,7 @@ pub(crate) async fn set_room_visibility_route(
|
|||
|
||||
services.rooms.directory.set_public(&body.room_id);
|
||||
|
||||
if services.globals.config.admin_room_notices {
|
||||
if services.server.config.admin_room_notices {
|
||||
services
|
||||
.admin
|
||||
.send_text(&format!(
|
||||
|
|
|
@ -31,7 +31,7 @@ pub(crate) async fn get_media_config_route(
|
|||
_body: Ruma<get_media_config::v1::Request>,
|
||||
) -> Result<get_media_config::v1::Response> {
|
||||
Ok(get_media_config::v1::Response {
|
||||
upload_size: ruma_from_usize(services.globals.config.max_request_size),
|
||||
upload_size: ruma_from_usize(services.server.config.max_request_size),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ pub(crate) async fn get_media_config_legacy_route(
|
|||
_body: Ruma<get_media_config::v3::Request>,
|
||||
) -> Result<get_media_config::v3::Response> {
|
||||
Ok(get_media_config::v3::Response {
|
||||
upload_size: ruma_from_usize(services.globals.config.max_request_size),
|
||||
upload_size: ruma_from_usize(services.server.config.max_request_size),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ async fn banned_room_check(
|
|||
if let Some(room_id) = room_id {
|
||||
if services.rooms.metadata.is_banned(room_id).await
|
||||
|| services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.forbidden_remote_server_names
|
||||
.contains(&room_id.server_name().unwrap().to_owned())
|
||||
|
@ -81,12 +81,12 @@ async fn banned_room_check(
|
|||
attempted to join a banned room or banned room server name: {room_id}"
|
||||
);
|
||||
|
||||
if services.globals.config.auto_deactivate_banned_room_attempts {
|
||||
if services.server.config.auto_deactivate_banned_room_attempts {
|
||||
warn!(
|
||||
"Automatically deactivating user {user_id} due to attempted banned room join"
|
||||
);
|
||||
|
||||
if services.globals.config.admin_room_notices {
|
||||
if services.server.config.admin_room_notices {
|
||||
services
|
||||
.admin
|
||||
.send_message(RoomMessageEventContent::text_plain(format!(
|
||||
|
@ -112,7 +112,7 @@ async fn banned_room_check(
|
|||
}
|
||||
} else if let Some(server_name) = server_name {
|
||||
if services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.forbidden_remote_server_names
|
||||
.contains(&server_name.to_owned())
|
||||
|
@ -122,12 +122,12 @@ async fn banned_room_check(
|
|||
name {server_name} that is globally forbidden. Rejecting.",
|
||||
);
|
||||
|
||||
if services.globals.config.auto_deactivate_banned_room_attempts {
|
||||
if services.server.config.auto_deactivate_banned_room_attempts {
|
||||
warn!(
|
||||
"Automatically deactivating user {user_id} due to attempted banned room join"
|
||||
);
|
||||
|
||||
if services.globals.config.admin_room_notices {
|
||||
if services.server.config.admin_room_notices {
|
||||
services
|
||||
.admin
|
||||
.send_message(RoomMessageEventContent::text_plain(format!(
|
||||
|
|
|
@ -37,7 +37,7 @@ pub(crate) async fn create_openid_token_route(
|
|||
Ok(account::request_openid_token::v3::Response {
|
||||
access_token,
|
||||
token_type: TokenType::Bearer,
|
||||
matrix_server_name: services.globals.config.server_name.clone(),
|
||||
matrix_server_name: services.server.config.server_name.clone(),
|
||||
expires_in: Duration::from_secs(expires_in),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ pub(crate) async fn report_room_route(
|
|||
if !services
|
||||
.rooms
|
||||
.state_cache
|
||||
.server_in_room(&services.globals.config.server_name, &body.room_id)
|
||||
.server_in_room(&services.server.config.server_name, &body.room_id)
|
||||
.await
|
||||
{
|
||||
return Err!(Request(NotFound(
|
||||
|
|
|
@ -71,7 +71,7 @@ pub(crate) async fn create_room_route(
|
|||
let room_id: OwnedRoomId = if let Some(custom_room_id) = &body.room_id {
|
||||
custom_room_id_check(&services, custom_room_id)?
|
||||
} else {
|
||||
RoomId::new(&services.globals.config.server_name)
|
||||
RoomId::new(&services.server.config.server_name)
|
||||
};
|
||||
|
||||
// check if room ID doesn't already exist instead of erroring on auth check
|
||||
|
@ -83,7 +83,7 @@ pub(crate) async fn create_room_route(
|
|||
}
|
||||
|
||||
if body.visibility == room::Visibility::Public
|
||||
&& services.globals.config.lockdown_public_room_directory
|
||||
&& services.server.config.lockdown_public_room_directory
|
||||
&& !services.users.is_admin(sender_user).await
|
||||
&& body.appservice_info.is_none()
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ pub(crate) async fn create_room_route(
|
|||
&room_id
|
||||
);
|
||||
|
||||
if services.globals.config.admin_room_notices {
|
||||
if services.server.config.admin_room_notices {
|
||||
services
|
||||
.admin
|
||||
.send_text(&format!(
|
||||
|
@ -450,7 +450,7 @@ pub(crate) async fn create_room_route(
|
|||
if body.visibility == room::Visibility::Public {
|
||||
services.rooms.directory.set_public(&room_id);
|
||||
|
||||
if services.globals.config.admin_room_notices {
|
||||
if services.server.config.admin_room_notices {
|
||||
services
|
||||
.admin
|
||||
.send_text(&format!(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum::extract::State;
|
||||
use conduwuit::Err;
|
||||
use conduwuit::{utils::math::Tried, Err};
|
||||
use ruma::api::client::typing::create_typing_event;
|
||||
|
||||
use crate::{utils, Result, Ruma};
|
||||
|
@ -31,17 +31,15 @@ pub(crate) async fn create_typing_event_route(
|
|||
let duration = utils::clamp(
|
||||
duration.as_millis().try_into().unwrap_or(u64::MAX),
|
||||
services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.typing_client_timeout_min_s
|
||||
.checked_mul(1000)
|
||||
.unwrap(),
|
||||
.try_mul(1000)?,
|
||||
services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.typing_client_timeout_max_s
|
||||
.checked_mul(1000)
|
||||
.unwrap(),
|
||||
.try_mul(1000)?,
|
||||
);
|
||||
services
|
||||
.rooms
|
||||
|
|
|
@ -38,7 +38,7 @@ pub(crate) async fn turn_server_route(
|
|||
let user = body.sender_user.unwrap_or_else(|| {
|
||||
UserId::parse_with_server_name(
|
||||
utils::random_string(RANDOM_USER_ID_LENGTH).to_lowercase(),
|
||||
&services.globals.config.server_name,
|
||||
&services.server.config.server_name,
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
|
|
|
@ -71,7 +71,7 @@ pub(super) async fn auth(
|
|||
match metadata {
|
||||
| &get_public_rooms::v3::Request::METADATA => {
|
||||
if !services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.allow_public_room_directory_without_auth
|
||||
{
|
||||
|
@ -94,7 +94,7 @@ pub(super) async fn auth(
|
|||
| &get_display_name::v3::Request::METADATA
|
||||
| &get_avatar_url::v3::Request::METADATA
|
||||
| &get_timezone_key::unstable::Request::METADATA => {
|
||||
if services.globals.config.require_auth_for_profile_requests {
|
||||
if services.server.config.require_auth_for_profile_requests {
|
||||
match token {
|
||||
| Token::Appservice(_) | Token::User(_) => {
|
||||
// we should have validated the token above
|
||||
|
@ -127,7 +127,7 @@ pub(super) async fn auth(
|
|||
}),
|
||||
| (AuthScheme::AccessToken, Token::None) => match metadata {
|
||||
| &get_turn_server_info::v3::Request::METADATA => {
|
||||
if services.globals.config.turn_allow_guests {
|
||||
if services.server.config.turn_allow_guests {
|
||||
Ok(Auth {
|
||||
origin: None,
|
||||
sender_user: None,
|
||||
|
|
|
@ -32,7 +32,7 @@ pub(super) async fn from(
|
|||
let query = serde_html_form::from_str(query)
|
||||
.map_err(|e| err!(Request(Unknown("Failed to read query parameters: {e}"))))?;
|
||||
|
||||
let max_body_size = services.globals.config.max_request_size;
|
||||
let max_body_size = services.server.config.max_request_size;
|
||||
|
||||
let body = axum::body::to_bytes(body, max_body_size)
|
||||
.await
|
||||
|
|
|
@ -37,7 +37,7 @@ pub(crate) async fn create_invite_route(
|
|||
|
||||
if let Some(server) = body.room_id.server_name() {
|
||||
if services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.forbidden_remote_server_names
|
||||
.contains(&server.to_owned())
|
||||
|
@ -47,7 +47,7 @@ pub(crate) async fn create_invite_route(
|
|||
}
|
||||
|
||||
if services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.forbidden_remote_server_names
|
||||
.contains(body.origin())
|
||||
|
|
|
@ -42,7 +42,7 @@ pub(crate) async fn create_join_event_template_route(
|
|||
.await?;
|
||||
|
||||
if services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.forbidden_remote_server_names
|
||||
.contains(body.origin())
|
||||
|
@ -59,7 +59,7 @@ pub(crate) async fn create_join_event_template_route(
|
|||
|
||||
if let Some(server) = body.room_id.server_name() {
|
||||
if services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.forbidden_remote_server_names
|
||||
.contains(&server.to_owned())
|
||||
|
|
|
@ -34,7 +34,7 @@ pub(crate) async fn create_knock_event_template_route(
|
|||
.await?;
|
||||
|
||||
if services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.forbidden_remote_server_names
|
||||
.contains(body.origin())
|
||||
|
@ -51,7 +51,7 @@ pub(crate) async fn create_knock_event_template_route(
|
|||
|
||||
if let Some(server) = body.room_id.server_name() {
|
||||
if services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.forbidden_remote_server_names
|
||||
.contains(&server.to_owned())
|
||||
|
|
|
@ -20,7 +20,7 @@ pub(crate) async fn get_public_rooms_filtered_route(
|
|||
body: Ruma<get_public_rooms_filtered::v1::Request>,
|
||||
) -> Result<get_public_rooms_filtered::v1::Response> {
|
||||
if !services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.allow_public_room_directory_over_federation
|
||||
{
|
||||
|
|
|
@ -63,7 +63,7 @@ pub(crate) async fn get_profile_information_route(
|
|||
body: Ruma<get_profile_information::v1::Request>,
|
||||
) -> Result<get_profile_information::v1::Response> {
|
||||
if !services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.allow_inbound_profile_lookup_federation_requests
|
||||
{
|
||||
|
|
|
@ -309,7 +309,7 @@ async fn handle_edu_typing(
|
|||
origin: &ServerName,
|
||||
typing: TypingContent,
|
||||
) {
|
||||
if !services.globals.config.allow_incoming_typing {
|
||||
if !services.server.config.allow_incoming_typing {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -344,7 +344,7 @@ async fn handle_edu_typing(
|
|||
if typing.typing {
|
||||
let timeout = utils::millis_since_unix_epoch().saturating_add(
|
||||
services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.typing_federation_timeout_s
|
||||
.saturating_mul(1000),
|
||||
|
|
|
@ -268,7 +268,7 @@ pub(crate) async fn create_join_event_v1_route(
|
|||
body: Ruma<create_join_event::v1::Request>,
|
||||
) -> Result<create_join_event::v1::Response> {
|
||||
if services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.forbidden_remote_server_names
|
||||
.contains(body.origin())
|
||||
|
@ -284,7 +284,7 @@ pub(crate) async fn create_join_event_v1_route(
|
|||
|
||||
if let Some(server) = body.room_id.server_name() {
|
||||
if services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.forbidden_remote_server_names
|
||||
.contains(&server.to_owned())
|
||||
|
@ -316,7 +316,7 @@ pub(crate) async fn create_join_event_v2_route(
|
|||
body: Ruma<create_join_event::v2::Request>,
|
||||
) -> Result<create_join_event::v2::Response> {
|
||||
if services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.forbidden_remote_server_names
|
||||
.contains(body.origin())
|
||||
|
@ -326,7 +326,7 @@ pub(crate) async fn create_join_event_v2_route(
|
|||
|
||||
if let Some(server) = body.room_id.server_name() {
|
||||
if services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.forbidden_remote_server_names
|
||||
.contains(&server.to_owned())
|
||||
|
|
|
@ -22,7 +22,7 @@ pub(crate) async fn create_knock_event_v1_route(
|
|||
body: Ruma<send_knock::v1::Request>,
|
||||
) -> Result<send_knock::v1::Response> {
|
||||
if services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.forbidden_remote_server_names
|
||||
.contains(body.origin())
|
||||
|
@ -38,7 +38,7 @@ pub(crate) async fn create_knock_event_v1_route(
|
|||
|
||||
if let Some(server) = body.room_id.server_name() {
|
||||
if services
|
||||
.globals
|
||||
.server
|
||||
.config
|
||||
.forbidden_remote_server_names
|
||||
.contains(&server.to_owned())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue