fix: fallback quoted image lookup by md5

This commit is contained in:
liuwei
2026-04-07 17:58:34 +08:00
parent d99f1a07d1
commit 1671bea3a3
4 changed files with 54 additions and 8 deletions

View File

@@ -73,6 +73,21 @@ class MessageStorageDB(BaseDBOperator):
"""
return self.execute_query(sql, (message_id,), fetch_one=True)
def get_image_message_by_md5(self, md5: str) -> Optional[Dict]:
"""根据图片消息 attachment_url 中的 md5 反查原图消息"""
sql = """
SELECT id, group_id, timestamp, sender, content, message_type,
attachment_url, message_id, message_xml, message_thumb, image_path
FROM messages
WHERE message_type = 3
AND attachment_url IS NOT NULL
AND attachment_url <> ''
AND attachment_url LIKE %s
ORDER BY id DESC
LIMIT 1
"""
return self.execute_query(sql, (f'%md5="{md5}"%',), fetch_one=True)
def get_member_recent_messages(self, group_id: str, wxid: str, days: int = 30,
limit: int = 200, include_today: bool = True) -> List[Dict]:
"""获取指定群成员近期消息"""