1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

Переделка10

This commit is contained in:
MoonTestUse1
2025-01-02 03:43:59 +06:00
parent ef4806770c
commit 4ec3a0be8f

View File

@@ -5,6 +5,7 @@ from typing import List
from ..database import get_db
from ..models.request import Request, RequestStatus, RequestPriority
from ..schemas.request import RequestCreate, RequestResponse
from ..utils.telegram import send_notification
router = APIRouter()
@@ -32,4 +33,25 @@ def create_request(request: RequestCreate, db: Session = Depends(get_db)):
db.commit()
db.refresh(db_request)
# Отправляем уведомление в Telegram
try:
# Получаем данные сотрудника для уведомления
employee = db_request.employee
notification_data = {
'id': db_request.id,
'employee_first_name': employee.first_name,
'employee_last_name': employee.last_name,
'department': db_request.department,
'office': employee.office,
'request_type': db_request.request_type,
'priority': db_request.priority,
'description': db_request.description,
'status': db_request.status,
'created_at': db_request.created_at.isoformat()
}
send_notification(notification_data)
except Exception as e:
# Логируем ошибку, но не прерываем выполнение
print(f"Error sending notification: {e}")
return db_request