mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 18:36:36 +00:00
s3 exports: Validate user metadata for all assets.
This preps us to download assets for just a single user.
This commit is contained in:
@@ -1441,13 +1441,12 @@ def export_files_from_s3(
|
|||||||
avatar_hash_values.add(avatar_path)
|
avatar_hash_values.add(avatar_path)
|
||||||
avatar_hash_values.add(avatar_path + ".original")
|
avatar_hash_values.add(avatar_path + ".original")
|
||||||
|
|
||||||
|
email_gateway_bot: Optional[UserProfile] = None
|
||||||
|
|
||||||
if settings.EMAIL_GATEWAY_BOT is not None:
|
if settings.EMAIL_GATEWAY_BOT is not None:
|
||||||
internal_realm = get_realm(settings.SYSTEM_BOT_REALM)
|
internal_realm = get_realm(settings.SYSTEM_BOT_REALM)
|
||||||
email_gateway_bot: Optional[UserProfile] = get_system_bot(
|
email_gateway_bot = get_system_bot(settings.EMAIL_GATEWAY_BOT, internal_realm.id)
|
||||||
settings.EMAIL_GATEWAY_BOT, internal_realm.id
|
user_ids.add(email_gateway_bot.id)
|
||||||
)
|
|
||||||
else:
|
|
||||||
email_gateway_bot = None
|
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
for bkey in bucket.objects.filter(Prefix=object_prefix):
|
for bkey in bucket.objects.filter(Prefix=object_prefix):
|
||||||
@@ -1462,6 +1461,9 @@ def export_files_from_s3(
|
|||||||
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:
|
||||||
|
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(
|
||||||
|
|||||||
Reference in New Issue
Block a user