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

+9 -1
View File
@@ -550,7 +550,7 @@ export class ForwardApi {
forwardResCache.set(resId, uploadReadyNodes.map(node => ({
userUin: node.userUin,
nickname: node.nickname,
elements: [...node.elements],
elements: node.elements.map(cacheableForwardElement),
time: node.time,
msgId: node.msgId,
msgSeq: node.msgSeq,
@@ -854,6 +854,14 @@ export class ForwardApi {
}
}
function cacheableForwardElement(element: MessageElement): MessageElement {
if (element.type !== 'image') return element;
if (element.imageUrl || element.fileId || element.md5Hex) return element;
const source = (element.url ?? '').trim();
if (!source) return element;
return { ...element, imageUrl: source };
}
function cloneNodes(nodes: ForwardNodePayload[]): ForwardNodePayload[] {
return nodes.map(node => ({
userUin: node.userUin,