From 9466aeb08876472f49da6ce4b2fb673ff3598c04 Mon Sep 17 00:00:00 2001 From: strawberry Date: Sat, 2 Nov 2024 18:52:25 -0400 Subject: [PATCH] remove some unnecessary debug prints on notices Signed-off-by: strawberry --- src/api/client/account.rs | 18 ++++++++++-------- src/api/client/report.rs | 25 ++++++++++++++----------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/api/client/account.rs b/src/api/client/account.rs index 97d36839..87e73c5a 100644 --- a/src/api/client/account.rs +++ b/src/api/client/account.rs @@ -100,8 +100,8 @@ pub(crate) async fn register_route( if !services.globals.allow_registration() && body.appservice_info.is_none() { info!( "Registration disabled and request not from known appservice, rejecting registration attempt for username \ - {:?}", - body.username + \"{}\"", + body.username.as_deref().unwrap_or("") ); return Err(Error::BadRequest(ErrorKind::forbidden(), "Registration has been disabled.")); } @@ -114,8 +114,8 @@ pub(crate) async fn register_route( { info!( "Guest registration disabled / registration enabled with token configured, rejecting guest registration \ - attempt, initial device name: {:?}", - body.initial_device_display_name + attempt, initial device name: \"{}\"", + body.initial_device_display_name.as_deref().unwrap_or("") ); return Err(Error::BadRequest( ErrorKind::GuestAccessForbidden, @@ -128,8 +128,8 @@ pub(crate) async fn register_route( if is_guest && services.users.count().await < 2 { warn!( "Guest account attempted to register before a real admin user has been registered, rejecting \ - registration. Guest's initial device name: {:?}", - body.initial_device_display_name + registration. Guest's initial device name: \"{}\"", + body.initial_device_display_name.as_deref().unwrap_or("") ); return Err(Error::BadRequest(ErrorKind::forbidden(), "Registration temporarily disabled.")); } @@ -312,12 +312,14 @@ pub(crate) async fn register_route( debug_info!(%user_id, %device_id, "User account was created"); - let device_display_name = body.initial_device_display_name.clone().unwrap_or_default(); + let device_display_name = body.initial_device_display_name.as_deref().unwrap_or(""); // log in conduit admin channel if a non-guest user registered if body.appservice_info.is_none() && !is_guest { if !device_display_name.is_empty() { - info!("New user \"{user_id}\" registered on this server with device display name: {device_display_name}"); + info!( + "New user \"{user_id}\" registered on this server with device display name: \"{device_display_name}\"" + ); if services.globals.config.admin_room_notices { services diff --git a/src/api/client/report.rs b/src/api/client/report.rs index 32a254d8..e20fa8c2 100644 --- a/src/api/client/report.rs +++ b/src/api/client/report.rs @@ -33,10 +33,18 @@ pub(crate) async fn report_room_route( let sender_user = body.sender_user.as_ref().expect("user is authenticated"); info!( - "Received room report by user {sender_user} for room {} with reason: {:?}", - body.room_id, body.reason + "Received room report by user {sender_user} for room {} with reason: \"{}\"", + body.room_id, + body.reason.as_deref().unwrap_or("") ); + if body.reason.as_ref().is_some_and(|s| s.len() > 750) { + return Err(Error::BadRequest( + ErrorKind::InvalidParam, + "Reason too long, should be 750 characters or fewer", + )); + }; + delay_response().await; if !services @@ -50,13 +58,6 @@ pub(crate) async fn report_room_route( ))); } - if body.reason.as_ref().is_some_and(|s| s.len() > 750) { - return Err(Error::BadRequest( - ErrorKind::InvalidParam, - "Reason too long, should be 750 characters or fewer", - )); - }; - // send admin room message that we received the report with an @room ping for // urgency services @@ -85,8 +86,10 @@ pub(crate) async fn report_event_route( let sender_user = body.sender_user.as_ref().expect("user is authenticated"); info!( - "Received event report by user {sender_user} for room {} and event ID {}, with reason: {:?}", - body.room_id, body.event_id, body.reason + "Received event report by user {sender_user} for room {} and event ID {}, with reason: \"{}\"", + body.room_id, + body.event_id, + body.reason.as_deref().unwrap_or("") ); delay_response().await;