Added Account::delete_all method
This commit is contained in:
parent
3db99a3626
commit
b326aa696d
@ -145,4 +145,13 @@ impl Entity {
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Deletes all the user's accounts from DB
|
||||
pub async fn delete_all(user_id: u64, db: &DatabaseConnection) -> crate::Result<()> {
|
||||
Self::delete_many()
|
||||
.filter(Column::UserId.eq(user_id))
|
||||
.exec(db)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
entity::{account, prelude::*},
|
||||
entity::prelude::*,
|
||||
errors::NoUserInfo,
|
||||
handlers::{markups::deletion_markup, utils::package_handler, MainDialogue, State},
|
||||
};
|
||||
@ -17,10 +17,7 @@ async fn get_master_pass(
|
||||
) -> crate::Result<()> {
|
||||
dialogue.exit().await?;
|
||||
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
|
||||
Account::delete_many()
|
||||
.filter(account::Column::UserId.eq(user_id))
|
||||
.exec(&db)
|
||||
.await?;
|
||||
Account::delete_all(user_id, &db).await?;
|
||||
MasterPass::delete_by_id(user_id).exec(&db).await?;
|
||||
bot.send_message(msg.chat.id, "Everything was deleted")
|
||||
.reply_markup(deletion_markup())
|
||||
|
Loading…
Reference in New Issue
Block a user