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

@@ -61,6 +61,11 @@ export class FollowBot {
}
}
/** 이 사람의 진행 중인 녹음을 버린다 (구독도 끊음. 다시 말하면 동의 상태대로 새로 녹음) */
discardActive(userId: string): void {
for (const r of this.recorders.values()) r.stopUser(userId);
}
/** 이 사람을 지금 녹음 중인 채널 이름 */
recordingNow(userId: string): string | null {
for (const [gid, r] of this.recorders) {
@@ -87,13 +92,18 @@ export class FollowBot {
return !!p?.has(PermissionFlagsBits.ViewChannel) && p.has(PermissionFlagsBits.Connect) && ch.joinable;
}
private consentedPresence(guild: Guild): Presence[] {
/**
* 동의자가 있는 채널 목록. 봇이 이미 들어가 있는 채널은 입장 가능 여부를 다시 보지 않는다
* (봇이 들어가 정원이 차면 joinable 이 false 가 되어 나갔다 들어오기를 반복하던 것)
*/
consentedPresence(guild: Guild): Presence[] {
const current = this.recorders.get(guild.id)?.channelId ?? null;
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;
const ch = vs.channel;
if (ch && this.canJoin(ch)) out.push({ userId: vs.id, channelId: vs.channelId });
if (ch && (ch.id === current || this.canJoin(ch))) out.push({ userId: vs.id, channelId: vs.channelId });
}
return out;
}