Add paired delivery diagnostic logging

This commit is contained in:
Eyejoker
2026-04-04 23:58:57 +09:00
parent 80567de4ed
commit ac225f2b1e
9 changed files with 370 additions and 62 deletions

View File

@@ -113,6 +113,7 @@ vi.mock('discord.js', () => {
});
import { DiscordChannel, DiscordChannelOpts } from './discord.js';
import { logger } from '../logger.js';
// --- Test helpers ---
@@ -815,6 +816,32 @@ describe('DiscordChannel', () => {
flags: 1 << 2,
});
});
it('logs channel name and Discord message ids after sending', async () => {
const opts = createTestOpts();
const channel = new DiscordChannel('test-token', opts);
await channel.connect();
const mockChannel = {
send: vi.fn().mockResolvedValue({ id: 'discord-message-1' }),
sendTyping: vi.fn(),
};
currentClient().channels.fetch.mockResolvedValue(mockChannel);
await channel.sendMessage('dc:1234567890123456', 'Hello');
expect(logger.info).toHaveBeenCalledWith(
expect.objectContaining({
jid: 'dc:1234567890123456',
channelName: 'discord',
deliveryMode: 'send',
chunkCount: 1,
messageId: 'discord-message-1',
messageIds: ['discord-message-1'],
}),
'Discord message sent',
);
});
});
// --- ownsJid ---