Tweaks in handlers to optimize database usage

This commit is contained in:
StNicolay 2022-10-30 16:06:38 +03:00
parent d65468134a
commit 689de06782

View File

@ -81,8 +81,6 @@ def _reset_master_pass2(
bot: telebot.TeleBot, engine: Engine, prev_mes: Message, mes: Message bot: telebot.TeleBot, engine: Engine, prev_mes: Message, mes: Message
) -> None: ) -> None:
_base(bot, mes, prev_mes) _base(bot, mes, prev_mes)
if database.get.get_master_pass(engine, mes.from_user.id) is None:
return _send_tmp_message(bot, mes.chat.id, "Мастер пароль не задан")
hash_, salt = cryptography.master_pass.encrypt_master_pass(mes.text.strip()) hash_, salt = cryptography.master_pass.encrypt_master_pass(mes.text.strip())
database.delete.purge_accounts(engine, mes.from_user.id) database.delete.purge_accounts(engine, mes.from_user.id)
database.change.change_master_pass(engine, mes.from_user.id, salt, hash_) database.change.change_master_pass(engine, mes.from_user.id, salt, hash_)
@ -116,7 +114,9 @@ def _add_account2(
database.get.get_account_info(engine, mes.from_user.id, mes.text.strip()) database.get.get_account_info(engine, mes.from_user.id, mes.text.strip())
is not None is not None
): ):
_send_tmp_message(bot, mes.chat.id, "Аккаунт с таким именем уже существует") return _send_tmp_message(
bot, mes.chat.id, "Аккаунт с таким именем уже существует"
)
bot_mes = bot.send_message(mes.chat.id, "Отправьте логин") bot_mes = bot.send_message(mes.chat.id, "Отправьте логин")
data = {"name": mes.text.strip()} data = {"name": mes.text.strip()}