cargo fmt

This commit is contained in:
mykola2312 2024-03-16 03:03:45 +02:00
parent 2c23c8c6a1
commit db5bc74de7
5 changed files with 29 additions and 23 deletions

View file

@ -8,8 +8,8 @@ use teloxide::{prelude::*, update_listeners::Polling, utils::command::BotCommand
use tracing::{event, Level};
use super::start::handle_new_chat_member;
use super::version::cmd_version;
use super::types::*;
use super::version::cmd_version;
use crate::db::DbPool;
use crate::util::{parse_env, unwrap_env};
@ -109,7 +109,7 @@ enum Command {
#[command(alias = "dl")]
Download(String),
#[command(alias = "op")]
OP,

View file

@ -6,10 +6,11 @@ use crate::db::{DbPool, User};
use super::types::HandlerResult;
pub async fn notify_admins(bot: &Bot, db: &DbPool, message: String) -> HandlerResult {
let admins: Vec<User> =
sqlx::query_as(r#"SELECT * FROM "user" WHERE is_admin = true AND has_private_chat = true;"#)
.fetch_all(db)
.await?;
let admins: Vec<User> = sqlx::query_as(
r#"SELECT * FROM "user" WHERE is_admin = true AND has_private_chat = true;"#,
)
.fetch_all(db)
.await?;
for admin in admins {
let res = bot

View file

@ -23,22 +23,25 @@ pub async fn cmd_request(bot: Bot, msg: Message, text: String, db: DbPool) -> Ha
reply_i18n_and_return!(bot, msg.chat.id, "already_can_download");
}
let requests: i64 = sqlx::query(r#"SELECT COUNT(1) FROM "request" WHERE requested_by = $1;"#)
.bind(user.id)
.fetch_one(&db)
.await?
.get(0);
let requests: i64 =
sqlx::query(r#"SELECT COUNT(1) FROM "request" WHERE requested_by = $1;"#)
.bind(user.id)
.fetch_one(&db)
.await?
.get(0);
if requests > 0 {
reply_i18n_and_return!(bot, msg.chat.id, "already_has_requested");
}
// put the request
sqlx::query(r#"INSERT INTO "request" (requested_by,message,is_approved) VALUES ($1,$2,$3);"#)
.bind(user.id)
.bind(text)
.bind(false)
.execute(&db)
.await?;
sqlx::query(
r#"INSERT INTO "request" (requested_by,message,is_approved) VALUES ($1,$2,$3);"#,
)
.bind(user.id)
.bind(text)
.bind(false)
.execute(&db)
.await?;
event!(Level::INFO, "added request for {}", user);
// notify admins

View file

@ -133,11 +133,13 @@ pub async fn cmd_approve_chat(bot: Bot, msg: Message, id: String, db: DbPool) ->
};
// approve request
sqlx::query(r#"UPDATE "request_chat" SET approved_by = $1, is_approved = true WHERE id = $2;"#)
.bind(user.id)
.bind(request.request_id)
.execute(&db)
.await?;
sqlx::query(
r#"UPDATE "request_chat" SET approved_by = $1, is_approved = true WHERE id = $2;"#,
)
.bind(user.id)
.bind(request.request_id)
.execute(&db)
.await?;
event!(
Level::INFO,
"approved chat request {} by {} for {}",

View file

@ -8,4 +8,4 @@ pub async fn cmd_version(bot: Bot, msg: Message) -> HandlerResult {
bot.send_message(msg.chat.id, VERSION).await?;
Ok(())
}
}