fix: fallback quoted image lookup by md5
This commit is contained in:
@@ -123,18 +123,24 @@ def get_messages():
|
||||
msg['quoted_preview_image'] = quote_data.get('preview_image', '')
|
||||
msg['quoted_preview_video_thumb'] = quote_data.get('preview_video_thumb', '')
|
||||
msg['quoted_reference_svrid'] = quote_data.get('reference_svrid', '')
|
||||
msg['quoted_reference_md5'] = quote_data.get('reference_md5', '')
|
||||
|
||||
# 优先使用原始被引用消息自己已落库的图片/缩略图地址
|
||||
reference_svrid = quote_data.get('reference_svrid')
|
||||
reference_md5 = quote_data.get('reference_md5')
|
||||
referenced_msg = None
|
||||
if reference_svrid:
|
||||
referenced_msg = server.message_storage.get_message_by_message_id(reference_svrid)
|
||||
if referenced_msg:
|
||||
if msg['quoted_type'] == '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':
|
||||
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 ''
|
||||
if not referenced_msg and reference_md5 and msg['quoted_type'] == 'image':
|
||||
referenced_msg = server.message_storage.get_image_message_by_md5(reference_md5)
|
||||
|
||||
if referenced_msg:
|
||||
if msg['quoted_type'] == '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':
|
||||
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'])
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
|
||||
<div v-else class="message-text-preview is-muted">
|
||||
{% raw %}{{ scope.row.content || `【消息类型: ${scope.row.message_type}】` }}{% endraw %}
|
||||
<div v-if="scope.row.quoted_type === 'image' && scope.row.quoted_preview_image" class="quoted-media-preview">
|
||||
<div v-if="scope.row.quoted_type === 'image' && hasQuotedPreview(scope.row.quoted_preview_image)" class="quoted-media-preview">
|
||||
<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>
|
||||
@@ -323,6 +323,7 @@
|
||||
},
|
||||
showQuotedImage(url) {
|
||||
const resolvedUrl = this.getQuotedPreviewUrl(url);
|
||||
if (!resolvedUrl) return;
|
||||
this.selectedMessage = { image_path: '', message_thumb: resolvedUrl };
|
||||
this.imageDialogVisible = true;
|
||||
},
|
||||
@@ -373,8 +374,27 @@
|
||||
}
|
||||
return `/api/messages/media_proxy?url=${encodeURIComponent(url)}`;
|
||||
},
|
||||
isUsableQuotedPreview(url) {
|
||||
if (!url) return false;
|
||||
if (url.startsWith('http://') || url.startsWith('https://')) {
|
||||
return true;
|
||||
}
|
||||
if (url.includes('static/images') || url.includes('static\\images')) {
|
||||
return true;
|
||||
}
|
||||
if (url.includes('/') || url.includes('\\')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
hasQuotedPreview(url) {
|
||||
return !!this.getQuotedPreviewUrl(url);
|
||||
},
|
||||
getQuotedPreviewUrl(url) {
|
||||
if (!url) return '';
|
||||
if (!this.isUsableQuotedPreview(url)) {
|
||||
return '';
|
||||
}
|
||||
if (url.startsWith('http://') || url.startsWith('https://')) {
|
||||
return this.getMediaProxyUrl(url);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user