fix(reply): 修复回复消息中媒体引用的兼容性问题

适配了 Drafty 媒体的 `refurl` 字段,同时兼容旧的 `ref` 和 `val` 字段,确保不同来源的媒体链接都能正确解析用于渲染。
This commit is contained in:
Austin
2026-09-23 21:37:07 +08:00
parent a8d3504424
commit cbb01085c4
+10 -3
View File
@@ -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();