feat: revamp contacts chat workspace
This commit is contained in:
@@ -202,6 +202,36 @@ class MessageStorageDB(BaseDBOperator):
|
||||
"""
|
||||
return self.execute_query(sql, (target_date, group_id, limit)) or []
|
||||
|
||||
def get_recent_group_chat_messages(self, group_id: str, limit: int = 20) -> List[Dict]:
|
||||
"""获取群聊最近消息"""
|
||||
sql = """
|
||||
SELECT timestamp, sender, content, message_type, attachment_url, message_id, message_xml, message_thumb, image_path
|
||||
FROM messages
|
||||
WHERE group_id = %s
|
||||
ORDER BY timestamp DESC
|
||||
LIMIT %s
|
||||
"""
|
||||
results = self.execute_query(sql, (group_id, limit)) or []
|
||||
return list(reversed(results))
|
||||
|
||||
def get_recent_personal_messages(self, wxid: str, limit: int = 20) -> List[Dict]:
|
||||
"""获取私聊最近归档消息
|
||||
|
||||
说明:
|
||||
当前消息表没有可靠的 to_user 会话维度,这里只返回目标联系人发来的、
|
||||
且未归属到群聊的消息,用于通讯录内的“尽力模式”历史预览。
|
||||
"""
|
||||
sql = """
|
||||
SELECT timestamp, sender, content, message_type, attachment_url, message_id, message_xml, message_thumb, image_path
|
||||
FROM messages
|
||||
WHERE (group_id IS NULL OR group_id = '')
|
||||
AND sender = %s
|
||||
ORDER BY timestamp DESC
|
||||
LIMIT %s
|
||||
"""
|
||||
results = self.execute_query(sql, (wxid, limit)) or []
|
||||
return list(reversed(results))
|
||||
|
||||
def get_message_count_by_date(self, date: str) -> List[Dict]:
|
||||
"""获取指定日期的消息统计"""
|
||||
sql = """
|
||||
|
||||
Reference in New Issue
Block a user