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: Remove debugging print() statement and re-organize logic.

Alex Vandiverc2f9e219cddb
diff --git a/zerver/lib/export.py b/zerver/lib/export.py
index 3b195b27c3f..cb8f1e3d2fa 100644
--- a/zerver/lib/export.py
+++ b/zerver/lib/export.py
@@ -2218,16 +2218,17 @@ def export_files_from_s3(
if int(key.metadata["user_profile_id"]) not in user_ids:
continue
- # This can happen if an email address has moved realms
- if key.metadata["realm_id"] != str(realm.id):
- if email_gateway_bot is None or key.metadata["user_profile_id"] != str(
- email_gateway_bot.id
- ):
- raise AssertionError(
- f"Key metadata problem: {key.key} / {key.metadata} / {realm.id}"
- )
- # Email gateway bot sends messages, potentially including attachments, cross-realm.
- print(f"File uploaded by email gateway bot: {key.key} / {key.metadata}")
+ if key.metadata["realm_id"] == str(realm.id):
+ pass
+ elif email_gateway_bot and key.metadata["user_profile_id"] == str(
+ email_gateway_bot.id
+ ):
+ # Our one expected cross-realm source of attachments
+ pass
+ else:
+ raise AssertionError(
+ f"Key metadata problem: {key.key} / {key.metadata} / {realm.id}"
+ )
record = _get_exported_s3_record(bucket_name, key, processing_emoji, realm.id)