Skip to content

Commit

Permalink
Run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
nexy7574 committed Dec 20, 2024
1 parent 94c3e85 commit 5ff0a7c
Show file tree
Hide file tree
Showing 147 changed files with 1,633 additions and 786 deletions.
27 changes: 17 additions & 10 deletions src/admin/debug/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,13 @@ pub(super) async fn get_remote_pdu(
match self
.services
.sending
.send_federation_request(&server, ruma::api::federation::event::get_event::v1::Request {
event_id: event_id.clone().into(),
include_unredacted_content: None,
})
.send_federation_request(
&server,
ruma::api::federation::event::get_event::v1::Request {
event_id: event_id.clone().into(),
include_unredacted_content: None,
},
)
.await
{
| Ok(response) => {
Expand Down Expand Up @@ -502,8 +505,9 @@ pub(super) async fn verify_pdu(&self, event_id: Box<EventId>) -> Result<RoomMess

event.remove("event_id");
let msg = match self.services.server_keys.verify_event(&event, None).await {
| Ok(ruma::signatures::Verified::Signatures) =>
"signatures OK, but content hash failed (redaction).",
| Ok(ruma::signatures::Verified::Signatures) => {
"signatures OK, but content hash failed (redaction)."
},
| Ok(ruma::signatures::Verified::All) => "signatures and hashes OK.",
| Err(e) => return Err(e),
};
Expand Down Expand Up @@ -603,10 +607,13 @@ pub(super) async fn force_set_room_state_from_server(
let remote_state_response = self
.services
.sending
.send_federation_request(&server_name, get_room_state::v1::Request {
room_id: room_id.clone().into(),
event_id: first_pdu.event_id.clone().into(),
})
.send_federation_request(
&server_name,
get_room_state::v1::Request {
room_id: room_id.clone().into(),
event_id: first_pdu.event_id.clone().into(),
},
)
.await?;

for pdu in remote_state_response.pdus.clone() {
Expand Down
4 changes: 2 additions & 2 deletions src/admin/media/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ pub(super) enum MediaCommand {
/// filesystem. This will always ignore errors.
DeleteList,

/// - Deletes all remote (and optionally local) media created before or after
/// [duration] time using filesystem metadata first created at date,
/// - Deletes all remote (and optionally local) media created before or after
/// [duration] time using filesystem metadata first created at date,
/// or fallback to last modified date.
/// This will always ignore errors by default.
DeletePastRemoteMedia {
Expand Down
4 changes: 3 additions & 1 deletion src/admin/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ use tracing_subscriber::{filter::LevelFilter, EnvFilter};
use crate::{admin, admin::AdminCommand, Command};

#[must_use]
pub(super) fn complete(line: &str) -> String { complete_command(AdminCommand::command(), line) }
pub(super) fn complete(line: &str) -> String {
complete_command(AdminCommand::command(), line)
}

#[must_use]
pub(super) fn dispatch(services: Arc<Services>, command: CommandInput) -> ProcessorFuture {
Expand Down
35 changes: 21 additions & 14 deletions src/admin/room/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ pub(super) async fn process(
format!("#{}:{}", room_alias_localpart, services.globals.server_name());
let room_alias = match RoomAliasId::parse_box(room_alias_str) {
| Ok(alias) => alias,
| Err(err) =>
| Err(err) => {
return Ok(RoomMessageEventContent::text_plain(format!(
"Failed to parse alias: {err}"
))),
)))
},
};
match command {
| RoomAliasCommand::Set { force, room_id, .. } =>
| RoomAliasCommand::Set { force, room_id, .. } => {
match (force, services.rooms.alias.resolve_local_alias(&room_alias).await) {
| (true, Ok(id)) => {
match services.rooms.alias.set_alias(
Expand Down Expand Up @@ -100,8 +101,9 @@ pub(super) async fn process(
))),
}
},
},
| RoomAliasCommand::Remove { .. } =>
}
},
| RoomAliasCommand::Remove { .. } => {
match services.rooms.alias.resolve_local_alias(&room_alias).await {
| Ok(id) => match services
.rooms
Expand All @@ -116,21 +118,25 @@ pub(super) async fn process(
"Failed to remove alias: {err}"
))),
},
| Err(_) =>
Ok(RoomMessageEventContent::text_plain("Alias isn't in use.")),
},
| RoomAliasCommand::Which { .. } =>
| Err(_) => {
Ok(RoomMessageEventContent::text_plain("Alias isn't in use."))
},
}
},
| RoomAliasCommand::Which { .. } => {
match services.rooms.alias.resolve_local_alias(&room_alias).await {
| Ok(id) => Ok(RoomMessageEventContent::text_plain(format!(
"Alias resolves to {id}"
))),
| Err(_) =>
Ok(RoomMessageEventContent::text_plain("Alias isn't in use.")),
},
| Err(_) => {
Ok(RoomMessageEventContent::text_plain("Alias isn't in use."))
},
}
},
| RoomAliasCommand::List { .. } => unreachable!(),
}
},
| RoomAliasCommand::List { room_id } =>
| RoomAliasCommand::List { room_id } => {
if let Some(room_id) = room_id {
let aliases: Vec<OwnedRoomAliasId> = services
.rooms
Expand Down Expand Up @@ -190,6 +196,7 @@ pub(super) async fn process(
let plain = format!("Aliases:\n{plain_list}");
let html = format!("Aliases:\n<ul>{html_list}</ul>");
Ok(RoomMessageEventContent::text_html(plain, html))
},
}
},
}
}
20 changes: 12 additions & 8 deletions src/admin/room/moderation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@ async fn ban_room(
let room_id = if room.is_room_id() {
let room_id = match RoomId::parse(&room) {
| Ok(room_id) => room_id,
| Err(e) =>
| Err(e) => {
return Ok(RoomMessageEventContent::text_plain(format!(
"Failed to parse room ID {room}. Please note that this requires a full room \
ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
(`#roomalias:example.com`): {e}"
))),
)))
},
};

