Fix uninlined-format-args
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
14039d9df4
commit
9e51525c25
14 changed files with 59 additions and 123 deletions
|
@ -47,7 +47,7 @@ pub(crate) async fn show(_body: Vec<&str>, appservice_identifier: String) -> Res
|
||||||
{
|
{
|
||||||
Some(config) => {
|
Some(config) => {
|
||||||
let config_str = serde_yaml::to_string(&config).expect("config should've been validated on register");
|
let config_str = serde_yaml::to_string(&config).expect("config should've been validated on register");
|
||||||
let output = format!("Config for {}:\n\n```yaml\n{}\n```", appservice_identifier, config_str,);
|
let output = format!("Config for {appservice_identifier}:\n\n```yaml\n{config_str}\n```",);
|
||||||
let output_html = format!(
|
let output_html = format!(
|
||||||
"Config for {}:\n\n<pre><code class=\"language-yaml\">{}</code></pre>",
|
"Config for {}:\n\n<pre><code class=\"language-yaml\">{}</code></pre>",
|
||||||
escape_html(&appservice_identifier),
|
escape_html(&appservice_identifier),
|
||||||
|
|
|
@ -294,8 +294,7 @@ pub(crate) async fn ping(_body: Vec<&str>, server: Box<ServerName>) -> Result<Ro
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_plain(format!(
|
Ok(RoomMessageEventContent::text_plain(format!(
|
||||||
"Got non-JSON response which took {ping_time:?} time:\n{0:?}",
|
"Got non-JSON response which took {ping_time:?} time:\n{response:?}"
|
||||||
response
|
|
||||||
)))
|
)))
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
|
@ -17,9 +17,8 @@ pub(crate) async fn check_all_users(_body: Vec<&str>) -> Result<RoomMessageEvent
|
||||||
let ok_count = users.iter().filter(|user| user.is_ok()).count();
|
let ok_count = users.iter().filter(|user| user.is_ok()).count();
|
||||||
|
|
||||||
let message = format!(
|
let message = format!(
|
||||||
"Database query completed in {query_time:?}:\n\n```\nTotal entries: {:?}\nFailure/Invalid user count: \
|
"Database query completed in {query_time:?}:\n\n```\nTotal entries: {total:?}\nFailure/Invalid user count: \
|
||||||
{:?}\nSuccess/Valid user count: {:?}```",
|
{err_count:?}\nSuccess/Valid user count: {ok_count:?}```"
|
||||||
total, err_count, ok_count
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::notice_html(message, String::new()))
|
Ok(RoomMessageEventContent::notice_html(message, String::new()))
|
||||||
|
|
|
@ -19,11 +19,8 @@ pub(crate) async fn account_data(subcommand: AccountData) -> Result<RoomMessageE
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", results),
|
format!("Query completed in {query_time:?}:\n\n```\n{results:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{results:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
results
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
AccountData::Get {
|
AccountData::Get {
|
||||||
|
@ -39,11 +36,8 @@ pub(crate) async fn account_data(subcommand: AccountData) -> Result<RoomMessageE
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", results),
|
format!("Query completed in {query_time:?}:\n\n```\n{results:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{results:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
results
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,8 @@ pub(crate) async fn appservice(subcommand: Appservice) -> Result<RoomMessageEven
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", results),
|
format!("Query completed in {query_time:?}:\n\n```\n{results:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{results:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
results
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
Appservice::All => {
|
Appservice::All => {
|
||||||
|
@ -30,11 +27,8 @@ pub(crate) async fn appservice(subcommand: Appservice) -> Result<RoomMessageEven
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", results),
|
format!("Query completed in {query_time:?}:\n\n```\n{results:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{results:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
results
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,8 @@ pub(crate) async fn globals(subcommand: Globals) -> Result<RoomMessageEventConte
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", results),
|
format!("Query completed in {query_time:?}:\n\n```\n{results:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{results:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
results
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
Globals::CurrentCount => {
|
Globals::CurrentCount => {
|
||||||
|
@ -25,11 +22,8 @@ pub(crate) async fn globals(subcommand: Globals) -> Result<RoomMessageEventConte
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", results),
|
format!("Query completed in {query_time:?}:\n\n```\n{results:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{results:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
results
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
Globals::LastCheckForUpdatesId => {
|
Globals::LastCheckForUpdatesId => {
|
||||||
|
@ -38,11 +32,8 @@ pub(crate) async fn globals(subcommand: Globals) -> Result<RoomMessageEventConte
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", results),
|
format!("Query completed in {query_time:?}:\n\n```\n{results:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{results:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
results
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
Globals::LoadKeypair => {
|
Globals::LoadKeypair => {
|
||||||
|
@ -51,11 +42,8 @@ pub(crate) async fn globals(subcommand: Globals) -> Result<RoomMessageEventConte
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", results),
|
format!("Query completed in {query_time:?}:\n\n```\n{results:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{results:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
results
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
Globals::SigningKeysFor {
|
Globals::SigningKeysFor {
|
||||||
|
@ -66,11 +54,8 @@ pub(crate) async fn globals(subcommand: Globals) -> Result<RoomMessageEventConte
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", results),
|
format!("Query completed in {query_time:?}:\n\n```\n{results:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{results:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
results
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,8 @@ pub(crate) async fn presence(subcommand: Presence) -> Result<RoomMessageEventCon
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", results),
|
format!("Query completed in {query_time:?}:\n\n```\n{results:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{results:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
results
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
Presence::PresenceSince {
|
Presence::PresenceSince {
|
||||||
|
@ -31,11 +28,8 @@ pub(crate) async fn presence(subcommand: Presence) -> Result<RoomMessageEventCon
|
||||||
let presence_since: Vec<(_, _, _)> = results.collect();
|
let presence_since: Vec<(_, _, _)> = results.collect();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", presence_since),
|
format!("Query completed in {query_time:?}:\n\n```\n{presence_since:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{presence_since:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
presence_since
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,8 @@ pub(crate) async fn room_alias(subcommand: RoomAlias) -> Result<RoomMessageEvent
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", results),
|
format!("Query completed in {query_time:?}:\n\n```\n{results:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{results:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
results
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
RoomAlias::LocalAliasesForRoom {
|
RoomAlias::LocalAliasesForRoom {
|
||||||
|
@ -31,11 +28,8 @@ pub(crate) async fn room_alias(subcommand: RoomAlias) -> Result<RoomMessageEvent
|
||||||
let aliases: Vec<_> = results.collect();
|
let aliases: Vec<_> = results.collect();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", aliases),
|
format!("Query completed in {query_time:?}:\n\n```\n{aliases:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{aliases:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
aliases
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
RoomAlias::AllLocalAliases => {
|
RoomAlias::AllLocalAliases => {
|
||||||
|
@ -46,11 +40,8 @@ pub(crate) async fn room_alias(subcommand: RoomAlias) -> Result<RoomMessageEvent
|
||||||
let aliases: Vec<_> = results.collect();
|
let aliases: Vec<_> = results.collect();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", aliases),
|
format!("Query completed in {query_time:?}:\n\n```\n{aliases:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{aliases:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
aliases
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,8 @@ pub(crate) async fn sending(subcommand: Sending) -> Result<RoomMessageEventConte
|
||||||
let active_requests: Result<Vec<(_, _, _)>> = results.collect();
|
let active_requests: Result<Vec<(_, _, _)>> = results.collect();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", active_requests),
|
format!("Query completed in {query_time:?}:\n\n```\n{active_requests:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{active_requests:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
active_requests
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
Sending::QueuedRequests {
|
Sending::QueuedRequests {
|
||||||
|
@ -96,11 +93,8 @@ pub(crate) async fn sending(subcommand: Sending) -> Result<RoomMessageEventConte
|
||||||
let queued_requests = results.collect::<Result<Vec<(_, _)>>>();
|
let queued_requests = results.collect::<Result<Vec<(_, _)>>>();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", queued_requests),
|
format!("Query completed in {query_time:?}:\n\n```\n{queued_requests:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{queued_requests:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
queued_requests
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
Sending::ActiveRequestsFor {
|
Sending::ActiveRequestsFor {
|
||||||
|
@ -178,11 +172,8 @@ pub(crate) async fn sending(subcommand: Sending) -> Result<RoomMessageEventConte
|
||||||
let active_requests = results.collect::<Result<Vec<(_, _)>>>();
|
let active_requests = results.collect::<Result<Vec<(_, _)>>>();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", active_requests),
|
format!("Query completed in {query_time:?}:\n\n```\n{active_requests:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{active_requests:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
active_requests
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
Sending::GetLatestEduCount {
|
Sending::GetLatestEduCount {
|
||||||
|
@ -193,11 +184,8 @@ pub(crate) async fn sending(subcommand: Sending) -> Result<RoomMessageEventConte
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", results),
|
format!("Query completed in {query_time:?}:\n\n```\n{results:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{results:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
results
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,8 @@ pub(crate) async fn users(subcommand: Users) -> Result<RoomMessageEventContent>
|
||||||
let users = results.collect::<Vec<_>>();
|
let users = results.collect::<Vec<_>>();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", users),
|
format!("Query completed in {query_time:?}:\n\n```\n{users:?}```"),
|
||||||
format!(
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{users:?}\n</code></pre>"),
|
||||||
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
|
|
||||||
users
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub(crate) async fn process(command: RoomAliasCommand, _body: Vec<&str>) -> Resu
|
||||||
let room_alias_str = format!("#{}:{}", room_alias_localpart, services().globals.server_name());
|
let room_alias_str = format!("#{}:{}", room_alias_localpart, services().globals.server_name());
|
||||||
let room_alias = match RoomAliasId::parse_box(room_alias_str) {
|
let room_alias = match RoomAliasId::parse_box(room_alias_str) {
|
||||||
Ok(alias) => alias,
|
Ok(alias) => alias,
|
||||||
Err(err) => return Ok(RoomMessageEventContent::text_plain(format!("Failed to parse alias: {}", err))),
|
Err(err) => return Ok(RoomMessageEventContent::text_plain(format!("Failed to parse alias: {err}"))),
|
||||||
};
|
};
|
||||||
match command {
|
match command {
|
||||||
RoomAliasCommand::Set {
|
RoomAliasCommand::Set {
|
||||||
|
@ -30,14 +30,12 @@ pub(crate) async fn process(command: RoomAliasCommand, _body: Vec<&str>) -> Resu
|
||||||
} => match (force, services().rooms.alias.resolve_local_alias(&room_alias)) {
|
} => match (force, services().rooms.alias.resolve_local_alias(&room_alias)) {
|
||||||
(true, Ok(Some(id))) => match services().rooms.alias.set_alias(&room_alias, &room_id) {
|
(true, Ok(Some(id))) => match services().rooms.alias.set_alias(&room_alias, &room_id) {
|
||||||
Ok(()) => Ok(RoomMessageEventContent::text_plain(format!(
|
Ok(()) => Ok(RoomMessageEventContent::text_plain(format!(
|
||||||
"Successfully overwrote alias (formerly {})",
|
"Successfully overwrote alias (formerly {id})"
|
||||||
id
|
|
||||||
))),
|
))),
|
||||||
Err(err) => Ok(RoomMessageEventContent::text_plain(format!("Failed to remove alias: {}", err))),
|
Err(err) => Ok(RoomMessageEventContent::text_plain(format!("Failed to remove alias: {err}"))),
|
||||||
},
|
},
|
||||||
(false, Ok(Some(id))) => Ok(RoomMessageEventContent::text_plain(format!(
|
(false, Ok(Some(id))) => Ok(RoomMessageEventContent::text_plain(format!(
|
||||||
"Refusing to overwrite in use alias for {}, use -f or --force to overwrite",
|
"Refusing to overwrite in use alias for {id}, use -f or --force to overwrite"
|
||||||
id
|
|
||||||
))),
|
))),
|
||||||
(_, Ok(None)) => match services().rooms.alias.set_alias(&room_alias, &room_id) {
|
(_, Ok(None)) => match services().rooms.alias.set_alias(&room_alias, &room_id) {
|
||||||
Ok(()) => Ok(RoomMessageEventContent::text_plain("Successfully set alias")),
|
Ok(()) => Ok(RoomMessageEventContent::text_plain("Successfully set alias")),
|
||||||
|
@ -49,18 +47,18 @@ pub(crate) async fn process(command: RoomAliasCommand, _body: Vec<&str>) -> Resu
|
||||||
..
|
..
|
||||||
} => match services().rooms.alias.resolve_local_alias(&room_alias) {
|
} => match services().rooms.alias.resolve_local_alias(&room_alias) {
|
||||||
Ok(Some(id)) => match services().rooms.alias.remove_alias(&room_alias) {
|
Ok(Some(id)) => match services().rooms.alias.remove_alias(&room_alias) {
|
||||||
Ok(()) => Ok(RoomMessageEventContent::text_plain(format!("Removed alias from {}", id))),
|
Ok(()) => Ok(RoomMessageEventContent::text_plain(format!("Removed alias from {id}"))),
|
||||||
Err(err) => Ok(RoomMessageEventContent::text_plain(format!("Failed to remove alias: {}", err))),
|
Err(err) => Ok(RoomMessageEventContent::text_plain(format!("Failed to remove alias: {err}"))),
|
||||||
},
|
},
|
||||||
Ok(None) => Ok(RoomMessageEventContent::text_plain("Alias isn't in use.")),
|
Ok(None) => Ok(RoomMessageEventContent::text_plain("Alias isn't in use.")),
|
||||||
Err(err) => Ok(RoomMessageEventContent::text_plain(format!("Unable to lookup alias: {}", err))),
|
Err(err) => Ok(RoomMessageEventContent::text_plain(format!("Unable to lookup alias: {err}"))),
|
||||||
},
|
},
|
||||||
RoomAliasCommand::Which {
|
RoomAliasCommand::Which {
|
||||||
..
|
..
|
||||||
} => match services().rooms.alias.resolve_local_alias(&room_alias) {
|
} => match services().rooms.alias.resolve_local_alias(&room_alias) {
|
||||||
Ok(Some(id)) => Ok(RoomMessageEventContent::text_plain(format!("Alias resolves to {}", id))),
|
Ok(Some(id)) => Ok(RoomMessageEventContent::text_plain(format!("Alias resolves to {id}"))),
|
||||||
Ok(None) => Ok(RoomMessageEventContent::text_plain("Alias isn't in use.")),
|
Ok(None) => Ok(RoomMessageEventContent::text_plain("Alias isn't in use.")),
|
||||||
Err(err) => Ok(RoomMessageEventContent::text_plain(format!("Unable to lookup alias: {}", err))),
|
Err(err) => Ok(RoomMessageEventContent::text_plain(format!("Unable to lookup alias: {err}"))),
|
||||||
},
|
},
|
||||||
RoomAliasCommand::List {
|
RoomAliasCommand::List {
|
||||||
..
|
..
|
||||||
|
@ -93,7 +91,7 @@ pub(crate) async fn process(command: RoomAliasCommand, _body: Vec<&str>) -> Resu
|
||||||
let html = format!("Aliases for {room_id}:\n<ul>{html_list}</ul>");
|
let html = format!("Aliases for {room_id}:\n<ul>{html_list}</ul>");
|
||||||
Ok(RoomMessageEventContent::text_html(plain, html))
|
Ok(RoomMessageEventContent::text_html(plain, html))
|
||||||
},
|
},
|
||||||
Err(err) => Ok(RoomMessageEventContent::text_plain(format!("Unable to list aliases: {}", err))),
|
Err(err) => Ok(RoomMessageEventContent::text_plain(format!("Unable to list aliases: {err}"))),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let aliases = services()
|
let aliases = services()
|
||||||
|
|
|
@ -481,7 +481,7 @@ pub(crate) async fn process(command: RoomModerationCommand, body: Vec<&str>) ->
|
||||||
// as the room name if we dont have it TODO: do same if we have a room alias for
|
// as the room name if we dont have it TODO: do same if we have a room alias for
|
||||||
// this
|
// this
|
||||||
let plain_list = room_ids.iter().fold(String::new(), |mut output, room_id| {
|
let plain_list = room_ids.iter().fold(String::new(), |mut output, room_id| {
|
||||||
writeln!(output, "- `{}`", room_id).unwrap();
|
writeln!(output, "- `{room_id}`").unwrap();
|
||||||
output
|
output
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -490,16 +490,13 @@ pub(crate) async fn process(command: RoomModerationCommand, body: Vec<&str>) ->
|
||||||
output
|
output
|
||||||
});
|
});
|
||||||
|
|
||||||
let plain = format!("Rooms:\n{}", plain_list);
|
let plain = format!("Rooms:\n{plain_list}");
|
||||||
let html = format!("Rooms:\n<ul>{}</ul>", html_list);
|
let html = format!("Rooms:\n<ul>{html_list}</ul>");
|
||||||
Ok(RoomMessageEventContent::text_html(plain, html))
|
Ok(RoomMessageEventContent::text_html(plain, html))
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to list banned rooms: {}", e);
|
error!("Failed to list banned rooms: {}", e);
|
||||||
Ok(RoomMessageEventContent::text_plain(format!(
|
Ok(RoomMessageEventContent::text_plain(format!("Unable to list room aliases: {e}")))
|
||||||
"Unable to list room aliases: {}",
|
|
||||||
e
|
|
||||||
)))
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -135,7 +135,7 @@ impl From<Infallible> for Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Error {
|
impl fmt::Debug for Error {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self) }
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{self}") }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
|
@ -127,9 +127,9 @@ mod tests {
|
||||||
};
|
};
|
||||||
|
|
||||||
// cargo test -- --nocapture
|
// cargo test -- --nocapture
|
||||||
println!("{}", SAMPLE);
|
println!("{SAMPLE}");
|
||||||
println!("{}", sanitize_filename::sanitize_with_options(SAMPLE, options.clone()));
|
println!("{}", sanitize_filename::sanitize_with_options(SAMPLE, options.clone()));
|
||||||
println!("{:?}", SAMPLE);
|
println!("{SAMPLE:?}");
|
||||||
println!("{:?}", sanitize_filename::sanitize_with_options(SAMPLE, options.clone()));
|
println!("{:?}", sanitize_filename::sanitize_with_options(SAMPLE, options.clone()));
|
||||||
|
|
||||||
assert_eq!(SANITISED, sanitize_filename::sanitize_with_options(SAMPLE, options.clone()));
|
assert_eq!(SANITISED, sanitize_filename::sanitize_with_options(SAMPLE, options.clone()));
|
||||||
|
|
Loading…
Add table
Reference in a new issue