diff --git a/src/api/client_server/account.rs b/src/api/client_server/account.rs index 1a569b41..b45af7df 100644 --- a/src/api/client_server/account.rs +++ b/src/api/client_server/account.rs @@ -198,7 +198,7 @@ pub(crate) async fn register_route( &uiaainfo, )?; if !worked { - return Err(Error::Uiaa(uiaainfo)); + return Err(Error::Uiaa(Box::new(uiaainfo))); } // Success! } else if let Some(json) = body.json_body { @@ -213,7 +213,7 @@ pub(crate) async fn register_route( &uiaainfo, &json, )?; - return Err(Error::Uiaa(uiaainfo)); + return Err(Error::Uiaa(Box::new(uiaainfo))); } else { return Err(Error::BadRequest(ErrorKind::NotJson, "Not json.")); } @@ -346,13 +346,13 @@ pub(crate) async fn change_password_route( &uiaainfo, )?; if !worked { - return Err(Error::Uiaa(uiaainfo)); + return Err(Error::Uiaa(Box::new(uiaainfo))); } // Success! } else if let Some(json) = body.json_body { uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); services().uiaa.create(sender_user, sender_device, &uiaainfo, &json)?; - return Err(Error::Uiaa(uiaainfo)); + return Err(Error::Uiaa(Box::new(uiaainfo))); } else { return Err(Error::BadRequest(ErrorKind::NotJson, "Not json.")); } @@ -434,13 +434,13 @@ pub(crate) async fn deactivate_route( &uiaainfo, )?; if !worked { - return Err(Error::Uiaa(uiaainfo)); + return Err(Error::Uiaa(Box::new(uiaainfo))); } // Success! } else if let Some(json) = body.json_body { uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); services().uiaa.create(sender_user, sender_device, &uiaainfo, &json)?; - return Err(Error::Uiaa(uiaainfo)); + return Err(Error::Uiaa(Box::new(uiaainfo))); } else { return Err(Error::BadRequest(ErrorKind::NotJson, "Not json.")); } diff --git a/src/api/client_server/alias.rs b/src/api/client_server/alias.rs index b2fbcf65..16052d06 100644 --- a/src/api/client_server/alias.rs +++ b/src/api/client_server/alias.rs @@ -164,7 +164,7 @@ pub(crate) async fn get_alias_helper( } } } - }; + } let Some(room_id) = room_id else { return Err(Error::BadRequest( diff --git a/src/api/client_server/device.rs b/src/api/client_server/device.rs index f94cae6e..adecd073 100644 --- a/src/api/client_server/device.rs +++ b/src/api/client_server/device.rs @@ -107,13 +107,13 @@ pub(crate) async fn delete_device_route( &uiaainfo, )?; if !worked { - return Err(Error::Uiaa(uiaainfo)); + return Err(Error::Uiaa(Box::new(uiaainfo))); } // Success! } else if let Some(json) = body.json_body { uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); services().uiaa.create(sender_user, sender_device, &uiaainfo, &json)?; - return Err(Error::Uiaa(uiaainfo)); + return Err(Error::Uiaa(Box::new(uiaainfo))); } else { return Err(Error::BadRequest(ErrorKind::NotJson, "Not json.")); } @@ -161,13 +161,13 @@ pub(crate) async fn delete_devices_route( &uiaainfo, )?; if !worked { - return Err(Error::Uiaa(uiaainfo)); + return Err(Error::Uiaa(Box::new(uiaainfo))); } // Success! } else if let Some(json) = body.json_body { uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); services().uiaa.create(sender_user, sender_device, &uiaainfo, &json)?; - return Err(Error::Uiaa(uiaainfo)); + return Err(Error::Uiaa(Box::new(uiaainfo))); } else { return Err(Error::BadRequest(ErrorKind::NotJson, "Not json.")); } diff --git a/src/api/client_server/keys.rs b/src/api/client_server/keys.rs index d2e3006f..7c22d56e 100644 --- a/src/api/client_server/keys.rs +++ b/src/api/client_server/keys.rs @@ -135,13 +135,13 @@ pub(crate) async fn upload_signing_keys_route( &uiaainfo, )?; if !worked { - return Err(Error::Uiaa(uiaainfo)); + return Err(Error::Uiaa(Box::new(uiaainfo))); } // Success! } else if let Some(json) = body.json_body { uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); services().uiaa.create(sender_user, sender_device, &uiaainfo, &json)?; - return Err(Error::Uiaa(uiaainfo)); + return Err(Error::Uiaa(Box::new(uiaainfo))); } else { return Err(Error::BadRequest(ErrorKind::NotJson, "Not json.")); } diff --git a/src/api/client_server/report.rs b/src/api/client_server/report.rs index edf18057..e822f7ae 100644 --- a/src/api/client_server/report.rs +++ b/src/api/client_server/report.rs @@ -26,14 +26,14 @@ pub(crate) async fn report_event_route( ErrorKind::InvalidParam, "Invalid score, must be within 0 to -100", )); - }; + } if let Some(true) = body.reason.clone().map(|s| s.chars().count() > 250) { return Err(Error::BadRequest( ErrorKind::InvalidParam, "Reason too long, should be 250 characters or fewer", )); - }; + } services().admin.send_message(message::RoomMessageEventContent::text_html( format!( diff --git a/src/api/ruma_wrapper/axum.rs b/src/api/ruma_wrapper/axum.rs index a514c6b8..d3fb0811 100644 --- a/src/api/ruma_wrapper/axum.rs +++ b/src/api/ruma_wrapper/axum.rs @@ -263,7 +263,7 @@ async fn ar_from_request_inner( if let Some(json_body) = &json_body { request_map.insert("content".to_owned(), json_body.clone()); - }; + } let keys_result = services() .rooms diff --git a/src/api/server_server.rs b/src/api/server_server.rs index 5bb7b554..abd111f4 100644 --- a/src/api/server_server.rs +++ b/src/api/server_server.rs @@ -217,7 +217,7 @@ where serde_json::from_slice(http_request.body()) .expect("body is valid json, we just created it"), ); - }; + } request_map .insert("method".to_owned(), T::METADATA.method.to_string().into()); diff --git a/src/database/abstraction/watchers.rs b/src/database/abstraction/watchers.rs index b31bd082..3f33e537 100644 --- a/src/database/abstraction/watchers.rs +++ b/src/database/abstraction/watchers.rs @@ -54,6 +54,6 @@ impl Watchers { tx.0.send(()).expect("channel should still be open"); } } - }; + } } } diff --git a/src/main.rs b/src/main.rs index fc6a3459..17ddfb2f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,7 +72,7 @@ fn set_application_state(state: ApplicationState) { ]); } ApplicationState::Stopping => notify(&[NotifyState::Stopping]), - }; + } } } diff --git a/src/service/admin.rs b/src/service/admin.rs index 0f15d5bc..dcd971af 100644 --- a/src/service/admin.rs +++ b/src/service/admin.rs @@ -246,7 +246,7 @@ impl TracingFilterCommand { #[derive(Debug)] pub(crate) enum AdminRoomEvent { ProcessMessage(String), - SendMessage(RoomMessageEventContent), + SendMessage(Box), } pub(crate) struct Service { @@ -297,7 +297,7 @@ impl Service { grapevine_room: &OwnedRoomId, ) { let message_content = match event { - AdminRoomEvent::SendMessage(content) => content, + AdminRoomEvent::SendMessage(content) => *content, AdminRoomEvent::ProcessMessage(room_message) => { self.process_admin_message(room_message).await } @@ -343,7 +343,9 @@ impl Service { &self, message_content: RoomMessageEventContent, ) { - self.sender.send(AdminRoomEvent::SendMessage(message_content)).unwrap(); + self.sender + .send(AdminRoomEvent::SendMessage(Box::new(message_content))) + .unwrap(); } // Parse and process a message from the admin room @@ -701,7 +703,7 @@ impl Service { return Ok(RoomMessageEventContent::text_plain( "The specified user is not from this server!", )); - }; + } // Check if the specified user is valid if !services().users.exists(&user_id)? @@ -1234,7 +1236,7 @@ impl Service { return Ok(RoomMessageEventContent::text_plain(format!( "Failed to reload filter: {e}" ))); - }; + } return Ok(RoomMessageEventContent::text_plain( "Filter reloaded", diff --git a/src/service/globals.rs b/src/service/globals.rs index 524c18d3..33dac38e 100644 --- a/src/service/globals.rs +++ b/src/service/globals.rs @@ -329,7 +329,7 @@ impl Service { error!(config=?s.config.default_room_version, fallback=?crate::config::default_default_room_version(), "Room version in config isn't supported, falling back to default version"); s.config.default_room_version = crate::config::default_default_room_version(); - }; + } Ok(s) } @@ -526,7 +526,7 @@ impl Service { Grapevine user", ); } - }; + } } pub(crate) fn supported_room_versions(&self) -> Vec { diff --git a/src/service/rooms/auth_chain.rs b/src/service/rooms/auth_chain.rs index 3c8e4b38..6711263d 100644 --- a/src/service/rooms/auth_chain.rs +++ b/src/service/rooms/auth_chain.rs @@ -157,7 +157,7 @@ impl Service { if i % 100 == 0 { tokio::task::yield_now().await; } - }; + } } debug!( chunk_cache_length = ?chunk_cache.len(), diff --git a/src/service/rooms/event_handler.rs b/src/service/rooms/event_handler.rs index cbe8079d..96e33f5f 100644 --- a/src/service/rooms/event_handler.rs +++ b/src/service/rooms/event_handler.rs @@ -1126,10 +1126,7 @@ impl Service { services() .rooms .auth_chain - .get_auth_chain( - room_id, - state.iter().map(|(_, id)| id.clone()).collect(), - ) + .get_auth_chain(room_id, state.values().cloned().collect()) .await? .collect(), ); diff --git a/src/service/rooms/state.rs b/src/service/rooms/state.rs index 5db98287..bf028f71 100644 --- a/src/service/rooms/state.rs +++ b/src/service/rooms/state.rs @@ -155,7 +155,7 @@ impl Service { .invalidate_cache(&pdu.room_id) .await; } - _ => continue, + _ => {} } } diff --git a/src/service/rooms/state_compressor.rs b/src/service/rooms/state_compressor.rs index 60fbb9c5..304cd9cb 100644 --- a/src/service/rooms/state_compressor.rs +++ b/src/service/rooms/state_compressor.rs @@ -257,7 +257,7 @@ impl Service { )?; return Ok(()); - }; + } // Else we have two options. // 1. We add the current diff on top of the parent layer. @@ -374,7 +374,7 @@ impl Service { 2, states_parents, )?; - }; + } Ok((new_shortstatehash, statediffnew, statediffremoved)) } diff --git a/src/service/rooms/timeline.rs b/src/service/rooms/timeline.rs index 93bf6c53..10fabf40 100644 --- a/src/service/rooms/timeline.rs +++ b/src/service/rooms/timeline.rs @@ -442,7 +442,7 @@ impl Service { highlight = true; } _ => {} - }; + } } if notify { @@ -497,7 +497,7 @@ impl Service { )? { self.redact_pdu(redact_id, pdu, shortroomid)?; } - }; + } } TimelineEventType::SpaceChild => { if pdu.state_key.is_some() { diff --git a/src/service/users.rs b/src/service/users.rs index b05a2ccb..9df6e835 100644 --- a/src/service/users.rs +++ b/src/service/users.rs @@ -96,12 +96,12 @@ impl Service { if let Some(cached_list) = cached.lists.get(list_id) { if list.sort.is_empty() { list.sort.clone_from(&cached_list.sort); - }; + } if list.room_details.required_state.is_empty() { list.room_details .required_state .clone_from(&cached_list.room_details.required_state); - }; + } list.room_details.timeline_limit = list .room_details .timeline_limit @@ -151,7 +151,7 @@ impl Service { if list.bump_event_types.is_empty() { list.bump_event_types .clone_from(&cached_list.bump_event_types); - }; + } } cached.lists.insert(list_id.clone(), list.clone()); } diff --git a/src/utils/error.rs b/src/utils/error.rs index 0b5420b3..9e36c3b3 100644 --- a/src/utils/error.rs +++ b/src/utils/error.rs @@ -66,7 +66,7 @@ pub(crate) enum Error { /// Don't create this directly. Use [`Error::bad_database`] instead. BadDatabase(&'static str), #[error("uiaa")] - Uiaa(UiaaInfo), + Uiaa(Box), #[error("{}: {}", .0.errcode(), .1)] BadRequest(ErrorKind, &'static str), // This is only needed for when a room alias already exists @@ -106,7 +106,7 @@ impl Error { }; if let Self::Uiaa(uiaainfo) = self { - return Ra(UiaaResponse::AuthResponse(uiaainfo.clone())); + return Ra(UiaaResponse::AuthResponse(*uiaainfo.clone())); } if let Self::Federation(origin, error) = self { diff --git a/src/utils/on_demand_hashmap.rs b/src/utils/on_demand_hashmap.rs index 69e8bac9..9f74e3d6 100644 --- a/src/utils/on_demand_hashmap.rs +++ b/src/utils/on_demand_hashmap.rs @@ -201,7 +201,7 @@ impl Drop for EntryDropGuard { .send(self.key.take().expect("drop should only be called once")) { warn!(%error, "Failed to send cleanup message"); - }; + } } }