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

отправка уведомлений в телеграV2

This commit is contained in:
MoonTestUse1
2025-01-03 01:43:59 +06:00
parent 3a70e37e26
commit 228689fbf8
2 changed files with 6 additions and 12 deletions

View File

@@ -57,23 +57,17 @@ def create_request(
db.commit()
db.refresh(db_request)
# Подготавливаем данные для уведомления
request_data = {
"id": db_request.id,
"title": db_request.title,
"description": db_request.description,
"priority": db_request.priority,
"status": db_request.status,
"employee_name": f"{current_employee.last_name} {current_employee.first_name}",
"created_at": db_request.created_at
}
# Преобразуем объект запроса в словарь для уведомления
request_dict = request_to_dict(db_request)
request_dict["employee_name"] = f"{current_employee.last_name} {current_employee.first_name}"
# Отправляем уведомление в Telegram
notify_new_request(request_data)
notify_new_request(request_dict)
return request_to_dict(db_request)
except Exception as e:
db.rollback()
logger.error(f"Error creating request: {e}", exc_info=True)
raise HTTPException(status_code=500, detail=str(e))
@router.get("/my", response_model=List[RequestResponse])

View File

@@ -45,7 +45,7 @@ async def send_request_notification(request_data: dict):
f"❗ <b>Приоритет:</b> {format_priority(request_data['priority'])}\n"
f"📊 <b>Статус:</b> {format_status(request_data['status'])}\n\n"
f"📄 <b>Описание:</b>\n{request_data['description']}\n\n"
f"🕒 <b>Создана:</b> {request_data['created_at'].strftime('%d.%m.%Y %H:%M')}"
f"🕒 <b>Создана:</b> {request_data['created_at'].strftime('%d.%m.%Y %H:%M') if request_data['created_at'] else 'Не указано'}"
)
await bot.send_message(