fix: only use downloaded media paths for quoted images

This commit is contained in:
liuwei
2026-04-07 17:50:08 +08:00
parent f9417a201f
commit d99f1a07d1
2 changed files with 27 additions and 10 deletions

View File

@@ -18,6 +18,19 @@ def _is_emoji_message(msg: dict) -> bool:
return message_type in {'47', '1048625', '1090519089'} or any(marker in content for marker in xml_markers)
def _is_usable_local_media_path(value: str) -> bool:
if not value:
return False
value = str(value).strip()
if value.startswith(('http://', 'https://')):
return True
if 'static/images' in value or 'static\\images' in value:
return True
if '/' in value or '\\' in value:
return True
return False
def _proxy_remote_media(target_url: str) -> Response:
if not target_url:
return Response("missing url", status=400)
@@ -117,17 +130,11 @@ def get_messages():
referenced_msg = server.message_storage.get_message_by_message_id(reference_svrid)
if referenced_msg:
if msg['quoted_type'] == 'image':
msg['quoted_preview_image'] = (
referenced_msg.get('image_path')
or referenced_msg.get('message_thumb')
or msg['quoted_preview_image']
)
image_path = referenced_msg.get('image_path') or ''
msg['quoted_preview_image'] = image_path if _is_usable_local_media_path(image_path) else ''
elif msg['quoted_type'] == 'video':
msg['quoted_preview_video_thumb'] = (
referenced_msg.get('message_thumb')
or referenced_msg.get('image_path')
or msg['quoted_preview_video_thumb']
)
video_thumb = referenced_msg.get('message_thumb') or referenced_msg.get('image_path') or ''
msg['quoted_preview_video_thumb'] = video_thumb if _is_usable_local_media_path(video_thumb) else ''
else:
# 其他类型的应用消息,解析 XML 提取标题
root = ET.fromstring(msg['content'])

View File

@@ -98,6 +98,9 @@
<div class="message-media-label">【引用图片】</div>
<img :src="getQuotedPreviewUrl(scope.row.quoted_preview_image)" class="message-thumb" @click="showQuotedImage(scope.row.quoted_preview_image)">
</div>
<div v-else-if="scope.row.quoted_type === 'image'" class="quoted-media-text">
【图片消息】
</div>
<div v-else-if="scope.row.quoted_type === 'video' && scope.row.quoted_preview_video_thumb" class="quoted-media-preview">
<div class="message-media-label">【引用视频】</div>
<img :src="scope.row.quoted_preview_video_thumb" class="message-thumb">
@@ -479,6 +482,13 @@
gap: 8px;
}
.quoted-media-text {
margin-top: 8px;
color: #64748b;
font-size: 13px;
font-weight: 600;
}
.message-media-label {
font-size: 12px;
color: #64748b;