Persist client document read failures with stale-state protection

This commit is contained in:
2026-09-06 09:36:47 +03:00
parent a109c2e548
commit ba1f93bd76
6 changed files with 52 additions and 3 deletions
+13
View File
@@ -1064,6 +1064,19 @@ const server = http.createServer(async (req, res) => {
return json(res, 200, { success: true, belgeler: store.listDocuments(user.email) });
} catch (e) { return json(res, 400, { success: false, error: e.message }); }
}
if (url.pathname === '/api/me/documents/read-error' && req.method === 'POST') {
const user = userFromAuthHeader(req.headers['authorization']);
if (!user) return json(res,401,{success:false,error:'oturum yok'});
try {
const body = await readBody(req,8192);
const rec = body.id && store.getDocument(user.email,String(body.id));
if (!rec || rec.tur !== 'ihale') return json(res,404,{success:false,error:'ihale dokümanı bulunamadı'});
if (!Object.hasOwn(body,'expectedProcessing')) return json(res,400,{success:false,error:'işleme sürümü gerekli'});
if (!store.reportDocumentReadError(user.email,rec.id,body.expectedProcessing))
return json(res,409,{success:false,error:'Belge işleme durumu değişti. Listeyi yeniden yükleyin.'});
return json(res,200,{success:true});
} catch (e) { return json(res,400,{success:false,error:e.message}); }
}
// Belge metni — docx/xlsx/zip için. PDF tarayıcıda (pdfjs) okunuyor;
// bu türler için tarayıcıda çözücü yok, baytlar zaten burada duruyor.
if (url.pathname === '/api/me/documents/text') {