From 0fa6976d868b3a1f5c146a2c64e5c796c12a6f32 Mon Sep 17 00:00:00 2001 From: strawberry Date: Sun, 7 Jul 2024 15:02:09 -0400 Subject: [PATCH] add client IP and user logging on join, remove unnecessary Option Signed-off-by: strawberry --- src/admin/user/commands.rs | 2 +- src/api/client/account.rs | 2 +- src/api/client/membership.rs | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/admin/user/commands.rs b/src/admin/user/commands.rs index 884e1d29..12aa0170 100644 --- a/src/admin/user/commands.rs +++ b/src/admin/user/commands.rs @@ -95,7 +95,7 @@ pub(super) async fn create( if let Some(room_id_server_name) = room.server_name() { match join_room_by_id_helper( - Some(&user_id), + &user_id, room, Some("Automatically joining this room upon registration".to_owned()), &[room_id_server_name.to_owned(), services().globals.server_name().to_owned()], diff --git a/src/api/client/account.rs b/src/api/client/account.rs index 66dc7a26..d34211bf 100644 --- a/src/api/client/account.rs +++ b/src/api/client/account.rs @@ -376,7 +376,7 @@ pub(crate) async fn register_route( if let Some(room_id_server_name) = room.server_name() { if let Err(e) = join_room_by_id_helper( - Some(&user_id), + &user_id, room, Some("Automatically joining this room upon registration".to_owned()), &[room_id_server_name.to_owned(), services().globals.server_name().to_owned()], diff --git a/src/api/client/membership.rs b/src/api/client/membership.rs index 0792ed89..6ebcd95b 100644 --- a/src/api/client/membership.rs +++ b/src/api/client/membership.rs @@ -202,7 +202,7 @@ pub(crate) async fn join_room_by_id_route( } join_room_by_id_helper( - body.sender_user.as_deref(), + sender_user, &body.room_id, body.reason.clone(), &servers, @@ -301,7 +301,7 @@ pub(crate) async fn join_room_by_id_or_alias_route( }; let join_room_response = join_room_by_id_helper( - Some(sender_user), + sender_user, &room_id, body.reason.clone(), &servers, @@ -653,11 +653,9 @@ pub(crate) async fn joined_members_route( } pub async fn join_room_by_id_helper( - sender_user: Option<&UserId>, room_id: &RoomId, reason: Option, servers: &[OwnedServerName], + sender_user: &UserId, room_id: &RoomId, reason: Option, servers: &[OwnedServerName], third_party_signed: Option<&ThirdPartySigned>, ) -> Result { - let sender_user = sender_user.expect("user is authenticated"); - if matches!(services().rooms.state_cache.is_joined(sender_user, room_id), Ok(true)) { info!("{sender_user} is already joined in {room_id}"); return Ok(join_room_by_id::v3::Response { @@ -679,6 +677,7 @@ pub async fn join_room_by_id_helper( } } +#[tracing::instrument(skip_all, fields(%sender_user, %room_id), name = "join_remote")] async fn join_room_by_id_helper_remote( sender_user: &UserId, room_id: &RoomId, reason: Option, servers: &[OwnedServerName], _third_party_signed: Option<&ThirdPartySigned>, state_lock: mutex_map::Guard<()>, @@ -1014,6 +1013,7 @@ async fn join_room_by_id_helper_remote( Ok(join_room_by_id::v3::Response::new(room_id.to_owned())) } +#[tracing::instrument(skip_all, fields(%sender_user, %room_id), name = "join_local")] async fn join_room_by_id_helper_local( sender_user: &UserId, room_id: &RoomId, reason: Option, servers: &[OwnedServerName], _third_party_signed: Option<&ThirdPartySigned>, state_lock: mutex_map::Guard<()>,