fix: keep upload pending until /confirm

Single-PUT init was inserting rows with status='approved' (skipping
the confirmation step), so a failed browser->R2 PUT left ghost
entries that the gallery happily listed. Always start as 'pending';
the existing /confirm flow is the only place that should approve.

https://claude.ai/code/session_01TPBqgcSJMppgrpiq7fLywL
This commit is contained in:
Claude 2026-05-04 02:21:27 +00:00
parent dbfd917e50
commit 7a60f1777c
No known key found for this signature in database

View File

@ -80,9 +80,6 @@ uploadsRoutes.post('/init', async (c) => {
c.req.header('cf-connecting-ip') ?? c.req.header('x-forwarded-for') ?? 'unknown'; c.req.header('cf-connecting-ip') ?? c.req.header('x-forwarded-for') ?? 'unknown';
const ipHashValue = await hashIp(ip, IP_HASH_SALT); const ipHashValue = await hashIp(ip, IP_HASH_SALT);
const initialStatus = cfg.moderation === 'pre' ? 'pending' : 'approved';
const approvedAt = initialStatus === 'approved' ? Date.now() : null;
if (input.sizeBytes <= SINGLE_PUT_MAX) { if (input.sizeBytes <= SINGLE_PUT_MAX) {
const presigned = await storage.presignPut({ const presigned = await storage.presignPut({
key: storageKey, key: storageKey,
@ -99,10 +96,9 @@ uploadsRoutes.post('/init', async (c) => {
durationSeconds: input.durationSeconds ?? null, durationSeconds: input.durationSeconds ?? null,
authorName: input.authorName?.trim() || null, authorName: input.authorName?.trim() || null,
message: input.message?.trim() || null, message: input.message?.trim() || null,
status: initialStatus, status: 'pending',
source: 'guest', source: 'guest',
ipHash: ipHashValue, ipHash: ipHashValue,
approvedAt,
}); });
const response: UploadInitResponse = { const response: UploadInitResponse = {