Skip to content

Commit 9a35ac8

Browse files
committed
fix: add missing sqlx queries
1 parent 822e0c6 commit 9a35ac8

6 files changed

+8
-97
lines changed

.sqlx/query-5b090e1e68c28c448b51811b0f4d5160ac09ce56db5c7082865448411dc47cd0.json

-12
This file was deleted.

.sqlx/query-6f0ad1b206a91ecc03afc952e82abda876d7b70212da0fdf9d9331a621578f5a.json

-20
This file was deleted.

.sqlx/query-af4ddce9ab335303494ad6a0f7f9efbd66b1754ffd957a23610b1323dbaa6f0d.json

-12
This file was deleted.

.sqlx/query-d0c6ad43c92be65d1c600aee4fecc30ce14f1ecfc988e92e837f778d0a67df03.json

-26
This file was deleted.

.sqlx/query-d32dd5b9da3258a0f3d45565c7f6550b1fdbd9f32fb0e313964e5058dc1a10b8.json

-12
This file was deleted.

src/cmd_authentication.rs

+8-15
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ pub async fn authorize(
8888
let mut tx = db.begin().await?;
8989

9090
let chat_id_str = msg.chat.id.to_string();
91+
92+
if !RESTRICTED_COMMANDS.iter().any(|c| c.shortand() == command) {
93+
bot.send_message(msg.chat.id, "Cette commande n'existe pas")
94+
.await?;
95+
return Ok(());
96+
}
97+
9198
let already_authorized = sqlx::query!(
9299
r#"SELECT COUNT(*) AS count FROM authorizations WHERE chat_id = $1 AND command = $2"#,
93100
chat_id_str,
@@ -96,21 +103,7 @@ pub async fn authorize(
96103
.fetch_one(tx.as_mut())
97104
.await?;
98105

99-
if RESTRICTED_COMMANDS
100-
.iter()
101-
.find(|c| c.shortand() == command)
102-
.is_none()
103-
{
104-
bot.send_message(msg.chat.id, "Cette commande n'existe pas")
105-
.await?;
106-
return Ok(());
107-
}
108-
109-
if already_authorized
110-
.iter()
111-
.find(|aa| aa.command == command)
112-
.is_none()
113-
{
106+
if already_authorized.count > 0 {
114107
sqlx::query!(
115108
r#"INSERT INTO authorizations(command, chat_id) VALUES($1, $2)"#,
116109
command,

0 commit comments

Comments
 (0)