From cbb01085c48fd6a36ee2a7410811837a1c1388b1 Mon Sep 17 00:00:00 2001 From: Austin Date: Wed, 23 Sep 2026 21:37:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(reply):=20=E4=BF=AE=E5=A4=8D=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E6=B6=88=E6=81=AF=E4=B8=AD=E5=AA=92=E4=BD=93=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E5=85=BC=E5=AE=B9=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 适配了 Drafty 媒体的 `refurl` 字段,同时兼容旧的 `ref` 和 `val` 字段,确保不同来源的媒体链接都能正确解析用于渲染。 --- web/src/lib/messages/reply.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/web/src/lib/messages/reply.ts b/web/src/lib/messages/reply.ts index accf57c2..1981e899 100644 --- a/web/src/lib/messages/reply.ts +++ b/web/src/lib/messages/reply.ts @@ -175,10 +175,17 @@ function draftyEntityMedia(msg: StoredMessage): QuoteMedia | null { // Prefer the first matching media entity -- a quoted message carries one primary attachment. for (const ent of doc.ent) { const data = ent.data || {}; - const asImage = () => - (typeof data.ref === 'string' || typeof data.val === 'string') - ? { image: { ref: typeof data.ref === 'string' ? data.ref : undefined, val: typeof data.val === 'string' ? data.val : undefined, mime: typeof data.mime === 'string' ? data.mime : undefined } } + const asImage = () => { + // This deployment's Drafty media carries its upload URL in `refurl` (both webapp-sent and + // script/iOS-sent messages -- see attachments.ts), with tinode's classic `ref`/inline `val` + // as the other accepted carriers. Missing all three -> not locally renderable. + const ref = + typeof data.refurl === 'string' ? data.refurl : typeof data.ref === 'string' ? data.ref : undefined; + const val = typeof data.val === 'string' ? data.val : undefined; + return ref || val + ? { image: { ref, val, mime: typeof data.mime === 'string' ? data.mime : undefined } } : null; + }; switch (ent.tp) { case 'IM': { const image = asImage();