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'])
|
||||
|
||||
Reference in New Issue
Block a user