PhoenixKit.Modules.Tickets.Events (phoenix_kit v1.7.38)

Copy Markdown View Source

PubSub events for PhoenixKit Tickets system.

Broadcasts ticket-related events for real-time updates in LiveViews. Uses PhoenixKit.PubSub.Manager for self-contained PubSub operations.

Topics

  • "tickets:all" - All tickets (for admins)
  • "tickets:user:{user_id}" - Tickets for specific user
  • "tickets:{id}" - Specific ticket (for detail view)

Events

Ticket Events

  • {:ticket_created, ticket} - New ticket created
  • {:ticket_updated, ticket} - Ticket updated
  • {:ticket_status_changed, ticket, old_status, new_status} - Status transition
  • {:ticket_assigned, ticket, old_assignee_id, new_assignee_id} - Assignment change
  • {:ticket_priority_changed, ticket, old_priority, new_priority} - Priority change
  • {:tickets_bulk_updated, tickets, changes} - Bulk update operation

Comment Events

  • {:comment_created, comment, ticket} - Public comment added
  • {:internal_note_created, comment, ticket} - Internal note added (staff only)

Usage Examples

# Subscribe to all ticket events (admin view)
PhoenixKit.Modules.Tickets.Events.subscribe_to_all()

# Subscribe to user's tickets
PhoenixKit.Modules.Tickets.Events.subscribe_to_user_tickets(user_id)

# Subscribe to specific ticket (detail view)
PhoenixKit.Modules.Tickets.Events.subscribe_to_ticket(ticket_id)

# Handle in LiveView
def handle_info({:ticket_created, ticket}, socket) do
  # Update UI
  {:noreply, socket}
end

Summary

Functions

Broadcasts public comment created event.

Broadcasts internal note created event (staff only).

Broadcasts ticket created event.

Broadcasts ticket status changed event.

Broadcasts ticket updated event.

Broadcasts tickets bulk updated event.

Alias for subscribe_to_all/0 for consistency with naming convention. Subscribes to all ticket events (for admin views).

Subscribes to all ticket events (for admin views).

Subscribes to events for a specific ticket (for detail views).

Subscribes to ticket events for a specific user.

Returns the PubSub topic for a specific ticket.

Unsubscribes from all ticket events.

Unsubscribes from a specific ticket's events.

Unsubscribes from a specific user's ticket events.

Returns the PubSub topic for a specific user's tickets.

Functions

broadcast_comment_created(comment, ticket)

Broadcasts public comment created event.

broadcast_internal_note_created(comment, ticket)

Broadcasts internal note created event (staff only).

broadcast_ticket_assigned(ticket, old_assignee_id, new_assignee_id)

Broadcasts ticket assigned event.

broadcast_ticket_created(ticket)

Broadcasts ticket created event.

broadcast_ticket_priority_changed(ticket, old_priority, new_priority)

Broadcasts ticket priority changed event.

broadcast_ticket_status_changed(ticket, old_status, new_status)

Broadcasts ticket status changed event.

broadcast_ticket_updated(ticket)

Broadcasts ticket updated event.

broadcast_tickets_bulk_updated(tickets, changes)

Broadcasts tickets bulk updated event.

subscribe_tickets()

Alias for subscribe_to_all/0 for consistency with naming convention. Subscribes to all ticket events (for admin views).

subscribe_to_all()

Subscribes to all ticket events (for admin views).

subscribe_to_ticket(ticket_id)

Subscribes to events for a specific ticket (for detail views).

subscribe_to_user_tickets(user_id)

Subscribes to ticket events for a specific user.

ticket_topic(ticket_id)

Returns the PubSub topic for a specific ticket.

unsubscribe_from_all()

Unsubscribes from all ticket events.

unsubscribe_from_ticket(ticket_id)

Unsubscribes from a specific ticket's events.

unsubscribe_from_user_tickets(user_id)

Unsubscribes from a specific user's ticket events.

user_topic(user_id)

Returns the PubSub topic for a specific user's tickets.