Fixed hot leads export count mismatch \ Fixed ban message formatting for popup alerts \ Fixed user deletion back button navigation

This commit is contained in:
Capybara-z
2025-09-01 15:36:02 +03:00
parent 1487fb2858
commit 9074876e3d
3 changed files with 25 additions and 8 deletions
+3 -2
View File
@@ -1114,12 +1114,13 @@ async def handle_delete_user_confirm(
await callback_query.message.edit_text(
text=f"🗑️ Пользователь с ID {tg_id} был удален.",
reply_markup=build_editor_kb(callback_data.tg_id),
reply_markup=build_admin_back_kb(),
)
except Exception as e:
logger.error(f"Ошибка при удалении данных из базы данных для пользователя {tg_id}: {e}")
await callback_query.message.edit_text(
text=f"❌ Произошла ошибка при удалении пользователя с ID {tg_id}. Попробуйте снова."
text=f"❌ Произошла ошибка при удалении пользователя с ID {tg_id}. Попробуйте снова.",
reply_markup=build_admin_back_kb(),
)
+14 -4
View File
@@ -65,21 +65,31 @@ class BanCheckerMiddleware(BaseMiddleware):
if until:
until_local = until.astimezone(TZ).strftime("%Y-%m-%d %H:%M")
text = (
text_html = (
f"🚫 Вы заблокированы до <b>{until_local}</b> по МСК.\n"
f"📄 Причина: <i>{reason}</i>\n\n"
f"Если вы считаете, что это ошибка, обратитесь в поддержку: {SUPPORT_CHAT_URL}"
)
text_plain = (
f"🚫 Вы заблокированы до {until_local} по МСК.\n"
f"📄 Причина: {reason}\n\n"
f"Если вы считаете, что это ошибка, обратитесь в поддержку: {SUPPORT_CHAT_URL}"
)
else:
text = (
text_html = (
f"🚫 Вы заблокированы <b>навсегда</b>.\n"
f"📄 Причина: <i>{reason}</i>\n\n"
f"Если вы считаете, что это ошибка, обратитесь в поддержку: {SUPPORT_CHAT_URL}"
)
text_plain = (
f"🚫 Вы заблокированы навсегда.\n"
f"📄 Причина: {reason}\n\n"
f"Если вы считаете, что это ошибка, обратитесь в поддержку: {SUPPORT_CHAT_URL}"
)
if isinstance(obj, Message):
await obj.answer(text, parse_mode="HTML")
await obj.answer(text_html, parse_mode="HTML")
elif isinstance(obj, CallbackQuery):
await obj.answer(text, show_alert=True)
await obj.answer(text_plain, show_alert=True)
return
return await handler(event, data)
+8 -2
View File
@@ -164,8 +164,14 @@ async def export_hot_leads_csv(session: AsyncSession) -> BufferedInputFile:
User.updated_at,
)
.where(
exists(select(Payment.tg_id).where(Payment.tg_id == User.tg_id).where(Payment.status == "success")),
not_(exists(select(Key.client_id).where(Key.tg_id == User.tg_id).where(Key.expiry_time > now_ts))),
exists(
select(Payment.tg_id)
.where(Payment.tg_id == User.tg_id)
.where(Payment.status == "success")
.where(Payment.amount > 0)
.where(Payment.payment_system.notin_(["referral", "coupon", "cashback"]))
),
not_(exists(select(Key.tg_id).where(Key.tg_id == User.tg_id).where(Key.expiry_time > now_ts))),
)
.order_by(User.updated_at.desc())
)