Member updates: saved draft (loads into the admin card, Save draft button)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
+5
-1
@@ -79,6 +79,10 @@ async function send(input, opts) {
|
||||
})();
|
||||
return { ok: true, id: rec.id, total: rec.total };
|
||||
}
|
||||
// one saved draft (subject, intro, noteIds, audience): the admin card loads it, Save draft writes it
|
||||
const DRAFT = () => path.join(R.dataDir, 'updates-draft.json');
|
||||
function draft() { try { return JSON.parse(fs.readFileSync(DRAFT(), 'utf8')); } catch (e) { return null; } }
|
||||
function saveDraft(d) { const v = { subject: String(d.subject || '').slice(0, 150), intro: String(d.intro || '').slice(0, 8000), noteIds: (d.noteIds || []).map(String).slice(0, 40), audience: AUDIENCES[d.audience] ? d.audience : 'optin', savedAt: Date.now() }; try { fs.writeFileSync(DRAFT(), JSON.stringify(v)); } catch (e) {} return v; }
|
||||
function status() { const l = log(); if (running) { const k = l.sends.find(x => x.id === running.id); if (k) Object.assign(k, running); } return { sends: l.sends.slice(0, 12), running: !!running }; }
|
||||
function lastSentAt() { const l = log(); const d = l.sends.find(x => x.status === 'done'); return d ? d.ts : 0; }
|
||||
module.exports = { init, AUDIENCES, counts, compose, send, status, lastSentAt };
|
||||
module.exports = { init, AUDIENCES, counts, compose, send, status, lastSentAt, draft, saveDraft };
|
||||
|
||||
Reference in New Issue
Block a user