Added a prelude to reduce the amount of imports
This commit is contained in:
@ -1,9 +1,4 @@
|
||||
use crate::{
|
||||
errors::NoUserInfo, markups::deletion_markup, models::DecryptedAccount, Handler, MainDialogue,
|
||||
State,
|
||||
};
|
||||
use sea_orm::prelude::*;
|
||||
use teloxide::{adaptors::Throttle, prelude::*};
|
||||
use crate::prelude::*;
|
||||
use tokio::task::spawn_blocking;
|
||||
|
||||
/// Gets the name of the master password, encryptes the account and adds it to the DB
|
||||
|
@ -1,5 +1,4 @@
|
||||
use crate::markups::deletion_markup;
|
||||
use teloxide::{adaptors::Throttle, prelude::*};
|
||||
use crate::prelude::*;
|
||||
|
||||
/// Handles /cancel command when there's no active state
|
||||
pub async fn cancel(bot: Throttle<Bot>, msg: Message) -> crate::Result<()> {
|
||||
|
@ -1,11 +1,4 @@
|
||||
use crate::{
|
||||
errors::NoUserInfo,
|
||||
markups::{self, deletion_markup},
|
||||
Handler, MainDialogue, State,
|
||||
};
|
||||
use entity::prelude::*;
|
||||
use sea_orm::prelude::*;
|
||||
use teloxide::{adaptors::Throttle, prelude::*};
|
||||
use crate::prelude::*;
|
||||
|
||||
/// Gets the master password and deletes the account.
|
||||
/// Although it doesn't use the master password, we get it to be sure that it's the user who used that command
|
||||
@ -53,7 +46,7 @@ pub async fn delete(
|
||||
db: DatabaseConnection,
|
||||
) -> crate::Result<()> {
|
||||
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
|
||||
let markup = markups::account_markup(user_id, &db).await?;
|
||||
let markup = account_markup(user_id, &db).await?;
|
||||
if markup.keyboard.is_empty() {
|
||||
bot.send_message(msg.chat.id, "No accounts found")
|
||||
.reply_markup(deletion_markup())
|
||||
|
@ -1,7 +1,4 @@
|
||||
use crate::{errors::NoUserInfo, markups::deletion_markup, Handler, MainDialogue, State};
|
||||
use entity::prelude::*;
|
||||
use sea_orm::DatabaseConnection;
|
||||
use teloxide::{adaptors::Throttle, prelude::*};
|
||||
use crate::prelude::*;
|
||||
use tokio::join;
|
||||
|
||||
/// Gets the master password, deletes the accounts and the master password from DB.
|
||||
|
@ -1,15 +1,7 @@
|
||||
use crate::{
|
||||
errors::NoUserInfo,
|
||||
markups::deletion_markup,
|
||||
models::{DecryptedAccount, User},
|
||||
Handler, MainDialogue, State,
|
||||
};
|
||||
use entity::prelude::*;
|
||||
use futures::TryStreamExt;
|
||||
use crate::prelude::*;
|
||||
use parking_lot::Mutex;
|
||||
use sea_orm::DatabaseConnection;
|
||||
use std::sync::Arc;
|
||||
use teloxide::{adaptors::Throttle, prelude::*, types::InputFile};
|
||||
use teloxide::types::InputFile;
|
||||
use tokio::task::spawn_blocking;
|
||||
|
||||
/// Decryptes the account on a worker thread and adds it to the accounts vector
|
||||
|
@ -1,8 +1,8 @@
|
||||
use crate::markups::deletion_markup;
|
||||
use crate::prelude::*;
|
||||
use arrayvec::ArrayString;
|
||||
use cryptography::passwords::generate_passwords;
|
||||
use std::fmt::Write;
|
||||
use teloxide::{adaptors::Throttle, prelude::*, types::ParseMode};
|
||||
use teloxide::types::ParseMode;
|
||||
use tokio::task::spawn_blocking;
|
||||
|
||||
const MESSAGE_HEADER: &str = "Passwords:";
|
||||
|
@ -1,12 +1,5 @@
|
||||
use crate::{
|
||||
errors::NoUserInfo,
|
||||
markups::{self, deletion_markup},
|
||||
Handler, MainDialogue, State,
|
||||
};
|
||||
use cryptography::prelude::*;
|
||||
use entity::prelude::*;
|
||||
use sea_orm::DatabaseConnection;
|
||||
use teloxide::{adaptors::Throttle, prelude::*, types::ParseMode};
|
||||
use crate::prelude::*;
|
||||
use teloxide::types::ParseMode;
|
||||
use tokio::task::spawn_blocking;
|
||||
|
||||
/// Gets the master password, decryptes the account and sends it to the user with copyable fields
|
||||
@ -68,7 +61,7 @@ pub async fn get_account(
|
||||
db: DatabaseConnection,
|
||||
) -> crate::Result<()> {
|
||||
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
|
||||
let markup = markups::account_markup(user_id, &db).await?;
|
||||
let markup = account_markup(user_id, &db).await?;
|
||||
if markup.keyboard.is_empty() {
|
||||
bot.send_message(msg.chat.id, "No accounts found")
|
||||
.reply_markup(deletion_markup())
|
||||
|
@ -1,9 +1,7 @@
|
||||
use crate::{errors::NoUserInfo, markups::deletion_markup};
|
||||
use entity::prelude::*;
|
||||
use futures::{future, TryStreamExt};
|
||||
use sea_orm::DatabaseConnection;
|
||||
use crate::prelude::*;
|
||||
use futures::future;
|
||||
use std::fmt::Write;
|
||||
use teloxide::{adaptors::Throttle, prelude::*, types::ParseMode};
|
||||
use teloxide::types::ParseMode;
|
||||
|
||||
/// Handles /get_accounts command by sending the list of copyable account names to the user
|
||||
pub async fn get_accounts(
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::{markups::deletion_markup, Command};
|
||||
use teloxide::{adaptors::Throttle, prelude::*, utils::command::BotCommands};
|
||||
use crate::prelude::*;
|
||||
use teloxide::utils::command::BotCommands;
|
||||
|
||||
/// Handles the help command by sending the passwords descryptions
|
||||
pub async fn help(bot: Throttle<Bot>, msg: Message) -> crate::Result<()> {
|
||||
|
@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
errors::NoUserInfo,
|
||||
markups::deletion_markup,
|
||||
models::{DecryptedAccount, User},
|
||||
Handler, MainDialogue, State,
|
||||
};
|
||||
use futures::{stream, StreamExt};
|
||||
use crate::prelude::*;
|
||||
use futures::stream;
|
||||
use itertools::Itertools;
|
||||
use parking_lot::Mutex;
|
||||
use sea_orm::prelude::*;
|
||||
use std::sync::Arc;
|
||||
use teloxide::{adaptors::Throttle, prelude::*};
|
||||
use tokio::task::spawn_blocking;
|
||||
|
||||
/// Ecryptes the account and adds it to the database
|
||||
|
@ -25,6 +25,7 @@ pub use help::help;
|
||||
pub use import::import;
|
||||
pub use set_master_pass::set_master_pass;
|
||||
pub use start::start;
|
||||
|
||||
use teloxide::macros::BotCommands;
|
||||
|
||||
#[derive(BotCommands, Clone, Copy)]
|
||||
|
@ -1,9 +1,5 @@
|
||||
use crate::{errors::NoUserInfo, markups::deletion_markup, Handler, MainDialogue, State};
|
||||
use cryptography::prelude::*;
|
||||
use entity::prelude::*;
|
||||
use sea_orm::prelude::*;
|
||||
use teloxide::{adaptors::Throttle, prelude::*};
|
||||
use tokio::task;
|
||||
use crate::prelude::*;
|
||||
use tokio::task::spawn_blocking;
|
||||
|
||||
/// Actually sets the master password
|
||||
async fn get_master_pass(
|
||||
@ -15,7 +11,7 @@ async fn get_master_pass(
|
||||
) -> crate::Result<()> {
|
||||
dialogue.exit().await?;
|
||||
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
|
||||
let model = task::spawn_blocking(move || {
|
||||
let model = spawn_blocking(move || {
|
||||
master_pass::ActiveModel::from_unencrypted(user_id, &master_password)
|
||||
})
|
||||
.await?;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use teloxide::{adaptors::Throttle, prelude::*};
|
||||
use crate::prelude::*;
|
||||
|
||||
/// Handles /start command by sending the greeting message
|
||||
pub async fn start(bot: Throttle<Bot>, msg: Message) -> crate::Result<()> {
|
||||
|
Reference in New Issue
Block a user