fix(onebot): keep image sources when reading bot-built forwards

get_forward_msg treated pictures inside a just-sent merge as empty.
Keep the original media source so file or url comes back.

Fixes #441
This commit is contained in:
DrSmoothl committed 2026-09-13 21:14:41 +08:00
1 parent 26fe4e5fb5
commit 48ce95f53e
5 files changed
+105 -4

No files matched your search

@@ -1283,6 +1283,35 @@ describe('buildApiContext send and forward dispatch', () => {
}]);
expect(fetch).toHaveBeenCalledWith('res-abc');
});
it('returns file/url for a cached bot-built image node (#441)', async () => {
const source = 'https://cdn.example/bot-built.png';
const fetch = vi.fn(async () => [{
messageType: 'group',
userUin: PEER_ID,
nickname: 'peer',
time: 1_725_000_100,
msgId: 11,
msgSeq: 12,
groupId: GROUP_ID,
elements: [{ type: 'image', url: source }],
}]);
const { api } = makeRef({
apis: { forward: { upload: vi.fn(), fetch } },
});
const messages = await api.getForwardMsg('res-img');
expect(messages).toHaveLength(1);
expect(messages[0]!.message).toEqual([{
type: 'image',
data: {
url: source,
file: source,
sub_type: 0,
summary: '',
},
}]);
});
});
describe('buildApiContext history', () => {