fix: check raw AD mail attribute, not UPN fallback, for email availability check
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user