refactor: cut over room mode from paired legacy

This commit is contained in:
Eyejoker
2026-03-31 14:47:59 +09:00
parent f04e5d06b3
commit 509e4c24a3
12 changed files with 245 additions and 68 deletions

View File

@@ -29,10 +29,10 @@ vi.mock('../logger.js', () => ({
},
}));
const isPairedRoomJidMock = vi.hoisted(() => vi.fn(() => false));
const hasReviewerLeaseMock = vi.hoisted(() => vi.fn(() => false));
vi.mock('../db.js', () => ({
isPairedRoomJid: isPairedRoomJidMock,
vi.mock('../service-routing.js', () => ({
hasReviewerLease: hasReviewerLeaseMock,
}));
// --- discord.js mock ---
@@ -206,7 +206,7 @@ async function triggerMessage(message: any) {
describe('DiscordChannel', () => {
beforeEach(() => {
vi.clearAllMocks();
isPairedRoomJidMock.mockReturnValue(false);
hasReviewerLeaseMock.mockReturnValue(false);
});
afterEach(() => {
@@ -343,7 +343,7 @@ describe('DiscordChannel', () => {
});
it('delivers other bot messages in paired rooms', async () => {
isPairedRoomJidMock.mockReturnValue(true);
hasReviewerLeaseMock.mockReturnValue(true);
const opts = createTestOpts();
const channel = new DiscordChannel('test-token', opts);

View File

@@ -17,10 +17,10 @@ import {
DATA_DIR,
TRIGGER_PATTERN,
} from '../config.js';
import { isPairedRoomJid } from '../db.js';
import { getEnv } from '../env.js';
import { logger } from '../logger.js';
import { formatOutbound } from '../router.js';
import { hasReviewerLease } from '../service-routing.js';
const ATTACHMENTS_DIR = path.join(DATA_DIR, 'attachments');
const TRANSCRIPTION_CACHE_DIR = path.join(CACHE_DIR, 'transcriptions');
@@ -214,7 +214,7 @@ export class DiscordChannel implements Channel {
const chatJid = `dc:${channelId}`;
const isOwnBotMessage = message.author.id === this.client?.user?.id;
if (isOwnBotMessage) return;
if (message.author.bot && !isPairedRoomJid(chatJid)) return;
if (message.author.bot && !hasReviewerLease(chatJid)) return;
let content = message.content;
const timestamp = message.createdAt.toISOString();