diff --git a/consent-recorder/README.md b/consent-recorder/README.md index 086400b..b96c013 100644 --- a/consent-recorder/README.md +++ b/consent-recorder/README.md @@ -6,8 +6,9 @@ ## 동작 - 사이트 (`src/site.ts`): 디스코드 로그인(OAuth2 `identify` 권한만) → 동의 문구 + 체크 3개(계정 주인 · AI 음성 모델 용도 이해 · 만 14세 이상)를 모두 직접 체크해야 동의. + **녹음할 서버**도 같이 고른다 (봇과 내가 함께 들어가 있는 서버만 보이고, 하나 이상 골라야 동의). 동의한 뒤에도 사이트에서 언제든 바꿀 수 있고, 뺀 서버에서는 바로 녹음을 멈춘다. 내 상태(동의 여부 · 지금 녹음 중인 채널 · 녹음 개수/길이), 동의 철회(녹음 파일 같이 삭제 기본), 녹음 파일만 삭제, 로그아웃. -- 봇 (`src/bot.ts`): 동의한 사람이 음성채널에 들어가면 따라 들어가고, 옮기면 따라 옮기고, 동의자가 모두 나가면 나간다. +- 봇 (`src/bot.ts`): 동의한 사람이 **녹음할 서버로 고른 서버**의 음성채널에 들어가면 따라 들어가고, 옮기면 따라 옮기고, 동의자가 모두 나가면 나간다. 서버마다 음성 연결은 하나라서 한 서버에서 동의자가 여러 채널에 흩어져 있으면 지금 채널 유지 → 방금 움직인 사람 → 동의자가 많은 채널 순으로 고른다 (`src/follow.ts`). - 녹음 (`src/recorder.ts`): 디스코드가 사람별로 따로 보내는 음성 스트림 중 **동의한 사람 것만 구독**한다. 동의 안 한 사람의 소리는 받지도 저장하지도 않는다. 말이 0.8초 끊길 때마다 파일 하나(최대 30초, 0.5초 미만 버림), Opus 그대로 `data/recordings/<아이디>/<날짜>/.ogg`. 말하는 도중 철회하면 쓰던 파일도 버린다. diff --git a/consent-recorder/src/bot.ts b/consent-recorder/src/bot.ts index ab365b3..c5cb315 100644 --- a/consent-recorder/src/bot.ts +++ b/consent-recorder/src/bot.ts @@ -35,7 +35,7 @@ export class FollowBot { // 누가 봇을 끊거나 다른 채널로 옮김: 정리하고 다시 판단 (동의자가 있는 채널로 돌아감) const rec = this.recorders.get(newS.guild.id); if (newS.id === me && rec && newS.channelId !== rec.channelId) this.drop(newS.guild.id); - if (newS.id === me || this.store.isConsented(newS.id) || this.recorders.has(newS.guild.id)) { + if (newS.id === me || this.store.isConsentedIn(newS.id, newS.guild.id) || this.recorders.has(newS.guild.id)) { if (oldS.channelId && oldS.channelId !== newS.channelId) this.recorders.get(oldS.guild.id)?.stopUser(newS.id); this.schedule(newS.guild, newS.id); } @@ -53,9 +53,9 @@ export class FollowBot { await this.client.destroy(); } - /** 사이트에서 동의 · 철회한 직후: 그 사람이 있는 서버를 바로 다시 판단 */ + /** 사이트에서 동의 · 철회 · 녹음할 서버를 바꾼 직후: 그 사람이 있는 서버를 바로 다시 판단 */ consentChanged(userId: string): void { - for (const r of this.recorders.values()) if (!this.store.isConsented(userId)) r.stopUser(userId); + for (const [gid, r] of this.recorders) if (!this.store.isConsentedIn(userId, gid)) r.stopUser(userId); for (const g of this.client.guilds.cache.values()) { if (g.voiceStates.cache.get(userId)?.channelId || this.recorders.has(g.id)) this.schedule(g, userId); } @@ -66,6 +66,20 @@ export class FollowBot { for (const r of this.recorders.values()) r.stopUser(userId); } + /** 봇이 들어가 있고 이 사람도 들어가 있는 서버 (사이트에서 녹음할 서버로 고를 수 있는 곳) */ + async userGuilds(userId: string): Promise<{ id: string; name: string }[]> { + const guilds = [...this.client.guilds.cache.values()].filter((g) => this.allowedGuild(g)); + const found = await Promise.all( + guilds.map((g) => + g.members.fetch(userId).then( + () => ({ id: g.id, name: g.name }), + () => null, // 이 서버에 없는 사람 (Unknown Member) + ), + ), + ); + return found.filter((g): g is { id: string; name: string } => !!g).sort((a, b) => a.name.localeCompare(b.name, 'ko')); + } + /** 이 사람을 지금 녹음 중인 채널 이름 */ recordingNow(userId: string): string | null { for (const [gid, r] of this.recorders) { @@ -101,7 +115,7 @@ export class FollowBot { const out: Presence[] = []; for (const vs of guild.voiceStates.cache.values()) { if (!vs.channelId || vs.id === this.client.user?.id || vs.member?.user.bot) continue; - if (!this.store.isConsented(vs.id)) continue; + if (!this.store.isConsentedIn(vs.id, guild.id)) continue; const ch = vs.channel; if (ch && (ch.id === current || this.canJoin(ch))) out.push({ userId: vs.id, channelId: vs.channelId }); } @@ -138,7 +152,7 @@ export class FollowBot { } this.watch(guild, conn); const rec = new Recorder(this.store, this.cfg.dataDir, conn, guild.id, ch.id, (uid) => { - return guild.voiceStates.cache.get(uid)?.channelId === ch.id && this.store.isConsented(uid); + return guild.voiceStates.cache.get(uid)?.channelId === ch.id && this.store.isConsentedIn(uid, guild.id); }); this.recorders.set(guild.id, rec); this.updatePresence(); diff --git a/consent-recorder/src/consent-text.ts b/consent-recorder/src/consent-text.ts index 82be201..40dbf82 100644 --- a/consent-recorder/src/consent-text.ts +++ b/consent-recorder/src/consent-text.ts @@ -2,11 +2,11 @@ * 동의 문구. 문구를 바꾸면 CONSENT_VERSION 을 올린다. * 버전이 바뀌면 예전 버전에 동의한 사람은 "동의 안 함"으로 보고 녹음하지 않는다 (새 문구에 다시 동의해야 함). */ -export const CONSENT_VERSION = '2026-11-11.1'; +export const CONSENT_VERSION = '2026-11-11.2'; export function consentItems(operator: string): string[] { return [ - '녹음 봇은 내가 동의한 뒤 들어가는 디스코드 음성채널에 따라 들어와, 그 채널에서 내 목소리만 따로 녹음합니다. 같은 채널의 다른 사람 목소리는 녹음하지 않습니다.', + '녹음 봇은 내가 동의한 뒤 내가 고른 서버의 디스코드 음성채널에 들어가면 따라 들어와, 그 채널에서 내 목소리만 따로 녹음합니다. 녹음할 서버는 이 사이트에서 언제든 바꿀 수 있습니다. 같은 채널의 다른 사람 목소리는 녹음하지 않습니다.', `녹음한 목소리로 내 목소리를 흉내 내는 AI 음성 모델을 만듭니다. ${operator}이(가) 이 모델로 자기 말소리를 실시간으로 내 목소리처럼 바꿔 디스코드 · 게임 등에서 쓸 수 있습니다.`, '봇이 채널에 들어오면 채널 채팅에 녹음 안내가 남고, 봇 상태가 "녹음 중"으로 바뀝니다.', '언제든 이 사이트에서 동의를 철회할 수 있습니다. 철회하면 바로 녹음을 멈추고, 고르면 지금까지의 녹음 파일도 지웁니다. 이미 만든 음성 모델 삭제는 운영자에게 요청하면 지웁니다.', diff --git a/consent-recorder/src/db.ts b/consent-recorder/src/db.ts index bab18cd..ef3d737 100644 --- a/consent-recorder/src/db.ts +++ b/consent-recorder/src/db.ts @@ -67,6 +67,12 @@ export class Store { at INTEGER NOT NULL, detail TEXT ); + -- 동의한 사람이 녹음을 허락한 서버 (사이트에서 직접 고른다) + CREATE TABLE IF NOT EXISTS consent_guilds ( + user_id TEXT NOT NULL, + guild_id TEXT NOT NULL, + PRIMARY KEY (user_id, guild_id) + ); CREATE TABLE IF NOT EXISTS recordings ( id TEXT PRIMARY KEY, user_id TEXT NOT NULL, @@ -100,6 +106,31 @@ export class Store { return !!r && r.revoked_at === null && r.version === CONSENT_VERSION; } + /** 동의했고 이 서버를 녹음할 서버로 골랐을 때만 true */ + isConsentedIn(userId: string, guildId: string): boolean { + return this.isConsented(userId) && !!this.db.prepare('SELECT 1 FROM consent_guilds WHERE user_id = ? AND guild_id = ?').get(userId, guildId); + } + + consentGuilds(userId: string): string[] { + return (this.db.prepare('SELECT guild_id FROM consent_guilds WHERE user_id = ? ORDER BY guild_id').all(userId) as { guild_id: string }[]).map((r) => r.guild_id); + } + + /** 녹음할 서버를 통째로 바꾼다 (빈 목록이면 어디서도 녹음하지 않음) */ + setConsentGuilds(userId: string, guildIds: string[], now = Date.now()): void { + const ids = [...new Set(guildIds)].sort(); + this.db.exec('BEGIN'); + try { + this.db.prepare('DELETE FROM consent_guilds WHERE user_id = ?').run(userId); + const ins = this.db.prepare('INSERT INTO consent_guilds (user_id, guild_id) VALUES (?, ?)'); + for (const g of ids) ins.run(userId, g); + this.db.exec('COMMIT'); + } catch (e) { + this.db.exec('ROLLBACK'); + throw e; + } + this.log(userId, 'guilds', now, ids.join(',')); + } + getConsent(userId: string): ConsentRow | undefined { return this.db.prepare('SELECT * FROM consents WHERE user_id = ?').get(userId) as ConsentRow | undefined; } diff --git a/consent-recorder/src/main.ts b/consent-recorder/src/main.ts index 8055574..0f6ec8c 100644 --- a/consent-recorder/src/main.ts +++ b/consent-recorder/src/main.ts @@ -12,6 +12,7 @@ const site = createSite(cfg, store, { consentChanged: (id) => bot.consentChanged(id), discardActive: (id) => bot.discardActive(id), recordingNow: (id) => bot.recordingNow(id), + userGuilds: (id) => bot.userGuilds(id), }); site.listen(cfg.port, cfg.host, () => console.log(`[site] ${cfg.publicUrl} (http://${cfg.host}:${cfg.port})`)); diff --git a/consent-recorder/src/site.ts b/consent-recorder/src/site.ts index b97ae1c..7b453a7 100644 --- a/consent-recorder/src/site.ts +++ b/consent-recorder/src/site.ts @@ -11,6 +11,8 @@ export interface SiteHooks { discardActive(userId: string): void; /** 이 사람이 지금 녹음되고 있는 채널 이름 (없으면 null) */ recordingNow(userId: string): string | null; + /** 봇과 이 사람이 함께 들어가 있는 서버 (녹음할 서버로 고를 수 있는 곳) */ + userGuilds(userId: string): Promise<{ id: string; name: string }[]>; } const esc = (s: string) => s.replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]!); @@ -27,7 +29,7 @@ button,.btn{display:inline-block;border:0;border-radius:10px;padding:11px 18px;f button.danger{background:var(--danger)}button.ghost{background:transparent;color:var(--muted);padding:6px 0} .status{font-weight:700}.status.on{color:var(--ok)}.status.off{color:var(--muted)}.rec{color:var(--danger);font-weight:700} .err{background:#fde7e9;color:#8a1c1c;border-radius:10px;padding:10px 14px} -form.inline{display:inline} +form.inline{display:inline}fieldset{border:0;padding:0;margin:12px 0}legend{font-weight:700;padding:0} `; function page(title: string, body: string): string { @@ -132,7 +134,25 @@ ${error ? `

