From 2c5b296eaf0393b11edb7f96919106a6d94aed6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=9A=D1=80=D0=B8=D0=B2?= =?UTF-8?q?=D0=BE=D1=87=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Thu, 30 Jul 2026 14:09:16 +0700 Subject: [PATCH] fix: check raw AD mail attribute, not UPN fallback, for email availability check --- instruct/handlers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/instruct/handlers.py b/instruct/handlers.py index 2041e62..f6ba062 100644 --- a/instruct/handlers.py +++ b/instruct/handlers.py @@ -155,7 +155,7 @@ def get_ad_user_info(user_id: str) -> dict | None: if raw_upn and raw_upn not in ("[]", "N/A", ""): mail = raw_upn city = str(entry.l) if 'l' in entry and entry.l.value else "Кемерово" - return {"cn": cn, "mail": mail, "city": city} + return {"cn": cn, "mail": mail, "raw_mail": raw_mail, "city": city} except Exception as e: logger.error(f"Ошибка получения AD info для {user_id}: {e}", exc_info=True) return None @@ -432,9 +432,9 @@ async def instruct_router_handler(msg: Message): if cn is None: cn = user_id ad_info = get_ad_user_info(user_id) - mail = ad_info.get("mail") if ad_info else None - if mail: - text = INSTRUCT_EMAIL_AVAILABLE(EMOJI_DIGITS, cn, mail) + raw_mail = ad_info.get("raw_mail") if ad_info else None + if raw_mail: + text = INSTRUCT_EMAIL_AVAILABLE(EMOJI_DIGITS, cn, raw_mail) else: text = INSTRUCT_EMAIL_UNAVAILABLE(EMOJI_DIGITS, cn) await msg.answer(text, parse_mode="html")