Function get_ticket_messages

Source
pub async fn get_ticket_messages(
    __arg0: Path<(i64, i64, i64)>,
    __arg1: State<AppState>,
    __arg2: Extension<AuthUser>,
    __arg3: Query<FilterReq>,
) -> impl IntoResponse
Expand description

GET /api/modules/{module_id}/assignments/{assignment_id}/tickets/{ticket_id}/messages

Retrieve a paginated list of ticket messages for a specific ticket.
Requires authentication and that the caller is allowed to view the ticket (validated by is_valid, e.g., ticket participant/assigned staff for the module).

§Path Parameters

  • module_id (i64): ID of the module that owns the assignment/ticket
  • assignment_id (i64): ID of the assignment (present in the route; not used in filtering here)
  • ticket_id (i64): ID of the ticket whose messages are being fetched

§Query Parameters

  • page (optional, i32): Page number. Defaults to 1. Minimum 1
  • per_page (optional, i32): Items per page. Defaults to 50. Maximum 100
  • query (optional, string): Case-insensitive substring filter applied to message content

Note: Sorting is not supported on this endpoint. Results are returned in the database’s default order for the query.

§Responses

  • 200 OK
{
  "success": true,
  "message": "Messages retrieved successfully",
  "data": {
    "tickets": [
      {
        "id": 101,
        "ticket_id": 99,
        "content": "Hey, I'm blocked on step 3.",
        "created_at": "2025-02-18T09:12:33Z",
        "updated_at": "2025-02-18T09:12:33Z",
        "user": {
          "id": 12,
          "username": "alice"
        }
      },
      {
        "id": 102,
        "ticket_id": 99,
        "content": "Try re-running with the latest config.",
        "created_at": "2025-02-18T09:14:10Z",
        "updated_at": "2025-02-18T09:14:10Z",
        "user": {
          "id": 8,
          "username": "tutor_bob"
        }
      }
    ],
    "page": 1,
    "per_page": 50,
    "total": 2
  }
}
  • 403 Forbidden
{
  "success": false,
  "message": "Forbidden"
}
  • 500 Internal Server Error
{
  "success": false,
  "message": "Error counting tickets"
}

or

{
  "success": false,
  "message": "Failed to retrieve tickets"
}

§Example Request

GET /api/modules/42/assignments/7/tickets/99/messages?page=1&per_page=50&query=blocked
Authorization: Bearer <token>

§Example Success (200)

See the 200 OK example above.