revert: restore original sd_dispatcher.py in dispatcher

This commit is contained in:
ohmo
2026-07-04 16:42:16 +07:00
parent de1e06cb2c
commit fa5dae47ed
+3 -29
View File
@@ -171,7 +171,7 @@ 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
@@ -195,10 +195,8 @@ def find_user_in_ad(requester, caller_phone=None, ticket_id=None):
if conn.entries and 'mail' in conn.entries[0]:
manager_email = conn.entries[0].mail.value
department = user.department.value if "department" in user and user.department.value else None
department = user.department.value if "department" in user and user.department.value else None
return {"city": city, "company": company, "department": department, "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})"}
return {"city": city, "company": company, "ad_path": ad_path, "manager_email": manager_email, "source": f"AD ({search_by})"}
except Exception as e:
log_to_file(f"❌ Ошибка LDAP или таймаут сети AD: {e}", ticket_id)
return None
@@ -765,9 +763,7 @@ def process_ticket_logic(req_id):
company = user_info["company"] if user_info else None
ad_path = user_info["ad_path"] if user_info else None
manager_email = user_info["manager_email"] if user_info else None
user_department = user_info["department"] if user_info else None
info_source = user_info["source"] if user_info else "Не определен"
user_department = user_info["department"] if user_info else None
prefix_used = False
if caller_phone and not user_info:
@@ -893,30 +889,8 @@ def process_ticket_logic(req_id):
is_cat_ok = False
if cat_name in APPROVAL_CATEGORIES:
allowed_subcats = APPROVAL_CATEGORIES[cat_name]
# Проверка: отдел пользователя в списке исключений
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
if "*" in allowed_subcats or subcat_name in allowed_subcats:
is_cat_ok = True
# Проверка: отдел пользователя в списке исключений
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
if is_city_ok and (is_group_ok or is_cat_ok):
if manager_email: