mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 08:26:11 +00:00
export: Add check_metadata flag.
This commit is contained in:
@@ -1455,25 +1455,31 @@ def export_files_from_s3(
|
|||||||
|
|
||||||
key = bucket.Object(bkey.key)
|
key = bucket.Object(bkey.key)
|
||||||
|
|
||||||
if "realm_id" not in key.metadata:
|
"""
|
||||||
raise AssertionError(f"Missing realm_id in key metadata: {key.metadata}")
|
For very old realms we may not have proper metadata. If you really need
|
||||||
|
an export to bypass these checks, flip the following flag.
|
||||||
|
"""
|
||||||
|
checking_metadata = True
|
||||||
|
if checking_metadata:
|
||||||
|
if "realm_id" not in key.metadata:
|
||||||
|
raise AssertionError(f"Missing realm_id in key metadata: {key.metadata}")
|
||||||
|
|
||||||
if "user_profile_id" not in key.metadata:
|
if "user_profile_id" not in key.metadata:
|
||||||
raise AssertionError(f"Missing user_profile_id in key metadata: {key.metadata}")
|
raise AssertionError(f"Missing user_profile_id in key metadata: {key.metadata}")
|
||||||
|
|
||||||
if int(key.metadata["user_profile_id"]) not in user_ids:
|
if int(key.metadata["user_profile_id"]) not in user_ids:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# This can happen if an email address has moved realms
|
# This can happen if an email address has moved realms
|
||||||
if key.metadata["realm_id"] != str(realm.id):
|
if key.metadata["realm_id"] != str(realm.id):
|
||||||
if email_gateway_bot is None or key.metadata["user_profile_id"] != str(
|
if email_gateway_bot is None or key.metadata["user_profile_id"] != str(
|
||||||
email_gateway_bot.id
|
email_gateway_bot.id
|
||||||
):
|
):
|
||||||
raise AssertionError(
|
raise AssertionError(
|
||||||
f"Key metadata problem: {key.key} / {key.metadata} / {realm.id}"
|
f"Key metadata problem: {key.key} / {key.metadata} / {realm.id}"
|
||||||
)
|
)
|
||||||
# Email gateway bot sends messages, potentially including attachments, cross-realm.
|
# Email gateway bot sends messages, potentially including attachments, cross-realm.
|
||||||
print(f"File uploaded by email gateway bot: {key.key} / {key.metadata}")
|
print(f"File uploaded by email gateway bot: {key.key} / {key.metadata}")
|
||||||
|
|
||||||
record = _get_exported_s3_record(bucket_name, key, processing_emoji)
|
record = _get_exported_s3_record(bucket_name, key, processing_emoji)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user