Renamed DatabaseConnection into Pool

This commit is contained in:
2024-02-03 16:23:39 +03:00
parent bd10acb438
commit e8f0fcd819
27 changed files with 37 additions and 65 deletions

View File

@ -6,18 +6,14 @@ use futures::future::BoxFuture;
pub async fn generic<F>(
bot: Throttle<Bot>,
msg: Message,
db: DatabaseConnection,
db: Pool,
dialogue: MainDialogue,
check: F,
no_text_message: impl Into<String> + Send,
handler: PackagedHandler<String>,
) -> crate::Result<()>
where
for<'a> F: FnOnce(
&'a Message,
&'a DatabaseConnection,
&'a str,
) -> BoxFuture<'a, crate::Result<Option<String>>>
for<'a> F: FnOnce(&'a Message, &'a Pool, &'a str) -> BoxFuture<'a, crate::Result<Option<String>>>
+ Send,
{
let mut handler = handler.lock().await;

View File

@ -1,11 +1,7 @@
use crate::prelude::*;
#[inline]
async fn check_login(
_: &Message,
_: &DatabaseConnection,
login: &str,
) -> crate::Result<Option<String>> {
async fn check_login(_: &Message, _: &Pool, login: &str) -> crate::Result<Option<String>> {
let is_valid = validate_field(login);
if !is_valid {
return Ok(Some("Invalid login. Try again".to_owned()));

View File

@ -7,7 +7,7 @@ use tokio::task::spawn_blocking;
#[inline]
async fn check_master_pass(
msg: &Message,
db: &DatabaseConnection,
db: &Pool,
master_pass: &str,
) -> crate::Result<Option<String>> {
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;

View File

@ -34,7 +34,7 @@ fn process_validity(validity: PasswordValidity) -> Result<(), String> {
#[inline]
async fn check_new_master_pass(
_: &Message,
_: &DatabaseConnection,
_: &Pool,
password: &str,
) -> crate::Result<Option<String>> {
let validity = check_master_pass(password);

View File

@ -4,7 +4,7 @@ use crate::prelude::*;
#[inline]
async fn check_new_account_name(
msg: &Message,
db: &DatabaseConnection,
db: &Pool,
name: &str,
) -> crate::Result<Option<String>> {
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;

View File

@ -1,11 +1,7 @@
use crate::prelude::*;
#[inline]
async fn check_password(
_: &Message,
_: &DatabaseConnection,
password: &str,
) -> crate::Result<Option<String>> {
async fn check_password(_: &Message, _: &Pool, password: &str) -> crate::Result<Option<String>> {
let is_valid = validate_field(password);
if !is_valid {
return Ok(Some("Invalid password. Try again".to_owned()));

View File

@ -132,7 +132,7 @@ fn user_from_vec(
pub async fn get_user(
bot: Throttle<Bot>,
msg: Message,
db: DatabaseConnection,
db: Pool,
dialogue: MainDialogue,
handler: PackagedHandler<User>,
) -> crate::Result<()> {

View File

@ -65,7 +65,7 @@ type DynHanlder<T> = Box<
dyn FnOnce(
Throttle<Bot>,
Message,
DatabaseConnection,
Pool,
MainDialogue,
MessageIds,
T,
@ -89,7 +89,7 @@ impl<T> Handler<T> {
H: FnOnce(
Throttle<Bot>,
Message,
DatabaseConnection,
Pool,
MainDialogue,
MessageIds,
T,