From 0f3d43153b6e85082f641bafdfb5fd900a443c00 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 2 Jun 2024 00:25:22 +0000 Subject: [PATCH] Fix unused-self Signed-off-by: Jason Volk --- src/core/config/mod.rs | 4 ++-- src/service/rooms/event_handler/mod.rs | 24 ++++++++++++------------ src/service/rooms/typing/mod.rs | 8 ++++---- src/service/sending/sender.rs | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index b4e2886a..665cbe20 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -411,7 +411,7 @@ impl Config { }; // don't start if we're listening on both UNIX sockets and TCP at same time - if config.is_dual_listening(&raw_config) { + if Self::is_dual_listening(&raw_config) { return Err(Error::bad_config("dual listening on UNIX and TCP sockets not allowed.")); }; @@ -455,7 +455,7 @@ impl Config { /// Checks the presence of the `address` and `unix_socket_path` keys in the /// raw_config, exiting the process if both keys were detected. - fn is_dual_listening(&self, raw_config: &Figment) -> bool { + fn is_dual_listening(raw_config: &Figment) -> bool { let check_address = raw_config.find_value("address"); let check_unix_socket = raw_config.find_value("unix_socket_path"); diff --git a/src/service/rooms/event_handler/mod.rs b/src/service/rooms/event_handler/mod.rs index 15e3d8d3..754365c3 100644 --- a/src/service/rooms/event_handler/mod.rs +++ b/src/service/rooms/event_handler/mod.rs @@ -118,7 +118,7 @@ impl Service { .ok_or_else(|| Error::bad_database("Failed to find create event in db."))?; // Procure the room version - let room_version_id = self.get_room_version_id(&create_event)?; + let room_version_id = Self::get_room_version_id(&create_event)?; let first_pdu_in_room = services() .rooms @@ -130,7 +130,7 @@ impl Service { .handle_outlier_pdu(origin, &create_event, event_id, room_id, value, false, pub_key_map) .await?; - self.check_room_id(room_id, &incoming_pdu)?; + Self::check_room_id(room_id, &incoming_pdu)?; // 8. if not timeline event: stop if !is_timeline_event { @@ -308,7 +308,7 @@ impl Service { // 2. Check signatures, otherwise drop // 3. check content hash, redact if doesn't match - let room_version_id = self.get_room_version_id(create_event)?; + let room_version_id = Self::get_room_version_id(create_event)?; let guard = pub_key_map.read().await; let mut val = match ruma::signatures::verify_event(&guard, &value, &room_version_id) { @@ -347,7 +347,7 @@ impl Service { ) .map_err(|_| Error::bad_database("Event is not a valid PDU."))?; - self.check_room_id(room_id, &incoming_pdu)?; + Self::check_room_id(room_id, &incoming_pdu)?; if !auth_events_known { // 4. fetch any missing auth events doing all checks listed here starting at 1. @@ -382,7 +382,7 @@ impl Service { continue; }; - self.check_room_id(room_id, &auth_event)?; + Self::check_room_id(room_id, &auth_event)?; match auth_events.entry(( auth_event.kind.to_string().into(), @@ -417,7 +417,7 @@ impl Service { } if !state_res::event_auth::auth_check( - &self.to_room_version(&room_version_id), + &Self::to_room_version(&room_version_id), &incoming_pdu, None::, // TODO: third party invite |k, s| auth_events.get(&(k.to_string().into(), s.to_owned())), @@ -460,7 +460,7 @@ impl Service { debug!("Upgrading to timeline pdu"); let timer = tokio::time::Instant::now(); - let room_version_id = self.get_room_version_id(create_event)?; + let room_version_id = Self::get_room_version_id(create_event)?; // 10. Fetch missing state and auth chain events by calling /state_ids at // backwards extremities doing all the checks in this list starting at 1. @@ -488,7 +488,7 @@ impl Service { } let state_at_incoming_event = state_at_incoming_event.expect("we always set this to some above"); - let room_version = self.to_room_version(&room_version_id); + let room_version = Self::to_room_version(&room_version_id); debug!("Performing auth check"); // 11. Check the auth of the event passes based on the state of the event @@ -1221,7 +1221,7 @@ impl Service { .await .pop() { - self.check_room_id(room_id, &pdu)?; + Self::check_room_id(room_id, &pdu)?; if amount > services().globals.max_fetch_prev_events() { // Max limit reached @@ -1329,7 +1329,7 @@ impl Service { } } - fn check_room_id(&self, room_id: &RoomId, pdu: &PduEvent) -> Result<()> { + fn check_room_id(room_id: &RoomId, pdu: &PduEvent) -> Result<()> { if pdu.room_id != room_id { warn!("Found event from room {} in room {}", pdu.room_id, room_id); return Err(Error::BadRequest(ErrorKind::InvalidParam, "Event has wrong room id")); @@ -1337,7 +1337,7 @@ impl Service { Ok(()) } - fn get_room_version_id(&self, create_event: &PduEvent) -> Result { + fn get_room_version_id(create_event: &PduEvent) -> Result { let create_event_content: RoomCreateEventContent = serde_json::from_str(create_event.content.get()).map_err(|e| { error!("Invalid create event: {}", e); @@ -1347,7 +1347,7 @@ impl Service { Ok(create_event_content.room_version) } - fn to_room_version(&self, room_version_id: &RoomVersionId) -> RoomVersion { + fn to_room_version(room_version_id: &RoomVersionId) -> RoomVersion { RoomVersion::new(room_version_id).expect("room version is supported") } } diff --git a/src/service/rooms/typing/mod.rs b/src/service/rooms/typing/mod.rs index 37876f3f..0b89dfdd 100644 --- a/src/service/rooms/typing/mod.rs +++ b/src/service/rooms/typing/mod.rs @@ -44,7 +44,7 @@ impl Service { // update federation if user_is_local(user_id) { - self.federation_send(room_id, user_id, true)?; + Self::federation_send(room_id, user_id, true)?; } Ok(()) @@ -70,7 +70,7 @@ impl Service { // update federation if user_is_local(user_id) { - self.federation_send(room_id, user_id, false)?; + Self::federation_send(room_id, user_id, false)?; } Ok(()) @@ -126,7 +126,7 @@ impl Service { // update federation for user in removable { if user_is_local(&user) { - self.federation_send(room_id, &user, false)?; + Self::federation_send(room_id, &user, false)?; } } } @@ -163,7 +163,7 @@ impl Service { }) } - fn federation_send(&self, room_id: &RoomId, user_id: &UserId, typing: bool) -> Result<()> { + fn federation_send(room_id: &RoomId, user_id: &UserId, typing: bool) -> Result<()> { debug_assert!(user_is_local(user_id), "tried to broadcast typing status of remote user",); if !services().globals.config.allow_outgoing_typing { return Ok(()); diff --git a/src/service/sending/sender.rs b/src/service/sending/sender.rs index 3d1d89da..9e107df8 100644 --- a/src/service/sending/sender.rs +++ b/src/service/sending/sender.rs @@ -80,12 +80,12 @@ impl Service { ) { match response { Ok(dest) => self.handle_response_ok(&dest, futures, statuses), - Err((dest, e)) => self.handle_response_err(dest, futures, statuses, &e), + Err((dest, e)) => Self::handle_response_err(dest, futures, statuses, &e), }; } fn handle_response_err( - &self, dest: Destination, _futures: &mut SendingFutures<'_>, statuses: &mut CurTransactionStatus, e: &Error, + dest: Destination, _futures: &mut SendingFutures<'_>, statuses: &mut CurTransactionStatus, e: &Error, ) { debug!(dest = ?dest, "{e:?}"); statuses.entry(dest).and_modify(|e| {