Skip to content

Commit

Permalink
fix: remove unnecessary Mutex in SharedUsers
Browse files Browse the repository at this point in the history
  • Loading branch information
MedAouadhi committed Aug 23, 2023
1 parent b9f0b5c commit 0638623
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lib/telegram/bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ impl<B: BotCommands + 'static> Bot for TelegramBot<B> {
"Adding the user (id = {}), (name = {}).",
user_id, user_name
);
users.insert(user_id, Mutex::new(BotUser::new()));
users.insert(user_id, BotUser::new());
};

let text = msg.get_message();
let mut user = users.get_mut(&user_id).unwrap().lock().await;
let user = users.get_mut(&user_id).unwrap();

// update the user activity
user.set_last_activity(chrono::Utc::now()).await;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub enum BotMessages {
Message, // Telegram messages
}

pub type SharedUsers = Arc<Mutex<HashMap<u64, Mutex<BotUser>>>>;
pub type SharedUsers = Arc<Mutex<HashMap<u64, BotUser>>>;
pub type CommandHashMap = HashMap<String, Box<dyn BotCommandHandler + Send + Sync>>;

#[async_trait]
Expand Down

0 comments on commit 0638623

Please sign in to comment.