Enhance Ticket management functionalities

This commit is contained in:
2026-03-25 17:33:34 -04:00
parent bee7146073
commit 49542d1f14
7 changed files with 218 additions and 69 deletions
+24 -1
View File
@@ -12,6 +12,29 @@ logger = logging.getLogger(__name__)
# ─── Notifications API ────────────────────────────────────────────────────────
@api_bp.route('/notifications')
@login_required
def get_notifications():
"""Return the 20 most recent notifications for the current user as JSON."""
notifs = (Notification.query
.filter_by(user_id=current_user.id)
.order_by(Notification.created_at.desc())
.limit(20)
.all())
return jsonify({'notifications': [
{
'id' : n.id,
'type' : n.type,
'title' : n.title,
'message' : n.message or '',
'link' : n.link or '',
'is_read' : n.is_read,
'created_at': n.created_at.strftime('%b %d, %H:%M'),
}
for n in notifs
]})
@api_bp.route('/notifications/unread-count')
@login_required
def unread_count():
@@ -80,4 +103,4 @@ def on_join_ticket(data):
def on_leave_ticket(data):
if current_user.is_authenticated:
ticket_id = data.get('ticket_id')
leave_room(f'ticket_{ticket_id}')
leave_room(f'ticket_{ticket_id}')