create_ticket

Function create_ticket 

Source
pub async fn create_ticket(
    __arg0: Extension<FilteredUser>,
    __arg1: State<Arc<AppState>>,
    __arg2: Json<TicketCreateScheme>,
) -> Result<impl IntoResponse, (StatusCode, Json<Value>)>
Expand description

Creates a new support ticket.

Associates the ticket with the authenticated FilteredUser and sets the current timestamp. Converts the TicketCreateScheme request into a database record. Tickets are automatically created with “open” status.

§Arguments

  • Extension(user): Authenticated FilteredUser (extracted from JWT token via middleware)
  • State(data): Application state containing AppState for database access
  • Json(body): TicketCreateScheme containing ticket details (category, subject, description, room)

§Returns

  • 200 OK on successful creation
  • 500 Internal Server Error if database insertion fails

§Database Fields Set Automatically

  • user_id: From authenticated user
  • status: Defaults to “open”
  • date: Current UTC timestamp