consent-recorder: let each consenter pick which servers to record in

The site lists only servers the bot and the user share (single-member REST
fetch, no privileged intent). Consent requires at least one server; the
choice can be changed later and removed servers stop recording at once.
Consent text mentions the server choice, so CONSENT_VERSION is bumped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-11 20:53:14 +09:00
parent 3a40645b12
commit f45d349f96
8 changed files with 152 additions and 21 deletions

View File

@@ -20,6 +20,8 @@ test('봇이 들어가 정원이 찬 지금 채널의 동의자는 그대로 따
const store = new Store(':memory:');
store.consent({ id: 'u1', username: 'a' });
store.consent({ id: 'u2', username: 'b' });
store.setConsentGuilds('u1', ['g']);
store.setConsentGuilds('u2', ['g']);
const cfg = loadConfig({ PUBLIC_URL: 'http://localhost', DISCORD_CLIENT_ID: 'c', DISCORD_CLIENT_SECRET: 's' }, false);
const bot = new FollowBot(cfg, store);
const guild = fakeGuild();
@@ -30,3 +32,26 @@ test('봇이 들어가 정원이 찬 지금 채널의 동의자는 그대로 따
await bot.client.destroy();
store.close();
});
test('녹음할 서버로 고르지 않은 서버에서는 동의자라도 따라가지 않는다', async () => {
const store = new Store(':memory:');
store.consent({ id: 'u1', username: 'a' });
store.consent({ id: 'u2', username: 'b' });
store.setConsentGuilds('u1', ['g']);
store.setConsentGuilds('u2', ['other']);
const cfg = loadConfig({ PUBLIC_URL: 'http://localhost', DISCORD_CLIENT_ID: 'c', DISCORD_CLIENT_SECRET: 's' }, false);
const bot = new FollowBot(cfg, store);
const guild = fakeGuild();
(bot as any).recorders.set('g', { channelId: 'A' });
assert.deepEqual(bot.consentedPresence(guild), [{ userId: 'u1', channelId: 'A' }]);
// 서버를 빼면 진행 중인 녹음도 멈춘다
const stopped: string[] = [];
(bot as any).recorders.set('g', { channelId: 'A', stopUser: (id: string) => stopped.push(id) });
store.setConsentGuilds('u1', []);
bot.consentChanged('u1');
assert.deepEqual(stopped, ['u1']);
assert.deepEqual(bot.consentedPresence(guild), []);
(bot as any).recorders.clear();
await bot.client.destroy();
store.close();
});