import { z } from 'zod' import { testExternalNotificationTarget } from '@/lib/external-auto-listing' import { autoListingFailure, autoListingResponse, targetIdSchema, withAutoListingSuperAdmin } from '../_shared' const testTarget = z.object({ id: targetIdSchema }).strict() export async function POST(request: Request) { return withAutoListingSuperAdmin(async () => { const result = testTarget.safeParse(await request.json().catch(() => null)) if (!result.success) return autoListingFailure('请指定已保存的回调目标', 400) const probe = await testExternalNotificationTarget(result.data.id) if (!probe) return autoListingFailure('回调目标不存在', 404) return autoListingResponse({ success: !probe.error, statusCode: probe.statusCode, ...(probe.error ? { error: probe.error } : {}), }, probe.error ? 502 : 200) }) }