Fix ticket details page, comments updated real-time

This commit is contained in:
2026-03-27 10:48:28 -04:00
parent bc9000aad9
commit d8828d487a
4 changed files with 275 additions and 9 deletions
+23
View File
@@ -214,6 +214,29 @@ def notify_comment_added(comment):
base_url = current_app.config.get('APP_BASE_URL', '')
ticket_url = f"{base_url}/tickets/{ticket.id}"
# ── Real-time push to everyone viewing this ticket ────────────────────────
# Emit to the ticket room so all users currently on the ticket detail page
# receive the new comment immediately without needing to reload.
payload = {
'id' : comment.id,
'author_name': comment.author.full_name,
'author_init': comment.author.full_name[0].upper(),
'is_it_staff': comment.author.is_it_staff,
'is_internal': comment.is_internal,
'body' : comment.body,
'created_at' : comment.created_at.strftime('%b %d, %Y %H:%M'),
'author_id' : comment.author_id,
}
def _emit_comment():
socketio.emit(
'new_comment',
payload,
to = f'ticket_{ticket.id}',
namespace = '/',
)
socketio.start_background_task(_emit_comment)
# ─────────────────────────────────────────────────────────────────────────
notified = set()
def _notify(user_id, is_internal=False):