${esc(error)}

` : ''} ); } - function home(s: SessionRow, error?: string): string { + /** 녹음할 서버 체크박스 (봇과 함께 있는 서버만) */ + function guildChecks(guilds: { id: string; name: string }[], picked: Set): string { + if (!guilds.length) return '

봇이 들어가 있는 디스코드 서버에 함께 들어가 있지 않습니다. 서버에 들어간 뒤 새로고침해 주세요.

'; + return `
녹음할 서버

고른 서버의 음성채널에서만 봇이 따라 들어와 녹음합니다.

+${guilds.map((g) => ``).join('')}
`; + } + + /** form 에서 고른 서버. 봇과 함께 있지 않은 서버를 보내면 거절 */ + async function pickedGuilds(s: SessionRow, form: URLSearchParams): Promise { + const mine = new Set((await hooks.userGuilds(s.user_id)).map((g) => g.id)); + const picked = [...new Set(form.getAll('guild'))]; + if (picked.some((g) => !mine.has(g))) throw new HttpError(400, '고를 수 없는 서버입니다. 새로고침한 뒤 다시 해 주세요'); + return picked; + } + + async function home(s: SessionRow, error?: string): Promise { + const guilds = await hooks.userGuilds(s.user_id); + const picked = new Set(store.consentGuilds(s.user_id)); + const pickedNames = guilds.filter((g) => picked.has(g.id)).map((g) => esc(g.name)); const c = store.getConsent(s.user_id); const on = store.isConsented(s.user_id); const stats = store.recordingStats(s.user_id); @@ -142,19 +162,23 @@ ${error ? `

