Member erase: their username leaves the messages that stay (another member's chat to them, a notice to their sponsor about them), whole words, 5+ characters; names option for a second pass after the account is gone; residue sweep also finds a long username inside text (REGEXP whole word)
Found on the LS-1021 erase: two kept messages still said "rajumiddha". qa/erase.mysql.test.cjs 3 pass (disposable mysql:8 on core), qa/erase.test.cjs 6 pass. NOT deployed (one InstantAdPay deploy today for this lane); ships with the next one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+10
-3
@@ -39,7 +39,7 @@ const E = 'gone9@example.test', O = 'other9@example.test';
|
||||
await q("INSERT INTO account_signals (email, signup_ip) VALUES (?, '1.2.3.4')", [E]);
|
||||
await q("INSERT INTO adoptions (adoptee, adopter, ts, expires) VALUES (?, ?, 1, 2)", [E, O]);
|
||||
await q("INSERT INTO event_marks (k, ts) VALUES (?, 1), ('keep:other', 1)", ['tankpay1:' + E + ':17']);
|
||||
await q("INSERT INTO sponsor_messages (from_member, from_email, to_email, subject, body, sent, kind) VALUES (0, ?, ?, '', 'their words', 1, 'chat'), (0, ?, ?, '', 'my words', 2, 'chat'), (1, 'admin@example.test', ?, 'Your ad', 'n', 3, 'notice')", [E, O, O, E, E]);
|
||||
await q("INSERT INTO sponsor_messages (from_member, from_email, to_email, subject, body, sent, kind) VALUES (0, ?, ?, '', 'their words', 1, 'chat'), (0, ?, ?, '', 'my words', 2, 'chat'), (1, 'admin@example.test', ?, 'Your ad', 'n', 3, 'notice'), (1, 'admin@example.test', ?, '@goneuser9 has not switched on payouts', '<p>@goneuser9 needs a nudge; goneuser99 is someone else</p>', 4, 'notice')", [E, O, O, E, E, O]);
|
||||
const tk = await q("INSERT INTO tickets (ref, platform, email, name, username, subject, category, created, updated) VALUES ('LS-9001', 'linkspin', ?, 'Gone Person', 'goneuser9', 'delete me', 'account', 1, 1)", [E]);
|
||||
await q("INSERT INTO ticket_messages (ticket_id, author, body, created) VALUES (?, 'member', 'please delete gone9@example.test', 1), (?, 'admin', 'Done.', 2)", [tk.insertId, tk.insertId]);
|
||||
let fails = 0;
|
||||
@@ -60,11 +60,18 @@ const E = 'gone9@example.test', O = 'other9@example.test';
|
||||
assert.strictEqual(await one('SELECT COUNT(*) n FROM accounts WHERE email=?', [E]), 0); assert.strictEqual(await one('SELECT COUNT(*) n FROM accounts WHERE email=?', [O]), 1);
|
||||
assert.strictEqual(await one('SELECT COUNT(*) n FROM campaigns WHERE id=?', [cid]), 0); assert.strictEqual(await one('SELECT COUNT(*) n FROM visit_seen WHERE campaign_id=?', [cid]), 0);
|
||||
assert.strictEqual(await one('SELECT COUNT(*) n FROM earned_credits WHERE email=?', [O]), 1); assert.strictEqual(await one("SELECT COUNT(*) n FROM event_marks WHERE k='keep:other'"), 1);
|
||||
const msgs = await q('SELECT from_email, to_email, body FROM sponsor_messages ORDER BY sent');
|
||||
assert.deepStrictEqual(msgs.map(m => [m.from_email, m.body]), [[O, 'my words']]); assert.ok(/^erased-[0-9a-f]{12}@erased\.invalid$/.test(msgs[0].to_email));
|
||||
const msgs = await q('SELECT from_email, to_email, subject, body FROM sponsor_messages ORDER BY sent');
|
||||
assert.deepStrictEqual(msgs.map(m => [m.from_email, m.body]), [[O, 'my words'], ['admin@example.test', '<p>[erased member] needs a nudge; goneuser99 is someone else</p>']]); assert.ok(/^erased-[0-9a-f]{12}@erased\.invalid$/.test(msgs[0].to_email));
|
||||
assert.strictEqual(msgs[1].subject, '[erased member] has not switched on payouts', 'a notice to someone else about them keeps its text, not their name'); assert.strictEqual(r.sql['sponsor_messages (others, name removed)'], 1);
|
||||
const [tkt] = await q("SELECT email, name, username FROM tickets WHERE ref='LS-9001'"); assert.ok(/@erased\.invalid$/.test(tkt.email)); assert.strictEqual(tkt.name, null);
|
||||
const tm = await q('SELECT author, body FROM ticket_messages ORDER BY id'); assert.ok(/removed/.test(tm[0].body)); assert.strictEqual(tm[1].body, 'Done.');
|
||||
assert.deepStrictEqual(JSON.parse((await q('SELECT chat_mutes FROM accounts WHERE email=?', [O]))[0].chat_mutes), ['x@example.test']);
|
||||
});
|
||||
await t('a second pass with names cleans a username left in a kept message after the account is gone', async () => {
|
||||
await q("INSERT INTO sponsor_messages (from_member, from_email, to_email, subject, body, sent, kind) VALUES (0, ?, ?, '', 'Hey goneuser9, welcome', 9, 'chat')", [O, 'x@example.test']);
|
||||
const r = await erase.erase(E, { dryRun: false, names: ['goneuser9'] });
|
||||
assert.strictEqual(r.found, false); assert.strictEqual(r.sql['sponsor_messages (others, name removed)'], 1); assert.deepStrictEqual(r.residue, []);
|
||||
assert.strictEqual((await q('SELECT body FROM sponsor_messages WHERE sent=9'))[0].body, 'Hey [erased member], welcome');
|
||||
});
|
||||
console.log(fails ? fails + ' FAILED' : 'erase mysql: all passed'); process.exit(fails ? 1 : 0);
|
||||
})().catch(e => { console.error(e); process.exit(1); });
|
||||
|
||||
Reference in New Issue
Block a user