Fix unused-self

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-06-02 00:25:22 +00:00 committed by June 🍓🦴
parent e5eccb3a0c
commit 0f3d43153b
4 changed files with 20 additions and 20 deletions

View file

@ -411,7 +411,7 @@ impl Config {
}; };
// don't start if we're listening on both UNIX sockets and TCP at same time // 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.")); 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 /// Checks the presence of the `address` and `unix_socket_path` keys in the
/// raw_config, exiting the process if both keys were detected. /// 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_address = raw_config.find_value("address");
let check_unix_socket = raw_config.find_value("unix_socket_path"); let check_unix_socket = raw_config.find_value("unix_socket_path");

View file

@ -118,7 +118,7 @@ impl Service {
.ok_or_else(|| Error::bad_database("Failed to find create event in db."))?; .ok_or_else(|| Error::bad_database("Failed to find create event in db."))?;
// Procure the room version // 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() let first_pdu_in_room = services()
.rooms .rooms
@ -130,7 +130,7 @@ impl Service {
.handle_outlier_pdu(origin, &create_event, event_id, room_id, value, false, pub_key_map) .handle_outlier_pdu(origin, &create_event, event_id, room_id, value, false, pub_key_map)
.await?; .await?;
self.check_room_id(room_id, &incoming_pdu)?; Self::check_room_id(room_id, &incoming_pdu)?;
// 8. if not timeline event: stop // 8. if not timeline event: stop
if !is_timeline_event { if !is_timeline_event {
@ -308,7 +308,7 @@ impl Service {
// 2. Check signatures, otherwise drop // 2. Check signatures, otherwise drop
// 3. check content hash, redact if doesn't match // 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 guard = pub_key_map.read().await;
let mut val = match ruma::signatures::verify_event(&guard, &value, &room_version_id) { 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."))?; .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 { if !auth_events_known {
// 4. fetch any missing auth events doing all checks listed here starting at 1. // 4. fetch any missing auth events doing all checks listed here starting at 1.
@ -382,7 +382,7 @@ impl Service {
continue; continue;
}; };
self.check_room_id(room_id, &auth_event)?; Self::check_room_id(room_id, &auth_event)?;
match auth_events.entry(( match auth_events.entry((
auth_event.kind.to_string().into(), auth_event.kind.to_string().into(),
@ -417,7 +417,7 @@ impl Service {
} }
if !state_res::event_auth::auth_check( if !state_res::event_auth::auth_check(
&self.to_room_version(&room_version_id), &Self::to_room_version(&room_version_id),
&incoming_pdu, &incoming_pdu,
None::<PduEvent>, // TODO: third party invite None::<PduEvent>, // TODO: third party invite
|k, s| auth_events.get(&(k.to_string().into(), s.to_owned())), |k, s| auth_events.get(&(k.to_string().into(), s.to_owned())),
@ -460,7 +460,7 @@ impl Service {
debug!("Upgrading to timeline pdu"); debug!("Upgrading to timeline pdu");
let timer = tokio::time::Instant::now(); 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 // 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. // 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 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"); debug!("Performing auth check");
// 11. Check the auth of the event passes based on the state of the event // 11. Check the auth of the event passes based on the state of the event
@ -1221,7 +1221,7 @@ impl Service {
.await .await
.pop() .pop()
{ {
self.check_room_id(room_id, &pdu)?; Self::check_room_id(room_id, &pdu)?;
if amount > services().globals.max_fetch_prev_events() { if amount > services().globals.max_fetch_prev_events() {
// Max limit reached // 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 { if pdu.room_id != room_id {
warn!("Found event from room {} in room {}", 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")); return Err(Error::BadRequest(ErrorKind::InvalidParam, "Event has wrong room id"));
@ -1337,7 +1337,7 @@ impl Service {
Ok(()) Ok(())
} }
fn get_room_version_id(&self, create_event: &PduEvent) -> Result<RoomVersionId> { fn get_room_version_id(create_event: &PduEvent) -> Result<RoomVersionId> {
let create_event_content: RoomCreateEventContent = let create_event_content: RoomCreateEventContent =
serde_json::from_str(create_event.content.get()).map_err(|e| { serde_json::from_str(create_event.content.get()).map_err(|e| {
error!("Invalid create event: {}", e); error!("Invalid create event: {}", e);
@ -1347,7 +1347,7 @@ impl Service {
Ok(create_event_content.room_version) 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") RoomVersion::new(room_version_id).expect("room version is supported")
} }
} }

View file

@ -44,7 +44,7 @@ impl Service {
// update federation // update federation
if user_is_local(user_id) { if user_is_local(user_id) {
self.federation_send(room_id, user_id, true)?; Self::federation_send(room_id, user_id, true)?;
} }
Ok(()) Ok(())
@ -70,7 +70,7 @@ impl Service {
// update federation // update federation
if user_is_local(user_id) { if user_is_local(user_id) {
self.federation_send(room_id, user_id, false)?; Self::federation_send(room_id, user_id, false)?;
} }
Ok(()) Ok(())
@ -126,7 +126,7 @@ impl Service {
// update federation // update federation
for user in removable { for user in removable {
if user_is_local(&user) { 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",); debug_assert!(user_is_local(user_id), "tried to broadcast typing status of remote user",);
if !services().globals.config.allow_outgoing_typing { if !services().globals.config.allow_outgoing_typing {
return Ok(()); return Ok(());

View file

@ -80,12 +80,12 @@ impl Service {
) { ) {
match response { match response {
Ok(dest) => self.handle_response_ok(&dest, futures, statuses), 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( 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:?}"); debug!(dest = ?dest, "{e:?}");
statuses.entry(dest).and_modify(|e| { statuses.entry(dest).and_modify(|e| {