PhoenixKit.Modules.Tickets.TicketComment (phoenix_kit v1.7.33)

Copy Markdown View Source

Schema for ticket comments with internal notes support.

Supports nested comment threads (like PostComment) with self-referencing parent/child relationships. The is_internal flag distinguishes between public comments (visible to customer) and internal notes (staff only).

Comment Types

  • Public comments (is_internal: false) - Visible to customer and staff
  • Internal notes (is_internal: true) - Visible only to support staff

Fields

  • ticket_id - Reference to the ticket
  • user_id - Reference to the commenter
  • parent_id - Reference to parent comment (nil for top-level)
  • content - Comment text
  • is_internal - True for internal notes, false for public comments
  • depth - Nesting level (0=top, 1=reply, 2=reply-to-reply, etc.)

Examples

# Public comment from support
%TicketComment{
  ticket_id: "018e3c4a-9f6b-7890-abcd-ef1234567890",
  user_id: 5,
  parent_id: nil,
  content: "Thank you for contacting us. We're looking into this.",
  is_internal: false,
  depth: 0
}

# Internal note (hidden from customer)
%TicketComment{
  ticket_id: "018e3c4a-9f6b-7890-abcd-ef1234567890",
  user_id: 5,
  parent_id: nil,
  content: "Customer seems frustrated. Need to escalate to senior support.",
  is_internal: true,
  depth: 0
}

# Customer reply
%TicketComment{
  ticket_id: "018e3c4a-9f6b-7890-abcd-ef1234567890",
  user_id: 42,
  parent_id: "018e3c4a-1234-5678-abcd-ef1234567890",
  content: "Thanks, I've tried that but it still doesn't work.",
  is_internal: false,
  depth: 1
}

Summary

Functions

Changeset for creating or updating a comment.

Check if comment is an internal note.

Check if comment is public (visible to customer).

Check if comment is a reply (has parent).

Check if comment is top-level (no parent).

Types

t()

@type t() :: %PhoenixKit.Modules.Tickets.TicketComment{
  __meta__: term(),
  attachments:
    [PhoenixKit.Modules.Tickets.TicketAttachment.t()]
    | Ecto.Association.NotLoaded.t(),
  children: [t()] | Ecto.Association.NotLoaded.t(),
  content: String.t(),
  depth: integer(),
  id: UUIDv7.t() | nil,
  inserted_at: NaiveDateTime.t() | nil,
  is_internal: boolean(),
  parent: t() | Ecto.Association.NotLoaded.t() | nil,
  parent_id: UUIDv7.t() | nil,
  ticket:
    PhoenixKit.Modules.Tickets.Ticket.t() | Ecto.Association.NotLoaded.t(),
  ticket_id: UUIDv7.t(),
  updated_at: NaiveDateTime.t() | nil,
  user: PhoenixKit.Users.Auth.User.t() | Ecto.Association.NotLoaded.t(),
  user_id: integer()
}

Functions

changeset(comment, attrs)

Changeset for creating or updating a comment.

Required Fields

  • ticket_id - Reference to ticket
  • user_id - Reference to commenter
  • content - Comment text

Validation Rules

  • Content must be 1-10000 characters
  • is_internal defaults to false
  • Depth automatically calculated from parent

internal?(arg1)

Check if comment is an internal note.

public?(arg1)

Check if comment is public (visible to customer).

reply?(ticket_comment)

Check if comment is a reply (has parent).

top_level?(ticket_comment)

Check if comment is top-level (no parent).