feat(channels): share line and zalo binary attachments via minio

This commit is contained in:
William Valentin
2026-02-17 10:45:31 -08:00
parent bfb073ca5f
commit 108641415f
8 changed files with 385 additions and 4 deletions
+42
View File
@@ -104,6 +104,48 @@ describe('LineAdapter', () => {
warnSpy.mockRestore();
});
it('uploads binary attachments to MinIO and sends share URL when configured', async () => {
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
const adapter = new LineAdapter({
channelAccessToken: 'token',
channelSecret: 'secret',
minio: {
enabled: true,
endpoint: 'localhost:9000',
accessKey: 'minio',
secretKey: 'secret',
bucket: 'flynn',
prefix: 'channels/line',
secure: false,
},
minioExecRunner: vi.fn(async (_file, args) => {
if (args[0] === 'share') {
return { stdout: '{"share":"https://minio.local/share/file.png"}\n', stderr: '' };
}
return { stdout: '', stderr: '' };
}),
});
await adapter.connect();
mockFetch.mockResolvedValue({
ok: true,
status: 200,
text: async () => '',
} as Response);
await adapter.send('U123', {
text: '',
attachments: [
{ mimeType: 'image/png', data: 'aGVsbG8=', filename: 'file.png' },
],
});
expect(mockFetch).toHaveBeenCalledTimes(1);
const body = JSON.parse(String(mockFetch.mock.calls[0]?.[1]?.body ?? '{}'));
expect(body.messages?.[0]?.text).toBe('file.png: https://minio.local/share/file.png');
expect(warnSpy).not.toHaveBeenCalled();
warnSpy.mockRestore();
});
it('send delivers URL attachment even when text is empty', async () => {
const adapter = new LineAdapter({
channelAccessToken: 'token',