consent-recorder: fix review findings

- /delete discards the in-progress utterance before deleting files
- keep the current channel even when the bot itself fills it (joinable=false)
- bind OAuth state to the browser via a short-lived cookie
- reject consent submitted from a page showing an older consent version
- regression tests for all four

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-11 11:47:07 +09:00
parent 6e0801ea1c
commit 8da3e713d0
7 changed files with 122 additions and 17 deletions

View File

@@ -62,3 +62,28 @@ test('동의한 사람만 구독해서 저장하고, 철회하면 쓰던 파일
store.close();
fs.rmSync(tmp, { recursive: true, force: true });
});
test('파일 삭제 직전 진행 중인 녹음을 버리면 삭제 뒤에 남지 않는다', async () => {
const tmp = fs.mkdtempSync(path.join(os.homedir(), '.tmp-rec-'));
const store = new Store(':memory:');
store.consent({ id: 'yes', username: 'y' });
const conn = fakeConnection();
const rec = new Recorder(store, tmp, conn, 'g', 'c', (uid) => store.isConsented(uid));
conn.receiver.speaking.emit('start', 'yes');
const s = conn.receiver.subscriptions.get('yes')!;
for (let i = 0; i < 30; i++) s.write(OPUS_20MS); // 600ms, 아직 진행 중
await new Promise((r) => setImmediate(r));
rec.stopUser('yes'); // 사이트 /delete → discardActive
store.deleteRecordings('yes');
s.end();
await new Promise((r) => setImmediate(r));
assert.equal(store.recordings('yes').length, 0);
const left = fs.readdirSync(tmp, { recursive: true }).filter((f) => String(f).endsWith('.ogg'));
assert.deepEqual(left, []);
// 동의는 그대로라 다시 말하면 새로 녹음한다
conn.receiver.speaking.emit('start', 'yes');
assert.equal(conn.receiver.subscriptions.has('yes'), true);
rec.close();
store.close();
fs.rmSync(tmp, { recursive: true, force: true });
});