Require explicit persisted acknowledgement of notifications
This commit is contained in:
@@ -929,6 +929,7 @@ const server = http.createServer(async (req, res) => {
|
||||
const body = await readBody(req);
|
||||
return json(res, 200, { success: true, okundu: okunduIsaretle(user.email, body.idler || []) });
|
||||
}
|
||||
if(req.method!=='GET')return json(res,405,{success:false,error:'Desteklenmeyen metot.'});
|
||||
return json(res, 200, { success: true, bildirimler: bildirimleriOku(user.email) });
|
||||
}
|
||||
if (url.pathname === '/api/health/takip') {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user