Require explicit persisted acknowledgement of notifications

This commit is contained in:
2026-09-06 12:52:14 +03:00
parent c7bb67b101
commit 458f638b81
7 changed files with 89 additions and 23 deletions
+7 -3
View File
@@ -80,13 +80,17 @@ export function bildirimYaz({ email, tur, ikn, baslik, metin }) {
return id;
}
export function bildirimleriOku(email, { limit = 50 } = {}) {
const d = open(); if (!d) return [];
const d = open(); if (!d) throw new Error('Bildirim deposuna erişilemiyor.');
return d.prepare('SELECT * FROM bildirimler WHERE email=? ORDER BY zaman DESC LIMIT ?').all(email, limit);
}
export function okunduIsaretle(email, idler) {
const d = open(); if (!d || !idler?.length) return 0;
if(!Array.isArray(idler)||idler.length>200||idler.some(id=>typeof id!=='string'||!id||id.length>100))throw new Error('Geçersiz bildirim kimlikleri.');
const d = open(); if (!d)throw new Error('Bildirim deposuna erişilemiyor.');
if(!idler.length)return 0;
const st = d.prepare('UPDATE bildirimler SET okundu=1 WHERE email=? AND id=?');
let n = 0; for (const id of idler) n += st.run(email, id).changes; return n;
d.exec('BEGIN IMMEDIATE');
try {let n=0;for(const id of new Set(idler))n+=st.run(email,id).changes;d.exec('COMMIT');return n;}
catch(error){d.exec('ROLLBACK');throw error;}
}
async function gonder(email, baslik, metinHtml, metinDuz) {