import getClient from "./zendesk-client" ; import { is_valid_uuid_string as isValidUUID } from "@cocalc/util/misc" ; import type { Tickets } from "node-zendesk" ; import { urlToUserURL } from "./util" ; export default async function getTickets ( account_id ) { if ( ! isValidUUID ( account_id ) ) { return [ ] ; } const client = await getClient ( ) ; const query = `type:ticket external_id:${ account_id }` ; const result = await client . search . query ( query ) ; for ( const ticket of result ) { ticket . userURL = urlToUserURL ( ticket . url ) ; } return result ; }