fix: persist weekly brief delivery claims and accepted messages
This commit is contained in:
+4
-6
@@ -1,8 +1,9 @@
|
||||
// Haftalık brief — Pazartesi 08:00: takipteki ihalelerden bu hafta yapılacaklar,
|
||||
// önceki yedi takvim günündeki takipli sonuç kayıtları.
|
||||
// Telegram (bağlıysa) + e-posta. Son gönderim data/brief-son.json'da tutulur;
|
||||
// saatlik kontrol, haftada bir gönderim (node-cron yok, setInterval).
|
||||
// Telegram (bağlıysa) + e-posta; kalıcı mesaj kabul kayıtları brief.sqlite.
|
||||
// Eski brief-son.json yalnız geçiş haftasında tekrar göndermemek için okunur.
|
||||
import fs from 'node:fs';
|
||||
import { createBriefOutbox } from './brief-outbox.mjs';
|
||||
import { createBriefBuilder } from './brief-content.mjs';
|
||||
import { createBriefSender } from './brief-delivery.mjs';
|
||||
import path from 'node:path';
|
||||
@@ -19,9 +20,6 @@ const DURUM_DOSYASI = path.join(__dirname, 'data', 'brief-son.json');
|
||||
function sonGonderim() {
|
||||
try { return JSON.parse(fs.readFileSync(DURUM_DOSYASI, 'utf8')); } catch { return {}; }
|
||||
}
|
||||
function sonGonderimYaz(d) {
|
||||
try { fs.mkdirSync(path.dirname(DURUM_DOSYASI), { recursive: true }); fs.writeFileSync(DURUM_DOSYASI, JSON.stringify(d)); } catch { /* yok */ }
|
||||
}
|
||||
|
||||
const paraTR = (v, birim) => (v == null ? '' : `${Number(v).toLocaleString('tr-TR')} ${birim || 'TL'}`);
|
||||
|
||||
@@ -62,6 +60,7 @@ export function briefHtml(b) {
|
||||
export const haftalikBriefGonder = createBriefSender({
|
||||
store, buildBrief:briefOlustur, text:briefMetni, html:briefHtml,
|
||||
telegramConfigured, sendTelegram, emailConfigured, sendEmail,
|
||||
outbox:createBriefOutbox(process.env.IHALEIST_USER_DATA_DIR || path.join(__dirname,'data')),
|
||||
});
|
||||
|
||||
export function briefScheduleKey(now = new Date()) {
|
||||
@@ -78,7 +77,6 @@ export function briefZamanlayici(tenderGetir) {
|
||||
if (!anahtar) return;
|
||||
const d = sonGonderim();
|
||||
if (d.son === anahtar) return;
|
||||
sonGonderimYaz({ son: anahtar });
|
||||
const r = await haftalikBriefGonder(tenderGetir).catch((e) => ({ hata: e.message }));
|
||||
console.log('[brief] haftalık brief:', JSON.stringify(r));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user