mirror of
https://github.com/BEDOLAGA-DEV/remnawave-bedolaga-telegram-bot.git
synced 2026-01-19 19:32:10 +00:00
feat(tickets): notify admins on new ticket creation and replies
- Added functionality to notify admins when a new ticket is created. - Implemented notification for admins when a user replies to a ticket. - Included error handling for notification failures.
This commit is contained in:
@@ -12,6 +12,7 @@ from sqlalchemy.orm import selectinload
|
||||
|
||||
from app.database.models import User, Ticket, TicketMessage
|
||||
from app.config import settings
|
||||
from app.handlers.tickets import notify_admins_about_new_ticket, notify_admins_about_ticket_reply
|
||||
|
||||
from ..dependencies import get_cabinet_db, get_current_cabinet_user
|
||||
from ..schemas.tickets import (
|
||||
@@ -161,6 +162,12 @@ async def create_ticket(
|
||||
# Refresh to get relationships
|
||||
await db.refresh(ticket, ["messages"])
|
||||
|
||||
# Уведомить админов о новом тикете
|
||||
try:
|
||||
await notify_admins_about_new_ticket(ticket, db)
|
||||
except Exception as e:
|
||||
logger.error(f"Error notifying admins about new ticket from cabinet: {e}")
|
||||
|
||||
messages = [_message_to_response(m) for m in ticket.messages]
|
||||
|
||||
return TicketDetailResponse(
|
||||
@@ -268,4 +275,10 @@ async def add_ticket_message(
|
||||
await db.commit()
|
||||
await db.refresh(message)
|
||||
|
||||
# Уведомить админов об ответе пользователя
|
||||
try:
|
||||
await notify_admins_about_ticket_reply(ticket, request.message, db)
|
||||
except Exception as e:
|
||||
logger.error(f"Error notifying admins about ticket reply from cabinet: {e}")
|
||||
|
||||
return _message_to_response(message)
|
||||
|
||||
Reference in New Issue
Block a user