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:
@@ -46,6 +46,7 @@ const leaderboard = require('./leaderboard');
|
||||
const toolkit = require('./toolkit');
|
||||
const registry = require('./registry'); // network registry: who is who across properties (LinkSpin, 2026-09-15)
|
||||
const iapsync = require('./iapsync'); // reverse registry sync: LinkSpin-first members reach InstantAdPay (2026-10-15)
|
||||
const erase = require('./erase'); // member erase (2026-11-15, LS-1021): POST /api/admin/erase + the hub's member.erased event
|
||||
const hubsync = require('./hubsync'); // network hub link, inert unless HUB_ENABLED=1 (2026-11-12)
|
||||
const SF = require('./sponsorfollow'); // deliberate sponsor changes follow to InstantAdPay until chain-bound + one network tank (2026-10-22)
|
||||
let follow = null, followStore = null;
|
||||
@@ -741,7 +742,7 @@ async function boot() {
|
||||
setTimeout(() => carry.backfillMemberIds().then(r => console.log('memberId backfill', JSON.stringify(r))).catch(e => console.error('memberId backfill', e.message)), 60000);
|
||||
// reverse registry sync (2026-10-15): account changes reach InstantAdPay within seconds; a 2-minute reconcile catches the rest
|
||||
iapsync.init({ dataDir: DATA_DIR, accounts, registry, host: SITE_HOST, follow: followStore, tank: () => tank }); accounts.onChange(email => { iapsync.touch(email); hubsync.touch(email); });
|
||||
hubsync.init({ dataDir: DATA_DIR, accounts, registry, carry, follow: followStore, chain }); setInterval(() => hubsync.tick().catch(e => console.error('hubsync', e.message)), 30 * 1000); // touch/tick do nothing while HUB_ENABLED is off
|
||||
hubsync.init({ dataDir: DATA_DIR, accounts, registry, carry, follow: followStore, chain, erase, erased: email => erase.isErased(email) }); setInterval(() => hubsync.tick().catch(e => console.error('hubsync', e.message)), 30 * 1000); // touch/tick do nothing while HUB_ENABLED is off
|
||||
setTimeout(() => iapsync.tick().catch(e => console.error('iapsync', e.message)), 2 * 60 * 1000);
|
||||
setInterval(() => iapsync.tick().catch(e => console.error('iapsync', e.message)), 2 * 60 * 1000);
|
||||
const ownHosts = () => [SITE_HOST].concat(String(siteConfig().linkDomains || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean), pagesHost() ? [pagesHost()] : []);
|
||||
@@ -763,6 +764,13 @@ async function boot() {
|
||||
zones.init({ dataDir: DATA_DIR, ads, siteHost: SITE_HOST });
|
||||
pages.init({ dataDir: DATA_DIR, ownHosts, imageBase: () => (IS_PROD ? 'https' : 'http') + '://' + SITE_HOST, openrouterKey: () => { if (process.env.OPENROUTER_API_KEY) return process.env.OPENROUTER_API_KEY.trim(); try { return fs.readFileSync(path.join(DATA_DIR, 'openrouter.key'), 'utf8').trim(); } catch (e) { return ''; } } });
|
||||
audiences.init({ dataDir: DATA_DIR });
|
||||
// member erase (erase.js, 2026-11-15): the modules that keep a document in memory are scrubbed through their live copy, the rest through docstore
|
||||
erase.init({ dataDir: DATA_DIR, accounts, ads, rotator, docstore,
|
||||
owners: { 'accounts.json': accounts._json, 'audiences.json': { state: audiences._state, save: audiences._save }, 'coach.json': coach._json,
|
||||
'convtrack.json': { state: convtrack._state, save: convtrack._save }, 'earned.json': ads._earned, 'hubsync.json': { state: hubsync._state, save: hubsync._save },
|
||||
'iapsync.json': { state: iapsync._state, save: iapsync._save }, 'mail-intro.json': mailer._intro, 'postbacks.json': postbacks._json, 'registry.json': registry._json,
|
||||
'rotator.json': rotator._json, 'sponsorfollow.json': { state: followStore._state, save: followStore._save } },
|
||||
reload: {}, forget: [email => iapsync._forget(email), email => hubsync._forgetHeld(email)] });
|
||||
// link-domain pool: channels live in site.json (linkDomainChannels), check state in domains.json; a burn alerts the admin once
|
||||
domains.init({ dataDir: DATA_DIR, siteConfig, saveSite: patch => fs.writeFileSync(SITE_FILE, JSON.stringify(Object.assign(siteConfig(), patch), null, 2)),
|
||||
notify: async text => { const sc = siteConfig(); if (sc.telegramBotToken && sc.telegramAdminChatId) await telegramSend(sc.telegramAdminChatId, text); else if (ADMIN_EMAIL && mailer.hasKey()) await mailer.send(ADMIN_EMAIL, 'LinkSpin: link domain burned', text.replace(/<[^>]+>/g, '')); } });
|
||||
@@ -2376,6 +2384,13 @@ const server = http.createServer(async (req, res) => {
|
||||
spamscan.setAllow(e, !b.remove); console.log('spamscan allowlist', b.remove ? 'removed' : 'added', e);
|
||||
return json(res, 200, spamscan.view());
|
||||
}
|
||||
// member erase (2026-11-15, ticket LS-1021): {email, dryRun (default true; only dryRun: false erases), force}. erase.js
|
||||
if (p === '/api/admin/erase' && req.method === 'POST') {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||
const b = await readBody(req); const r = await erase.erase(String(b.email || ''), { dryRun: b.dryRun !== false, force: b.force === true, by: 'admin' });
|
||||
return json(res, r.error ? 400 : 200, r);
|
||||
}
|
||||
if (p === '/api/admin/erase' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, erase.view()); }
|
||||
if (p === '/api/admin/member' && req.method === 'DELETE') {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||
const e = String(u.searchParams.get('email') || '').trim().toLowerCase(); const acct = e && await accounts.byEmail(e);
|
||||
@@ -3054,7 +3069,7 @@ const server = http.createServer(async (req, res) => {
|
||||
const want = crypto.createHmac('sha256', secret).update(ts + '\n' + raw).digest('hex');
|
||||
if (want.length !== sig.length || !crypto.timingSafeEqual(Buffer.from(want), Buffer.from(sig))) return json(res, 401, { error: 'bad signature' });
|
||||
let b; try { b = JSON.parse(raw || '{}'); } catch (e) { return json(res, 400, { error: 'bad json' }); }
|
||||
const rows = Array.isArray(b.rows) ? b.rows.slice(0, 500) : [];
|
||||
const rows = (Array.isArray(b.rows) ? b.rows.slice(0, 500) : []).filter(r => !(r && erase.isErased(r.email))); // erased here (erase.js): a sync never brings them back
|
||||
// sponsor follow (2026-10-22): no engine activation may start for these people until the batch has settled their
|
||||
// sponsor (carry.hold); wallets are linked LAST, after every sponsor decision, for the same reason
|
||||
const held = rows.map(r => String(r.email || '').trim().toLowerCase()).filter(Boolean); carry.hold(held);
|
||||
|
||||
Reference in New Issue
Block a user