fix(onebot): stop storing inline image payloads in the media cache

Large base64 image sources were written into the media database as keys
and row data, which could freeze the process on slow disks. The cache
now keeps only short identifiers and metadata.

Fixes #463
This commit is contained in:
DrSmoothl committed 2026-09-18 00:11:59 +08:00
1 parent 2a515c165c
commit ce050d1ba1
4 files changed
+259 -23

No files matched your search

@@ -436,6 +436,30 @@ describe('convertEvent — message elements', () => {
});
});
it('image: does not emit inline base64 as file/url (#463)', async () => {
const source = `base64://${'A'.repeat(32)}`;
const seg = await segment({ type: 'image', url: source });
expect(seg).toEqual({
type: 'image',
data: {
url: '',
file: '',
sub_type: 0,
summary: '',
},
});
});
it('image: keeps fileId when the only source is inline (#463)', async () => {
const seg = await segment({
type: 'image',
fileId: 'fid',
url: `base64://${'A'.repeat(32)}`,
});
expect((seg.data as Record<string, unknown>).file).toBe('fid');
expect((seg.data as Record<string, unknown>).url).toBe('');
});
it('image: resolver sees the upload source when only url is present (#441)', async () => {
const source = 'https://cdn.example/bot-built.png';
const seen: string[] = [];