import { queryOptions } from '@tanstack/react-query'
import { probeHostSoftware } from 'src/lib/fediverse-probe'
import { fetchMobilizonEvent } from 'src/lib/mobilizon-enrichment'
import { queryKeys } from './keys'

export const halflightQueries = {
  mobilizonEvent: (host: string, uuid: string) =>
    queryOptions({
      queryKey: queryKeys.halflight.mobilizonEvent(host, uuid),
      queryFn: () => fetchMobilizonEvent(host, uuid),
      staleTime: 10 * 60 * 1000,
      gcTime: 60 * 60 * 1000,
      retry: false,
      refetchOnWindowFocus: false,
    }),

  nodeinfo: (host: string) =>
    queryOptions({
      queryKey: queryKeys.halflight.nodeinfo(host),
      queryFn: () => probeHostSoftware(host),
      staleTime: 24 * 60 * 60 * 1000,
      gcTime: 7 * 24 * 60 * 60 * 1000,
      retry: false,
      refetchOnWindowFocus: false,
    }),
}
