's'
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user