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 tracing::{event, Level};
use super::start::handle_new_chat_member; use super::start::handle_new_chat_member;
use super::version::cmd_version;
use super::types::*; use super::types::*;
use super::version::cmd_version;
use crate::db::DbPool; use crate::db::DbPool;
use crate::util::{parse_env, unwrap_env}; use crate::util::{parse_env, unwrap_env};

View file

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

View file

@ -23,7 +23,8 @@ 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"); 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;"#) let requests: i64 =
sqlx::query(r#"SELECT COUNT(1) FROM "request" WHERE requested_by = $1;"#)
.bind(user.id) .bind(user.id)
.fetch_one(&db) .fetch_one(&db)
.await? .await?
@ -33,7 +34,9 @@ pub async fn cmd_request(bot: Bot, msg: Message, text: String, db: DbPool) -> Ha
} }
// put the request // put the request
sqlx::query(r#"INSERT INTO "request" (requested_by,message,is_approved) VALUES ($1,$2,$3);"#) sqlx::query(
r#"INSERT INTO "request" (requested_by,message,is_approved) VALUES ($1,$2,$3);"#,
)
.bind(user.id) .bind(user.id)
.bind(text) .bind(text)
.bind(false) .bind(false)

View file

@ -133,7 +133,9 @@ pub async fn cmd_approve_chat(bot: Bot, msg: Message, id: String, db: DbPool) ->
}; };
// approve request // approve request
sqlx::query(r#"UPDATE "request_chat" SET approved_by = $1, is_approved = true WHERE id = $2;"#) sqlx::query(
r#"UPDATE "request_chat" SET approved_by = $1, is_approved = true WHERE id = $2;"#,
)
.bind(user.id) .bind(user.id)
.bind(request.request_id) .bind(request.request_id)
.execute(&db) .execute(&db)