use crate::prelude::*; use tokio::task::spawn_blocking; /// Gets the name of the master password, encryptes the account and adds it to the DB #[allow(clippy::too_many_arguments)] async fn get_master_pass( bot: Throttle, msg: Message, db: DatabaseConnection, dialogue: MainDialogue, name: String, login: String, password: String, master_pass: String, ) -> crate::Result<()> { let user_id = msg.from().ok_or(NoUserInfo)?.id.0; dialogue.exit().await?; let account = spawn_blocking(move || { account::ActiveModel::from_unencrypted(user_id, name, &login, &password, &master_pass) }) .await??; account.insert(&db).await?; bot.send_message(msg.chat.id, "Success") .reply_markup(deletion_markup()) .await?; Ok(()) } handler!( get_password(name:String, login: String, password: String), "Send master password", State::GetMasterPass, get_master_pass ); handler!(get_login(name: String, login: String), "Send password", State::GetPassword, get_password ); handler!(get_account_name(name: String), "Send login", State::GetLogin, get_login); handler!(pub add_account(), "Send account name", State::GetNewName, get_account_name);