Enhance Ticket management functionalities
This commit is contained in:
+24
-1
@@ -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}')
|
||||
Reference in New Issue
Block a user