30 lines
		
	
	
		
			755 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			755 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
use crate::prelude::*;
 | 
						|
use tokio::task::spawn_blocking;
 | 
						|
 | 
						|
#[inline]
 | 
						|
pub async fn get_account(
 | 
						|
    bot: Throttle<Bot>,
 | 
						|
    msg: Message,
 | 
						|
    db: DatabaseConnection,
 | 
						|
) -> crate::Result<()> {
 | 
						|
    let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
 | 
						|
 | 
						|
    let names: Vec<String> = Account::get_names(user_id, &db)
 | 
						|
        .await?
 | 
						|
        .try_collect()
 | 
						|
        .await?;
 | 
						|
 | 
						|
    if names.is_empty() {
 | 
						|
        bot.send_message(msg.chat.id, "You don't have any accounts")
 | 
						|
            .reply_markup(deletion_markup())
 | 
						|
            .await?;
 | 
						|
        return Ok(());
 | 
						|
    }
 | 
						|
 | 
						|
    let markup = spawn_blocking(|| menu_markup_sync("decrypt", names)).await?;
 | 
						|
    bot.send_message(msg.chat.id, "Choose the account to get")
 | 
						|
        .reply_markup(markup)
 | 
						|
        .await?;
 | 
						|
    Ok(())
 | 
						|
}
 |