debug!("Room specified is a room ID, banning room ID");
Expand All @@ -112,12 +113,13 @@ async fn ban_room(
} else if room.is_room_alias_id() {
let room_alias = match RoomAliasId::parse(&room) {
| Ok(room_alias) => room_alias,
| Err(e) =>
| Err(e) => {
return Ok(RoomMessageEventContent::text_plain(format!(
"Failed to parse room ID {room}. Please note that this requires a full room \
ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
(`#roomalias:example.com`): {e}"
))),
)))
},
};

debug!(
Expand Down Expand Up @@ -510,12 +512,13 @@ async fn unban_room(
let room_id = if room.is_room_id() {
let room_id = match RoomId::parse(&room) {
| Ok(room_id) => room_id,
| Err(e) =>
| Err(e) => {
return Ok(RoomMessageEventContent::text_plain(format!(
"Failed to parse room ID {room}. Please note that this requires a full room \
ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
(`#roomalias:example.com`): {e}"
))),
)))
},
};

debug!("Room specified is a room ID, unbanning room ID");
Expand All @@ -526,12 +529,13 @@ async fn unban_room(
} else if room.is_room_alias_id() {
let room_alias = match RoomAliasId::parse(&room) {
| Ok(room_alias) => room_alias,
| Err(e) =>
| Err(e) => {
return Ok(RoomMessageEventContent::text_plain(format!(
"Failed to parse room ID {room}. Please note that this requires a full room \
ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
(`#roomalias:example.com`): {e}"
))),
)))
},
};

debug!(
Expand Down
12 changes: 9 additions & 3 deletions src/admin/tests.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#![cfg(test)]

#[test]
fn get_help_short() { get_help_inner("-h"); }
fn get_help_short() {
get_help_inner("-h");
}

#[test]
fn get_help_long() { get_help_inner("--help"); }
fn get_help_long() {
get_help_inner("--help");
}

#[test]
fn get_help_subcommand() { get_help_inner("help"); }
fn get_help_subcommand() {
get_help_inner("help");
}

fn get_help_inner(input: &str) {
use clap::Parser;
Expand Down
5 changes: 3 additions & 2 deletions src/api/client/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,9 @@ pub(crate) async fn get_public_rooms_filtered_helper(
let backwards = match characters.next() {
| Some('n') => false,
| Some('p') => true,
| _ =>
return Err(Error::BadRequest(ErrorKind::InvalidParam, "Invalid `since` token")),
| _ => {
return Err(Error::BadRequest(ErrorKind::InvalidParam, "Invalid `since` token"))
},
};

num_since = characters
Expand Down
9 changes: 6 additions & 3 deletions src/api/client/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,12 @@ pub(crate) async fn claim_keys_helper(
server,
services
.sending
.send_federation_request(server, federation::keys::claim_keys::v1::Request {
one_time_keys: one_time_keys_input_fed,
})
.send_federation_request(
server,
federation::keys::claim_keys::v1::Request {
one_time_keys: one_time_keys_input_fed,
},
)
.await,
)
})
Expand Down
Loading

0 comments on commit 5ff0a7c

Please sign in to comment.