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

@@ -7,7 +7,7 @@ use tokio::task::spawn_blocking;
async fn get_master_pass(
bot: Throttle<Bot>,
msg: Message,
db: DatabaseConnection,
db: Pool,
dialogue: MainDialogue,
mut ids: MessageIds,
name: String,

View File

@@ -2,7 +2,7 @@ use crate::prelude::*;
use tokio::task::spawn_blocking;
#[inline]
pub async fn delete(bot: Throttle<Bot>, msg: Message, db: DatabaseConnection) -> crate::Result<()> {
pub async fn delete(bot: Throttle<Bot>, msg: Message, db: Pool) -> crate::Result<()> {
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
let names: Vec<String> = Account::get_names(user_id, &db).try_collect().await?;

View File

@@ -7,7 +7,7 @@ use log::error;
async fn get_master_pass(
bot: Throttle<Bot>,
msg: Message,
db: DatabaseConnection,
db: Pool,
dialogue: MainDialogue,
mut ids: MessageIds,
_: String,

View File

@@ -22,7 +22,7 @@ async fn decrypt_account(
async fn get_master_pass(
bot: Throttle<Bot>,
msg: Message,
db: DatabaseConnection,
db: Pool,
dialogue: MainDialogue,
ids: MessageIds,
master_pass: String,

View File

@@ -2,11 +2,7 @@ use crate::prelude::*;
use tokio::task::spawn_blocking;
#[inline]
pub async fn get_account(
bot: Throttle<Bot>,
msg: Message,
db: DatabaseConnection,
) -> crate::Result<()> {
pub async fn get_account(bot: Throttle<Bot>, msg: Message, db: Pool) -> crate::Result<()> {
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
let names: Vec<String> = Account::get_names(user_id, &db).try_collect().await?;

View File

@@ -5,11 +5,7 @@ use teloxide::types::ParseMode;
/// Handles /`get_accounts` command by sending the list of copyable account names to the user
#[inline]
pub async fn get_accounts(
bot: Throttle<Bot>,
msg: Message,
db: DatabaseConnection,
) -> crate::Result<()> {
pub async fn get_accounts(bot: Throttle<Bot>, msg: Message, db: Pool) -> crate::Result<()> {
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
let mut account_names = Account::get_names(user_id, &db);

View File

@@ -11,7 +11,7 @@ use tokio::task::spawn_blocking;
async fn encrypt_account(
account: DecryptedAccount,
user_id: u64,
db: &DatabaseConnection,
db: &Pool,
master_pass: Arc<str>,
failed: &Mutex<&mut Vec<String>>,
) {
@@ -30,7 +30,7 @@ async fn encrypt_account(
async fn get_master_pass(
bot: Throttle<Bot>,
msg: Message,
db: DatabaseConnection,
db: Pool,
dialogue: MainDialogue,
mut ids: MessageIds,
user: User,

View File

@@ -2,7 +2,7 @@ use crate::prelude::*;
use tokio::task::spawn_blocking;
#[inline]
pub async fn menu(bot: Throttle<Bot>, msg: Message, db: DatabaseConnection) -> crate::Result<()> {
pub async fn menu(bot: Throttle<Bot>, msg: Message, db: Pool) -> crate::Result<()> {
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
let names: Vec<String> = Account::get_names(user_id, &db).try_collect().await?;

View File

@@ -6,7 +6,7 @@ use tokio::task::spawn_blocking;
async fn get_master_pass2(
bot: Throttle<Bot>,
msg: Message,
db: DatabaseConnection,
db: Pool,
dialogue: MainDialogue,
mut ids: MessageIds,
hash: HashedBytes<[u8; 64], [u8; 64]>,
@@ -45,7 +45,7 @@ async fn get_master_pass2(
async fn get_master_pass(
bot: Throttle<Bot>,
_: Message,
_: DatabaseConnection,
_: Pool,
dialogue: MainDialogue,
mut ids: MessageIds,
master_pass: String,
@@ -71,7 +71,7 @@ pub async fn set_master_pass(
bot: Throttle<Bot>,
msg: Message,
dialogue: MainDialogue,
db: DatabaseConnection,
db: Pool,
) -> crate::Result<()> {
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
if MasterPass::exists(user_id, &db).await? {