fix: correct department exclusion logic in auto-approval
This commit is contained in:
+10
-13
@@ -171,7 +171,6 @@ def find_user_in_ad(requester, caller_phone=None, ticket_id=None):
|
||||
server = Server(AD_SERVER, get_info=ALL, connect_timeout=AD_CONNECT_TIMEOUT)
|
||||
conn = Connection(server, user=AD_USER, password=AD_PASSWORD, auto_bind=True, receive_timeout=AD_RECEIVE_TIMEOUT)
|
||||
conn.search(search_base=AD_BASE, search_filter=ldap_filter, attributes=["l", "company", "manager"])
|
||||
conn.search(search_base=AD_BASE, search_filter=ldap_filter, attributes=["l", "company", "manager", "department"])
|
||||
if not conn.entries:
|
||||
log_to_file(f" [AD] ❌ Объект ({search_by}) не найден in AD!", ticket_id)
|
||||
return None
|
||||
@@ -198,7 +197,6 @@ def find_user_in_ad(requester, caller_phone=None, ticket_id=None):
|
||||
department = user.department.value if "department" in user and user.department.value else None
|
||||
return {"city": city, "company": company, "ad_path": ad_path, "manager_email": manager_email, "source": f"AD ({search_by})"}
|
||||
return {"city": city, "company": company, "department": department, "ad_path": ad_path, "manager_email": manager_email, "source": f"AD ({search_by})"}
|
||||
log_to_file(f"❌ Ошибка LDAP или таймаут сети AD: {e}", ticket_id)
|
||||
return None
|
||||
|
||||
def resolve_support_group(qdrant_group, city, company, ad_path):
|
||||
@@ -895,18 +893,17 @@ def process_ticket_logic(req_id):
|
||||
is_cat_ok = True
|
||||
continue
|
||||
t_log(" ⏭ Пропуск: пользователь в исключённом отделе.")
|
||||
if is_excluded:
|
||||
break
|
||||
t_log(f" ⚠️ Отдел '{user_department}' в списке исключений — автосогласование отменено")
|
||||
is_excluded = True
|
||||
if dept.lower() in user_department.lower() or user_department.lower() in dept.lower():
|
||||
for dept in APPROVAL_EXCLUDED_DEPARTMENTS:
|
||||
if user_department and APPROVAL_EXCLUDED_DEPARTMENTS:
|
||||
is_excluded = False
|
||||
# Проверка: отдел пользователя в списке исключений
|
||||
|
||||
if is_city_ok and (is_group_ok or is_cat_ok):
|
||||
if manager_email:
|
||||
is_excluded = False
|
||||
if user_department and APPROVAL_EXCLUDED_DEPARTMENTS:
|
||||
for dept in APPROVAL_EXCLUDED_DEPARTMENTS:
|
||||
if dept.lower() in user_department.lower() or user_department.lower() in dept.lower():
|
||||
is_excluded = True
|
||||
t_log(f" ⚠️ Отдел '{user_department}' в списке исключений — автосогласование отменено")
|
||||
break
|
||||
if is_excluded:
|
||||
t_log(" ⏭ Пропуск: пользователь в исключённом отделе.")
|
||||
continue
|
||||
t_log(f"✔ Условия совпали. Запуск процесса согласования для {manager_email}...")
|
||||
ai_was_used = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user