Skip to content

Commit 935e8cd

Browse files
committed
fix(warnings): fix all warnings and remove dead code
1 parent f53e473 commit 935e8cd

32 files changed

Lines changed: 111 additions & 675 deletions

File tree

rustmail/src/api/handler/auth/callback.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ pub struct AuthRequest {
1717
#[derive(serde::Deserialize, Debug)]
1818
struct DiscordUser {
1919
id: String,
20-
username: String,
21-
discriminator: String,
20+
_username: String,
21+
_discriminator: String,
2222
avatar: Option<String>,
2323
}
2424

rustmail/src/api/handler/panel/panel.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use axum::response::IntoResponse;
44
use std::sync::Arc;
55
use tokio::sync::Mutex;
66

7-
pub async fn handle_panel_check(
8-
State(bot_state): State<Arc<Mutex<BotState>>>,
9-
) -> impl IntoResponse {
7+
pub async fn handle_panel_check(State(..): State<Arc<Mutex<BotState>>>) -> impl IntoResponse {
108
axum::response::Json(serde_json::json!({ "authorized": true }))
119
}

rustmail/src/bot.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ pub async fn run_bot(
235235

236236
let _ = resp.send(is_member);
237237
}
238-
_ => {}
239238
}
240239
}
241240

rustmail/src/commands/alert/common.rs

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,14 @@ use serenity::all::{CommandInteraction, Context, CreateInteractionResponse, Mess
77
use std::collections::HashMap;
88

99
pub async fn get_thread_user_id_from_msg(
10-
ctx: &Context,
1110
msg: &Message,
12-
config: &Config,
1311
pool: &sqlx::SqlitePool,
1412
) -> ModmailResult<i64> {
1513
let channel_id = msg.channel_id.to_string();
1614

1715
match get_user_id_from_channel_id(&channel_id, pool).await {
1816
Some(uid) => Ok(uid),
19-
None => {
20-
send_alert_message(ctx, msg, config, "alert.not_in_thread", None).await;
21-
Err(common::validation_failed("Not in a thread"))
22-
}
17+
None => Err(ModmailError::Command(CommandError::NotInThread())),
2318
}
2419
}
2520

@@ -78,7 +73,18 @@ pub async fn handle_cancel_alert_from_msg(
7873
let mut params = HashMap::new();
7974
params.insert("user".to_string(), format!("<@{}>", user_id));
8075

81-
send_alert_message(ctx, msg, config, "alert.cancel_confirmation", Some(&params)).await;
76+
let _ = MessageBuilder::system_message(ctx, config)
77+
.translated_content(
78+
"alert.cancel_confirmation",
79+
Some(&params),
80+
Some(msg.author.id),
81+
msg.guild_id.map(|g| g.get()),
82+
)
83+
.await
84+
.to_channel(msg.channel_id)
85+
.send(true)
86+
.await;
87+
8288
Ok(())
8389
}
8490

@@ -120,15 +126,25 @@ pub async fn handle_set_alert_from_msg(
120126
user_id: i64,
121127
pool: &sqlx::SqlitePool,
122128
) -> ModmailResult<()> {
123-
if let Err(e) = set_alert_for_staff(msg.author.id, user_id, pool).await {
124-
send_alert_message(ctx, msg, config, "alert.set_failed", None).await;
125-
return Ok(());
129+
if let Err(..) = set_alert_for_staff(msg.author.id, user_id, pool).await {
130+
return Err(ModmailError::Command(CommandError::AlertSetFailed));
126131
}
127132

128133
let mut params = HashMap::new();
129134
params.insert("user".to_string(), format!("<@{}>", user_id));
130135

131-
send_alert_message(ctx, msg, config, "alert.confirmation", Some(&params)).await;
136+
let _ = MessageBuilder::system_message(ctx, config)
137+
.translated_content(
138+
"alert.confirmation",
139+
Some(&params),
140+
Some(msg.author.id),
141+
msg.guild_id.map(|g| g.get()),
142+
)
143+
.await
144+
.to_channel(msg.channel_id)
145+
.send(true)
146+
.await;
147+
132148
Ok(())
133149
}
134150

@@ -165,26 +181,6 @@ pub async fn handle_set_alert_from_command(
165181
}
166182
}
167183

168-
pub async fn send_alert_message(
169-
ctx: &Context,
170-
msg: &Message,
171-
config: &Config,
172-
message_key: &str,
173-
params: Option<&HashMap<String, String>>,
174-
) {
175-
let _ = MessageBuilder::system_message(ctx, config)
176-
.translated_content(
177-
message_key,
178-
params,
179-
Some(msg.author.id),
180-
msg.guild_id.map(|g| g.get()),
181-
)
182-
.await
183-
.to_channel(msg.channel_id)
184-
.send(true)
185-
.await;
186-
}
187-
188184
pub async fn extract_alert_action(msg: &Message, config: &Config) -> bool {
189185
let content = msg.content.trim();
190186
let prefix = &config.command.prefix;

rustmail/src/commands/alert/text_command/alert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub async fn alert(
1616
.as_ref()
1717
.ok_or_else(database_connection_failed)?;
1818

19-
let user_id = get_thread_user_id_from_msg(&ctx, &msg, config, pool).await?;
19+
let user_id = get_thread_user_id_from_msg(&msg, pool).await?;
2020
let is_cancel = extract_alert_action(&msg, config).await;
2121

2222
if is_cancel {

rustmail/src/commands/delete/common.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::prelude::commands::*;
21
use crate::prelude::config::*;
32
use crate::prelude::db::*;
43
use crate::prelude::errors::*;

rustmail/src/commands/edit/message_ops.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::prelude::commands::*;
21
use crate::prelude::config::*;
32
use crate::prelude::db::*;
43
use crate::prelude::errors::*;

rustmail/src/commands/logs/text_command/logs.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ pub async fn handle_logs_from_user_id(
9393
pagination_store.lock().await.insert(
9494
session_id.clone(),
9595
PaginationContext {
96-
user_id: user_id.to_string(),
9796
logs,
9897
current_page: page,
9998
message_id: response.id,

rustmail/src/commands/move_thread/common.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use crate::prelude::config::*;
22
use crate::prelude::db::*;
3-
use crate::prelude::i18n::*;
4-
use crate::prelude::utils::*;
53
use serenity::all::{ChannelId, CommandInteraction, Context, EditChannel, GuildId, Message};
6-
use std::collections::HashMap;
74

85
pub async fn is_in_thread(msg: &Message, pool: &sqlx::SqlitePool) -> bool {
96
let channel_id = msg.channel_id.to_string();

rustmail/src/commands/ping/slash_command/ping.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::errors::{DiscordError, ModmailError, ModmailResult};
55
use crate::handlers::InteractionHandler;
66
use crate::i18n::get_translated_message;
77
use crate::utils::{MessageBuilder, defer_response};
8-
use chrono::Utc;
98
use serenity::FutureExt;
109
use serenity::all::{CommandInteraction, Context, CreateCommand, ResolvedOption};
1110
use std::collections::HashMap;

0 commit comments

Comments
 (0)