Member erase (Marty 2026-11-15, ticket LS-1021): POST /api/admin/erase {email, dryRun (default true), force} + the hub's member.erased event
erase.js runs inside the app so the documents modules keep in memory and the MySQL docs rows stay consistent. Refused
unless force: a main wallet, an on-chain member number, positions, a team here, ads running or queued. Removes the
account, their spin links with every click row in rot_hits and conversions (rotator.eraseOwner, docstore.rowsWhere),
and scrubs every document that mentions them with scrub.js (same file as InstantAdPay) through the owning module's live
copy: accounts, audiences, coach, convtrack, earned (unspent credits go away), hubsync, iapsync, mail-intro, postbacks,
registry, rotator, sponsorfollow; others (updates-log, ...) through docstore. A 30-day email-hash tombstone (erase.json)
stops the InstantAdPay registry sync and hub events from bringing them back; the log keeps hashes and counts only.
hubsync handles member.erased {emailHash}. qa/erase.test.cjs 6 pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+13
-1
@@ -362,6 +362,18 @@ async function claim(demoOwner, newOwner) {
|
||||
for (const r of mine) { r.owner = o; delete r.demo; delete r.expires; r.name = r.name === 'My first spin' ? 'My first spin' : r.name; }
|
||||
if (mine.length) J.save(); return { ok: true, claimed: mine.length };
|
||||
}
|
||||
// member erase (erase.js, 2026-11-15): every spin link the person owns goes, with its clicks (memory and every rot_hits row) and
|
||||
// conversions. dryRun counts only. -> { rotations, hits, conv }
|
||||
async function eraseOwner(email, dryRun) {
|
||||
const e = norm(email); const ids = new Set(J.db.rotations.filter(r => norm(r.owner) === e).map(r => r.id));
|
||||
if (!ids.size) return { rotations: 0, hits: 0, conv: 0 };
|
||||
const list = [...ids]; const memHits = J.db.hits.filter(h => ids.has(h.r)).length; const conv = J.db.conv.filter(c => ids.has(c.r)).length;
|
||||
if (dryRun) { const rows = docstore.isOn() ? await docstore.rowsWhere('rot_hits', '$.r', list, false) : 0; return { rotations: ids.size, hits: Math.max(memHits, rows), conv }; }
|
||||
J.db.rotations = J.db.rotations.filter(r => !ids.has(r.id)); // first: no new click can be counted for them
|
||||
J.db.hits = J.db.hits.filter(h => !ids.has(h.r)); J.db.conv = J.db.conv.filter(c => !ids.has(c.r)); HIT_IX = null; J.save();
|
||||
const rows = docstore.isOn() ? await docstore.rowsWhere('rot_hits', '$.r', list, true) : 0;
|
||||
return { rotations: ids.size, hits: Math.max(memHits, rows), conv };
|
||||
}
|
||||
function sweepDemos() {
|
||||
const now = Date.now(); const gone = new Set();
|
||||
J.db.rotations = J.db.rotations.filter(r => { if (r.demo && r.expires && r.expires < now) { gone.add(r.id); return false; } return true; });
|
||||
@@ -395,5 +407,5 @@ function adminAll() {
|
||||
destinations: (r.destinations || []).map(d => ({ id: d.id, url: d.url, label: d.label || '', weight: d.weight, active: !!d.active, autoPaused: d.autoPaused || 0, health: d.health ? { state: d.health.state, note: d.health.note || '', checkedAt: d.health.checkedAt || 0 } : null })),
|
||||
hits: o.hits, hits7: o.hits7, bots: o.bots, conversions: cv[r.id] || 0 }; });
|
||||
}
|
||||
module.exports = { init, convRows, adminAll, hitById, list, get, create, update, remove, addDest, updateDest, resolve, stats, totals, convert, summary, createDemo, claim, sweepDemos, servedToday, window24,
|
||||
module.exports = { eraseOwner, _json: { state: () => J.db, save: () => J.save() }, init, convRows, adminAll, hitById, list, get, create, update, remove, addDest, updateDest, resolve, stats, totals, convert, summary, createDemo, claim, sweepDemos, servedToday, window24,
|
||||
pub, rawRotations, save, findMine, setExternalConvert, PRESETS, cleanHours, cleanTz, cellAt, zoneFor, isOn, COUNTRY_TZ, sourceCounts, detachSource, ensureFixed, ensurePartner, partnerStats };
|
||||
|
||||
Reference in New Issue
Block a user