cargo clippy
This commit is contained in:
parent
ca82b2940d
commit
f430b87459
32 changed files with 139 additions and 166 deletions
|
@ -179,7 +179,7 @@ impl Service {
|
|||
}
|
||||
|
||||
pub fn start_handler(self: &Arc<Self>) {
|
||||
let self2 = Arc::clone(&self);
|
||||
let self2 = Arc::clone(self);
|
||||
tokio::spawn(async move {
|
||||
self2.handler().await;
|
||||
});
|
||||
|
@ -270,13 +270,11 @@ impl Service {
|
|||
let command_line = lines.next().expect("each string has at least one line");
|
||||
let body: Vec<_> = lines.collect();
|
||||
|
||||
let admin_command = match self.parse_admin_command(&command_line) {
|
||||
let admin_command = match self.parse_admin_command(command_line) {
|
||||
Ok(command) => command,
|
||||
Err(error) => {
|
||||
let server_name = services().globals.server_name();
|
||||
let message = error
|
||||
.to_string()
|
||||
.replace("server.name", server_name.as_str());
|
||||
let message = error.replace("server.name", server_name.as_str());
|
||||
let html_message = self.usage_to_html(&message, server_name);
|
||||
|
||||
return RoomMessageEventContent::text_html(message, html_message);
|
||||
|
@ -316,8 +314,8 @@ impl Service {
|
|||
|
||||
// Backwards compatibility with `register_appservice`-style commands
|
||||
let command_with_dashes;
|
||||
if argv.len() > 1 && argv[1].contains("_") {
|
||||
command_with_dashes = argv[1].replace("_", "-");
|
||||
if argv.len() > 1 && argv[1].contains('_') {
|
||||
command_with_dashes = argv[1].replace('_', "-");
|
||||
argv[1] = &command_with_dashes;
|
||||
}
|
||||
|
||||
|
@ -631,7 +629,7 @@ impl Service {
|
|||
let displayname = format!("{} ⚡️", user_id.localpart());
|
||||
services()
|
||||
.users
|
||||
.set_displayname(&user_id, Some(displayname.clone()))?;
|
||||
.set_displayname(&user_id, Some(displayname))?;
|
||||
|
||||
// Initial account data
|
||||
services().account_data.update(
|
||||
|
@ -771,7 +769,7 @@ impl Service {
|
|||
let text = text.replace("subcommand", "command");
|
||||
|
||||
// Escape option names (e.g. `<element-id>`) since they look like HTML tags
|
||||
let text = text.replace("<", "<").replace(">", ">");
|
||||
let text = text.replace('<', "<").replace('>', ">");
|
||||
|
||||
// Italicize the first line (command name and version text)
|
||||
let re = Regex::new("^(.*?)\n").expect("Regex compilation should not fail");
|
||||
|
@ -799,7 +797,7 @@ impl Service {
|
|||
|
||||
while text_lines
|
||||
.get(line_index)
|
||||
.map(|line| line.starts_with("#"))
|
||||
.map(|line| line.starts_with('#'))
|
||||
.unwrap_or(false)
|
||||
{
|
||||
command_body += if text_lines[line_index].starts_with("# ") {
|
||||
|
@ -830,12 +828,10 @@ impl Service {
|
|||
};
|
||||
|
||||
// Add HTML line-breaks
|
||||
let text = text
|
||||
.replace("\n\n\n", "\n\n")
|
||||
.replace("\n", "<br>\n")
|
||||
.replace("[nobr]<br>", "");
|
||||
|
||||
text
|
||||
text.replace("\n\n\n", "\n\n")
|
||||
.replace('\n', "<br>\n")
|
||||
.replace("[nobr]<br>", "")
|
||||
}
|
||||
|
||||
/// Create the admin room.
|
||||
|
@ -1110,7 +1106,7 @@ impl Service {
|
|||
state_key: Some(user_id.to_string()),
|
||||
redacts: None,
|
||||
},
|
||||
&user_id,
|
||||
user_id,
|
||||
&room_id,
|
||||
&state_lock,
|
||||
)?;
|
||||
|
@ -1142,8 +1138,8 @@ impl Service {
|
|||
PduBuilder {
|
||||
event_type: RoomEventType::RoomMessage,
|
||||
content: to_raw_value(&RoomMessageEventContent::text_html(
|
||||
format!("## Thank you for trying out Conduit!\n\nConduit is currently in Beta. This means you can join and participate in most Matrix rooms, but not all features are supported and you might run into bugs from time to time.\n\nHelpful links:\n> Website: https://conduit.rs\n> Git and Documentation: https://gitlab.com/famedly/conduit\n> Report issues: https://gitlab.com/famedly/conduit/-/issues\n\nFor a list of available commands, send the following message in this room: `@conduit:{}: --help`\n\nHere are some rooms you can join (by typing the command):\n\nConduit room (Ask questions and get notified on updates):\n`/join #conduit:fachschaften.org`\n\nConduit lounge (Off-topic, only Conduit users are allowed to join)\n`/join #conduit-lounge:conduit.rs`", services().globals.server_name()).to_owned(),
|
||||
format!("<h2>Thank you for trying out Conduit!</h2>\n<p>Conduit is currently in Beta. This means you can join and participate in most Matrix rooms, but not all features are supported and you might run into bugs from time to time.</p>\n<p>Helpful links:</p>\n<blockquote>\n<p>Website: https://conduit.rs<br>Git and Documentation: https://gitlab.com/famedly/conduit<br>Report issues: https://gitlab.com/famedly/conduit/-/issues</p>\n</blockquote>\n<p>For a list of available commands, send the following message in this room: <code>@conduit:{}: --help</code></p>\n<p>Here are some rooms you can join (by typing the command):</p>\n<p>Conduit room (Ask questions and get notified on updates):<br><code>/join #conduit:fachschaften.org</code></p>\n<p>Conduit lounge (Off-topic, only Conduit users are allowed to join)<br><code>/join #conduit-lounge:conduit.rs</code></p>\n", services().globals.server_name()).to_owned(),
|
||||
format!("## Thank you for trying out Conduit!\n\nConduit is currently in Beta. This means you can join and participate in most Matrix rooms, but not all features are supported and you might run into bugs from time to time.\n\nHelpful links:\n> Website: https://conduit.rs\n> Git and Documentation: https://gitlab.com/famedly/conduit\n> Report issues: https://gitlab.com/famedly/conduit/-/issues\n\nFor a list of available commands, send the following message in this room: `@conduit:{}: --help`\n\nHere are some rooms you can join (by typing the command):\n\nConduit room (Ask questions and get notified on updates):\n`/join #conduit:fachschaften.org`\n\nConduit lounge (Off-topic, only Conduit users are allowed to join)\n`/join #conduit-lounge:conduit.rs`", services().globals.server_name()),
|
||||
format!("<h2>Thank you for trying out Conduit!</h2>\n<p>Conduit is currently in Beta. This means you can join and participate in most Matrix rooms, but not all features are supported and you might run into bugs from time to time.</p>\n<p>Helpful links:</p>\n<blockquote>\n<p>Website: https://conduit.rs<br>Git and Documentation: https://gitlab.com/famedly/conduit<br>Report issues: https://gitlab.com/famedly/conduit/-/issues</p>\n</blockquote>\n<p>For a list of available commands, send the following message in this room: <code>@conduit:{}: --help</code></p>\n<p>Here are some rooms you can join (by typing the command):</p>\n<p>Conduit room (Ask questions and get notified on updates):<br><code>/join #conduit:fachschaften.org</code></p>\n<p>Conduit lounge (Off-topic, only Conduit users are allowed to join)<br><code>/join #conduit-lounge:conduit.rs</code></p>\n", services().globals.server_name()),
|
||||
))
|
||||
.expect("event is valid, we just created it"),
|
||||
unsigned: None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue