Implement empty chat filtering from SQL #112

This commit also removed the old empty chat filtering logic.
This commit is contained in:
KnugiHK
2025-01-04 18:18:34 +08:00
parent 92d710bce8
commit 23af55d645
4 changed files with 39 additions and 30 deletions
+4 -6
View File
@@ -220,6 +220,10 @@ def get_file_name(contact: str, chat: ChatStore):
return sanitize_filename(file_name), name
def get_cond_for_empty(enable, jid_field: str, broadcast_field: str):
return f"AND (chat.sort_timestamp IS NOT NULL OR {jid_field}='status@broadcast' OR {broadcast_field}>0)" if enable else ""
def get_chat_condition(filter, include, columns, jid=None, platform=None):
if filter is not None:
conditions = []
@@ -245,12 +249,6 @@ def get_chat_condition(filter, include, columns, jid=None, platform=None):
else:
return ""
def _is_message_empty(message):
return (message.data is None or message.data == "") and not message.media
def chat_is_empty(chat: ChatStore):
return len(chat.messages) == 0 or all(_is_message_empty(message) for message in chat.messages.values())
# Android Specific
CRYPT14_OFFSETS = (