${esc(error)}

` : ''} const stale = c && c.revoked_at === null && c.version !== CONSENT_VERSION; const status = on ? `

● 녹음 동의함

${fmtTime(c!.consented_at)}에 동의 (문구 버전 ${esc(c!.version)})

- ${live ? `

🔴 지금 “${esc(live)}” 채널에서 내 목소리를 녹음하고 있습니다

` : '

지금은 녹음하고 있지 않습니다. 음성채널에 들어가면 봇이 따라 들어옵니다.

'}` + ${live ? `

🔴 지금 “${esc(live)}” 채널에서 내 목소리를 녹음하고 있습니다

` : '

지금은 녹음하고 있지 않습니다. 고른 서버의 음성채널에 들어가면 봇이 따라 들어옵니다.

'} +

녹음할 서버: ${pickedNames.length ? pickedNames.join(', ') : '없음 (어디서도 녹음하지 않음)'}

` : `

○ 녹음하지 않음

${ stale ? '

동의 문구가 바뀌어서 다시 동의해야 녹음합니다.

' : c?.revoked_at ? `

${fmtTime(c.revoked_at)}에 동의를 철회했습니다.

` : '' }`; const consentForm = on - ? `

동의 철회

철회하면 바로 녹음을 멈추고 봇이 나를 따라오지 않습니다.

+ ? `

녹음할 서버 바꾸기

${csrf} +${guildChecks(guilds, picked)}${guilds.length ? '' : ''}
+

동의 철회

철회하면 바로 녹음을 멈추고 봇이 나를 따라오지 않습니다.

${csrf}
` : `

녹음 동의

    ${consentItems(esc(cfg.operatorName)).map((t) => `
  • ${t}
  • `).join('')}
${csrf} +${guildChecks(guilds, picked)} ${Object.entries(CONSENT_CHECKS).map(([k, t]) => ``).join('')} -
`; +${guilds.length ? '' : ''}
`; return page( '목소리 녹음 동의', `

${name}님

디스코드 아이디 ${esc(s.user_id)}

@@ -193,7 +217,7 @@ ${consentForm} return send(res, 200, JSON.stringify({ ok: true }), 'application/json'); case 'GET /': { const cur = currentSession(req); - return send(res, 200, cur ? home(cur.s) : landing()); + return send(res, 200, cur ? await home(cur.s) : landing()); } case 'GET /login': { // state 를 이 브라우저 쿠키에도 넣어 둔다: 남이 받은 callback 주소를 열어도 그 사람 계정으로 로그인되지 않게 @@ -217,13 +241,23 @@ ${consentForm} case 'POST /consent': { const { s, form } = await authedForm(req); const missing = Object.keys(CONSENT_CHECKS).filter((k) => form.get(k) !== '1'); - if (missing.length) return send(res, 400, home(s, '모든 항목에 직접 체크해야 동의할 수 있습니다.')); + if (missing.length) return send(res, 400, await home(s, '모든 항목에 직접 체크해야 동의할 수 있습니다.')); // 예전 문구를 띄워 둔 화면에서 낸 동의는 받지 않는다 - if (form.get('version') !== CONSENT_VERSION) return send(res, 409, home(s, '동의 문구가 바뀌었습니다. 바뀐 내용을 읽고 다시 동의해 주세요.')); + if (form.get('version') !== CONSENT_VERSION) return send(res, 409, await home(s, '동의 문구가 바뀌었습니다. 바뀐 내용을 읽고 다시 동의해 주세요.')); + const guilds = await pickedGuilds(s, form); + if (!guilds.length) return send(res, 400, await home(s, '녹음할 서버를 하나 이상 골라 주세요.')); + store.setConsentGuilds(s.user_id, guilds); store.consent({ id: s.user_id, username: s.username, global_name: s.display_name }); hooks.consentChanged(s.user_id); return redirect(res, '/'); } + case 'POST /guilds': { + const { s, form } = await authedForm(req); + if (!store.isConsented(s.user_id)) return send(res, 400, await home(s, '먼저 녹음에 동의해 주세요.')); + store.setConsentGuilds(s.user_id, await pickedGuilds(s, form)); + hooks.consentChanged(s.user_id); // 빠진 서버에서는 바로 녹음을 멈추고, 더한 서버에는 따라 들어간다 + return redirect(res, '/'); + } case 'POST /revoke': { const { s, form } = await authedForm(req); store.revoke(s.user_id); diff --git a/consent-recorder/test/bot.test.ts b/consent-recorder/test/bot.test.ts index c578d4c..0726c9b 100644 --- a/consent-recorder/test/bot.test.ts +++ b/consent-recorder/test/bot.test.ts @@ -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(); +}); diff --git a/consent-recorder/test/consent.test.ts b/consent-recorder/test/consent.test.ts index baf85f7..4bd5b2e 100644 --- a/consent-recorder/test/consent.test.ts +++ b/consent-recorder/test/consent.test.ts @@ -53,6 +53,10 @@ before(async () => { consentChanged: (id) => changed.push(id), discardActive: (id) => events.push(`discard:${id}:${store.recordingStats(id).count}`), recordingNow: () => null, + userGuilds: async () => [ + { id: 'g1', name: '첫째 서버' }, + { id: 'g2', name: '둘째 서버' }, + ], }); await new Promise((r) => site.listen(port, '127.0.0.1', r)); }); @@ -65,7 +69,7 @@ after(() => { }); const get = (p: string, cookie = '') => fetch(base + p, { redirect: 'manual', headers: cookie ? { cookie } : {} }); -const post = (p: string, cookie: string, form: Record) => +const post = (p: string, cookie: string, form: Record | string[][]) => fetch(base + p, { method: 'POST', redirect: 'manual', headers: { cookie, 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams(form) }); async function login(): Promise<{ cookie: string; csrf: string }> { @@ -116,12 +120,31 @@ test('디스코드 로그인 → 모든 항목 체크해야 동의 → 철회하 assert.equal((await post('/consent', cookie, { csrf, self: '1', model: '1', age: '1' })).status, 409); assert.equal((await post('/consent', cookie, { csrf, version: 'old', self: '1', model: '1', age: '1' })).status, 409); assert.equal(store.isConsented(USER.id), false); - const version = /name="version" value="([^"]+)"/.exec(await (await get('/', cookie)).text())![1]; + const page0 = await (await get('/', cookie)).text(); + const version = /name="version" value="([^"]+)"/.exec(page0)![1]; assert.equal(version, CONSENT_VERSION); - assert.equal((await post('/consent', cookie, { csrf, version, self: '1', model: '1', age: '1' })).status, 303); + // 봇과 함께 있는 서버만 고를 수 있고, 하나 이상 골라야 동의된다 + assert.match(page0, /name="guild" value="g1"[^>]*>첫째 서버/); + const ok = { csrf, version, self: '1', model: '1', age: '1' }; + assert.equal((await post('/consent', cookie, ok)).status, 400); + assert.equal((await post('/consent', cookie, { ...ok, guild: 'other' })).status, 400); + assert.equal(store.isConsented(USER.id), false); + assert.equal((await post('/consent', cookie, [...Object.entries(ok), ['guild', 'g1'], ['guild', 'g2']])).status, 303); assert.equal(store.isConsented(USER.id), true); + assert.deepEqual(store.consentGuilds(USER.id), ['g1', 'g2']); assert.deepEqual(changed, [USER.id]); - assert.match(await (await get('/', cookie)).text(), /녹음 동의함/); + assert.match(await (await get('/', cookie)).text(), /녹음 동의함[\s\S]*녹음할 서버: 첫째 서버, 둘째 서버/); + + // 녹음할 서버 바꾸기: 뺀 서버는 녹음하지 않는다. 다 빼면 어디서도 녹음하지 않음 + assert.equal((await post('/guilds', cookie, { csrf, guild: 'other' })).status, 400); + assert.equal((await post('/guilds', cookie, { csrf, guild: 'g2' })).status, 303); + assert.deepEqual(changed, [USER.id, USER.id]); + assert.equal(store.isConsentedIn(USER.id, 'g1'), false); + assert.equal(store.isConsentedIn(USER.id, 'g2'), true); + assert.equal((await post('/guilds', cookie, { csrf })).status, 303); + assert.equal(store.isConsentedIn(USER.id, 'g2'), false); + assert.match(await (await get('/', cookie)).text(), /녹음할 서버: 없음/); + assert.equal((await post('/guilds', cookie, { csrf, guild: 'g1' })).status, 303); // 녹음 파일 하나 있다고 치고 철회 + 삭제 const f = path.join(tmp, 'recordings', USER.id, 'a.ogg'); @@ -139,7 +162,9 @@ test('디스코드 로그인 → 모든 항목 체크해야 동의 → 철회하 assert.equal(store.isConsented(USER.id), false); assert.equal(fs.existsSync(f), false); assert.equal(store.recordingStats(USER.id).count, 0); - assert.deepEqual(store.consentLog(USER.id).map((l) => l.action), ['consent', 'delete_recordings', 'revoke', 'delete_recordings']); + assert.deepEqual(store.consentLog(USER.id).map((l) => l.action), ['guilds', 'consent', 'guilds', 'guilds', 'guilds', 'delete_recordings', 'revoke', 'delete_recordings']); + // 철회한 뒤에는 서버를 바꿀 수 없다 + assert.equal((await post('/guilds', cookie, { csrf, guild: 'g1' })).status, 400); // 로그아웃하면 세션 끝 assert.equal((await post('/logout', cookie, { csrf })).status, 303);