mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-10 22:01:16 +00:00
fix: BigInt literal compatibility and bot link code JSON parsing
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
- Replace 0n literals with BigInt(0) for ES2017 target compatibility - Parse link code JSON to extract userId and check expiration (was passing raw JSON string as FK, causing constraint violation) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,16 @@ export async function findLinkByUserId(userId: string) {
|
|||||||
export async function validateLinkCode(code: string): Promise<string | null> {
|
export async function validateLinkCode(code: string): Promise<string | null> {
|
||||||
const key = `link_code:${code}`;
|
const key = `link_code:${code}`;
|
||||||
const setting = await db.globalSetting.findUnique({ where: { key } });
|
const setting = await db.globalSetting.findUnique({ where: { key } });
|
||||||
return setting?.value ?? null;
|
if (!setting) return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(setting.value);
|
||||||
|
if (parsed.expiresAt && new Date(parsed.expiresAt) < new Date()) return null;
|
||||||
|
return parsed.userId ?? null;
|
||||||
|
} catch {
|
||||||
|
// Legacy format: value is the userId directly
|
||||||
|
return setting.value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteLinkCode(code: string): Promise<void> {
|
export async function deleteLinkCode(code: string): Promise<void> {
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export async function uploadPackagePreview(
|
|||||||
data: {
|
data: {
|
||||||
previewData: buffer,
|
previewData: buffer,
|
||||||
// Set previewMsgId to 0 as sentinel so hasPreview checks work
|
// Set previewMsgId to 0 as sentinel so hasPreview checks work
|
||||||
previewMsgId: 0n,
|
previewMsgId: BigInt(0),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ export async function setPreviewFromExtract(
|
|||||||
previewData: extractReq.imageData,
|
previewData: extractReq.imageData,
|
||||||
// Set previewMsgId to 0 as sentinel so hasPreview checks work
|
// Set previewMsgId to 0 as sentinel so hasPreview checks work
|
||||||
// (original Telegram-matched previews have the actual message ID)
|
// (original Telegram-matched previews have the actual message ID)
|
||||||
previewMsgId: 0n,
|
previewMsgId: BigInt(0),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user