This commit is contained in:
eric
2026-03-16 12:04:56 -05:00
parent b8fa250897
commit 3ba00e9a93
2 changed files with 50 additions and 18 deletions

View File

@@ -133,6 +133,28 @@ async function tryPocketBaseDirect(
const pb = getPocketBaseConfig();
const base = pb.url.replace(/\/$/, "");
const wechatId = String(record.wechatId ?? "").trim();
if (wechatId) {
const escaped = wechatId.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
const filter = encodeURIComponent(`wechatId = "${escaped}"`);
const checkRes = await fetch(
`${base}/api/collections/${pb.joinCollection}/records?filter=${filter}&perPage=1`,
{
headers: { Authorization: `Bearer ${token}` },
cache: "no-store",
}
);
if (checkRes.ok) {
const checkData = await checkRes.json();
if (Array.isArray((checkData as { items?: unknown[] }).items) && (checkData as { items: unknown[] }).items.length > 0) {
return NextResponse.json(
{ ok: false, error: "该微信号已报名,请勿重复提交" },
{ status: 400 }
);
}
}
}
const url = `${base}/api/collections/${pb.joinCollection}/records`;
const qualify = !!(record.qualify ?? false);