diff --git a/src/admin/user/commands.rs b/src/admin/user/commands.rs index c51545f7..7b303dc6 100644 --- a/src/admin/user/commands.rs +++ b/src/admin/user/commands.rs @@ -163,8 +163,8 @@ pub(super) async fn deactivate(&self, no_leave_rooms: bool, user_id: String) -> .rooms_joined(&user_id) .filter_map(Result::ok) .collect(); - update_displayname(self.services, user_id.clone(), None, all_joined_rooms.clone()).await?; - update_avatar_url(self.services, user_id.clone(), None, None, all_joined_rooms).await?; + update_displayname(self.services, &user_id, None, all_joined_rooms.clone()).await?; + update_avatar_url(self.services, &user_id, None, None, all_joined_rooms).await?; self.services.users.set_timezone(&user_id, None).await?; leave_all_rooms(self.services, &user_id).await; } @@ -272,8 +272,9 @@ pub(super) async fn deactivate_all(&self, no_leave_rooms: bool, force: bool) -> .rooms_joined(&user_id) .filter_map(Result::ok) .collect(); - update_displayname(self.services, user_id.clone(), None, all_joined_rooms.clone()).await?; - update_avatar_url(self.services, user_id.clone(), None, None, all_joined_rooms).await?; + update_displayname(self.services, &user_id, None, all_joined_rooms.clone()).await?; + update_avatar_url(self.services, &user_id, None, None, all_joined_rooms).await?; + self.services.users.set_timezone(&user_id, None).await?; leave_all_rooms(self.services, &user_id).await; } }, diff --git a/src/api/client/account.rs b/src/api/client/account.rs index 01e0a501..f1f330f6 100644 --- a/src/api/client/account.rs +++ b/src/api/client/account.rs @@ -568,8 +568,9 @@ pub(crate) async fn deactivate_route( .rooms_joined(sender_user) .filter_map(Result::ok) .collect(); - super::update_displayname(&services, sender_user.clone(), None, all_joined_rooms.clone()).await?; - super::update_avatar_url(&services, sender_user.clone(), None, None, all_joined_rooms).await?; + super::update_displayname(&services, sender_user, None, all_joined_rooms.clone()).await?; + super::update_avatar_url(&services, sender_user, None, None, all_joined_rooms).await?; + services.users.set_timezone(sender_user, None).await?; // Make the user leave all rooms before deactivation super::leave_all_rooms(&services, sender_user).await; diff --git a/src/api/client/membership.rs b/src/api/client/membership.rs index 34e45a12..c7d37c45 100644 --- a/src/api/client/membership.rs +++ b/src/api/client/membership.rs @@ -93,8 +93,9 @@ async fn banned_room_check( .filter_map(Result::ok) .collect(); - update_displayname(services, user_id.into(), None, all_joined_rooms.clone()).await?; - update_avatar_url(services, user_id.into(), None, None, all_joined_rooms).await?; + update_displayname(services, user_id, None, all_joined_rooms.clone()).await?; + update_avatar_url(services, user_id, None, None, all_joined_rooms).await?; + services.users.set_timezone(user_id, None).await?; leave_all_rooms(services, user_id).await; } @@ -136,8 +137,9 @@ async fn banned_room_check( .filter_map(Result::ok) .collect(); - update_displayname(services, user_id.into(), None, all_joined_rooms.clone()).await?; - update_avatar_url(services, user_id.into(), None, None, all_joined_rooms).await?; + update_displayname(services, user_id, None, all_joined_rooms.clone()).await?; + update_avatar_url(services, user_id, None, None, all_joined_rooms).await?; + services.users.set_timezone(user_id, None).await?; leave_all_rooms(services, user_id).await; } diff --git a/src/api/client/profile.rs b/src/api/client/profile.rs index 0e1e0f0a..789af643 100644 --- a/src/api/client/profile.rs +++ b/src/api/client/profile.rs @@ -10,7 +10,7 @@ use ruma::{ }, events::{room::member::RoomMemberEventContent, StateEventType, TimelineEventType}, presence::PresenceState, - OwnedMxcUri, OwnedRoomId, OwnedUserId, + OwnedMxcUri, OwnedRoomId, UserId, }; use serde_json::value::to_raw_value; use service::Services; @@ -38,7 +38,7 @@ pub(crate) async fn set_displayname_route( .filter_map(Result::ok) .collect(); - update_displayname(&services, body.user_id.clone(), body.displayname.clone(), all_joined_rooms).await?; + update_displayname(&services, &body.user_id, body.displayname.clone(), all_joined_rooms).await?; if services.globals.allow_local_presence() { // Presence update @@ -129,7 +129,7 @@ pub(crate) async fn set_avatar_url_route( update_avatar_url( &services, - body.user_id.clone(), + &body.user_id, body.avatar_url.clone(), body.blurhash.clone(), all_joined_rooms, @@ -271,9 +271,9 @@ pub(crate) async fn get_profile_route( } pub async fn update_displayname( - services: &Services, user_id: OwnedUserId, displayname: Option, all_joined_rooms: Vec, + services: &Services, user_id: &UserId, displayname: Option, all_joined_rooms: Vec, ) -> Result<()> { - let current_display_name = services.users.displayname(&user_id).unwrap_or_default(); + let current_display_name = services.users.displayname(user_id).unwrap_or_default(); if displayname == current_display_name { return Ok(()); @@ -281,7 +281,7 @@ pub async fn update_displayname( services .users - .set_displayname(&user_id, displayname.clone()) + .set_displayname(user_id, displayname.clone()) .await?; // Send a new join membership event into all joined rooms @@ -325,11 +325,11 @@ pub async fn update_displayname( } pub async fn update_avatar_url( - services: &Services, user_id: OwnedUserId, avatar_url: Option, blurhash: Option, + services: &Services, user_id: &UserId, avatar_url: Option, blurhash: Option, all_joined_rooms: Vec, ) -> Result<()> { - let current_avatar_url = services.users.avatar_url(&user_id).unwrap_or_default(); - let current_blurhash = services.users.blurhash(&user_id).unwrap_or_default(); + let current_avatar_url = services.users.avatar_url(user_id).unwrap_or_default(); + let current_blurhash = services.users.blurhash(user_id).unwrap_or_default(); if current_avatar_url == avatar_url && current_blurhash == blurhash { return Ok(()); @@ -337,11 +337,11 @@ pub async fn update_avatar_url( services .users - .set_avatar_url(&user_id, avatar_url.clone()) + .set_avatar_url(user_id, avatar_url.clone()) .await?; services .users - .set_blurhash(&user_id, blurhash.clone()) + .set_blurhash(user_id, blurhash.clone()) .await?; // Send a new join membership event into all joined rooms @@ -386,14 +386,14 @@ pub async fn update_avatar_url( } pub async fn update_all_rooms( - services: &Services, all_joined_rooms: Vec<(PduBuilder, &OwnedRoomId)>, user_id: OwnedUserId, + services: &Services, all_joined_rooms: Vec<(PduBuilder, &OwnedRoomId)>, user_id: &UserId, ) { for (pdu_builder, room_id) in all_joined_rooms { let state_lock = services.rooms.state.mutex.lock(room_id).await; if let Err(e) = services .rooms .timeline - .build_and_append_pdu(pdu_builder, &user_id, room_id, &state_lock) + .build_and_append_pdu(pdu_builder, user_id, room_id, &state_lock) .await { warn!(%user_id, %room_id, %e, "Failed to update/send new profile join membership update in room");