From 5cb2551422898af8b3ba02d5e79fe27c2e2adec9 Mon Sep 17 00:00:00 2001 From: Charles Hall Date: Thu, 16 May 2024 01:42:48 -0700 Subject: [PATCH] enable `error_on_line_overflow` and fix errors These required some manual intervention. --- rustfmt.toml | 1 + src/api/client_server/report.rs | 107 +++++++++++++++-------------- src/database/abstraction/sqlite.rs | 6 +- src/main.rs | 12 +++- src/service/admin.rs | 4 +- src/service/rooms/state_cache.rs | 5 +- 6 files changed, 75 insertions(+), 60 deletions(-) diff --git a/rustfmt.toml b/rustfmt.toml index 58355ad5..a0729a75 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,6 +1,7 @@ edition = "2021" condense_wildcard_suffixes = true +error_on_line_overflow = true format_code_in_doc_comments = true format_macro_bodies = true format_macro_matchers = true diff --git a/src/api/client_server/report.rs b/src/api/client_server/report.rs index 7bcf3f25..d9242f62 100644 --- a/src/api/client_server/report.rs +++ b/src/api/client_server/report.rs @@ -35,58 +35,61 @@ pub(crate) async fn report_event_route( )); }; - services() - .admin - .send_message(message::RoomMessageEventContent::text_html( - format!( - "Report received from: {}\n\nEvent ID: {:?}\nRoom ID: {:?}\nSent \ - By: {:?}\n\nReport Score: {:?}\nReport Reason: {:?}", - sender_user, pdu.event_id, pdu.room_id, pdu.sender, body.score, body.reason - ), - format!( - r#" -
- - Report received from: - {0:?} - - -
- "#, - sender_user, - pdu.event_id, - pdu.room_id, - pdu.sender, - body.score, - html_escape::encode_safe(body.reason.as_deref().unwrap_or("")) - ), - )); + services().admin.send_message(message::RoomMessageEventContent::text_html( + format!( + "Report received from: {}\n\nEvent ID: {:?}\nRoom ID: {:?}\nSent \ + By: {:?}\n\nReport Score: {:?}\nReport Reason: {:?}", + sender_user, + pdu.event_id, + pdu.room_id, + pdu.sender, + body.score, + body.reason + ), + format!( + r#" +
+ + Report received from: + {0:?} + + +
+ "#, + sender_user, + pdu.event_id, + pdu.room_id, + pdu.sender, + body.score, + html_escape::encode_safe(body.reason.as_deref().unwrap_or("")) + ), + )); Ok(report_content::v3::Response {}) } diff --git a/src/database/abstraction/sqlite.rs b/src/database/abstraction/sqlite.rs index f73ba509..1ddfff54 100644 --- a/src/database/abstraction/sqlite.rs +++ b/src/database/abstraction/sqlite.rs @@ -15,8 +15,10 @@ use super::{watchers::Watchers, KeyValueDatabaseEngine, KvTree}; use crate::{database::Config, Result}; thread_local! { - static READ_CONNECTION: RefCell> = RefCell::new(None); - static READ_CONNECTION_ITERATOR: RefCell> = RefCell::new(None); + static READ_CONNECTION: RefCell> = + RefCell::new(None); + static READ_CONNECTION_ITERATOR: RefCell> = + RefCell::new(None); } struct PreparedStatementIterator<'a> { diff --git a/src/main.rs b/src/main.rs index 407a01b0..cccc7ba4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -595,9 +595,15 @@ macro_rules! impl_ruma_handler { for path in meta.history.all_paths() { let handler = self.clone(); - router = router.route(path, on(method_filter, |$( $ty: $ty, )* req| async move { - handler($($ty,)* req).await.map(RumaResponse) - })) + router = router.route( + path, + on( + method_filter, + |$( $ty: $ty, )* req| async move { + handler($($ty,)* req).await.map(RumaResponse) + } + ) + ) } router diff --git a/src/service/admin.rs b/src/service/admin.rs index 87b645f1..562d0ec3 100644 --- a/src/service/admin.rs +++ b/src/service/admin.rs @@ -243,7 +243,9 @@ impl Service { Some(event) = receiver.recv() => { let message_content = match event { AdminRoomEvent::SendMessage(content) => content, - AdminRoomEvent::ProcessMessage(room_message) => self.process_admin_message(room_message).await + AdminRoomEvent::ProcessMessage(room_message) => { + self.process_admin_message(room_message).await + } }; let mutex_state = Arc::clone( diff --git a/src/service/rooms/state_cache.rs b/src/service/rooms/state_cache.rs index bf4ce632..deaf1cc8 100644 --- a/src/service/rooms/state_cache.rs +++ b/src/service/rooms/state_cache.rs @@ -21,6 +21,8 @@ pub(crate) struct Service { pub(crate) db: &'static dyn Data, } +type RoomsLeft = (OwnedRoomId, Vec>); + impl Service { /// Update current membership data. #[tracing::instrument(skip(self, last_state))] @@ -390,8 +392,7 @@ impl Service { pub(crate) fn rooms_left<'a>( &'a self, user_id: &UserId, - ) -> impl Iterator>)>> + 'a - { + ) -> impl Iterator> + 'a { self.db.rooms_left(user_id) }