Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

export_search: Support --dm option for 1:1 DMs using DM group.

Mohammad Reza Kianifar30d2d82d028d
diff --git a/zerver/management/commands/export_search.py b/zerver/management/commands/export_search.py
index 8011a011575..26723996922 100644
--- a/zerver/management/commands/export_search.py
+++ b/zerver/management/commands/export_search.py
@@ -17,7 +17,7 @@ from zerver.lib.management import ZulipBaseCommand
from zerver.lib.soft_deactivation import reactivate_user_if_soft_deactivated
from zerver.lib.upload import save_attachment_contents
from zerver.models import AbstractUserMessage, Attachment, Message, Recipient, Stream, UserProfile
-from zerver.models.recipients import get_or_create_direct_message_group
+from zerver.models.recipients import get_direct_message_group, get_or_create_direct_message_group
from zerver.models.streams import get_stream
from zerver.models.users import get_user_by_delivery_email
@@ -184,9 +184,13 @@ This is most often used for legal compliance.
)
elif len(user_profiles) == 2:
user_a, user_b = user_profiles
- limits &= Q(recipient=user_a.recipient, sender=user_b) | Q(
- recipient=user_b.recipient, sender=user_a
- )
+ direct_message_group = get_direct_message_group(id_list=[user_a.id, user_b.id])
+ if direct_message_group:
+ limits &= Q(recipient=direct_message_group.recipient)
+ else:
+ limits &= Q(recipient=user_a.recipient, sender=user_b) | Q(
+ recipient=user_b.recipient, sender=user_a
+ )
else:
direct_message_group = get_or_create_direct_message_group(
[user.id for user in user_profiles]