upload: Remove redundant acting_user_profile argument.

This argument, effectively added in 9eb47f108c, was never actually
used.
This commit is contained in:
Alex Vandiver 2024-06-25 21:27:26 +00:00 committed by Tim Abbott
parent 41d1b417e7
commit 08b24484d1
11 changed files with 15 additions and 16 deletions

View File

@ -81,7 +81,7 @@ def create_integration_bot(integration: Integration, bot_name: Optional[str] = N
bot_avatar_path = static_path(bot_avatar_path)
if os.path.isfile(bot_avatar_path):
with open(bot_avatar_path, "rb") as f:
upload_avatar_image(f, owner, bot)
upload_avatar_image(f, bot)
do_change_avatar_fields(bot, UserProfile.AVATAR_FROM_USER, acting_user=owner)
return bot

View File

@ -75,7 +75,7 @@ def create_user(full_name: str, avatar_filename: str) -> None:
def set_avatar(user: UserProfile, filename: str) -> None:
with open(filename, "rb") as f:
upload_avatar_image(f, user, user)
upload_avatar_image(f, user)
do_change_avatar_fields(user, UserProfile.AVATAR_FROM_USER, acting_user=DEFAULT_USER)

View File

@ -30,7 +30,7 @@ def _transfer_avatar_to_s3(user: UserProfile) -> None:
file_path = os.path.join(settings.LOCAL_AVATARS_DIR, avatar_path)
try:
with open(file_path + ".original", "rb") as f:
upload_avatar_image(f, user, user, backend=s3backend)
upload_avatar_image(f, user, backend=s3backend)
logging.info("Uploaded avatar for %s in realm %s", user.id, user.realm.name)
except FileNotFoundError:
pass

View File

@ -181,18 +181,17 @@ def write_avatar_images(
def upload_avatar_image(
user_file: IO[bytes],
acting_user_profile: UserProfile,
target_user_profile: UserProfile,
user_profile: UserProfile,
content_type: Optional[str] = None,
backend: Optional[ZulipUploadBackend] = None,
) -> None:
if content_type is None:
content_type = guess_type(user_file.name)[0]
file_path = user_avatar_path(target_user_profile)
file_path = user_avatar_path(user_profile)
image_data = user_file.read()
write_avatar_images(
file_path, target_user_profile, image_data, content_type=content_type, backend=backend
file_path, user_profile, image_data, content_type=content_type, backend=backend
)

View File

@ -175,7 +175,7 @@ class ExportFile(ZulipTestCase):
)
with get_test_image_file("img.png") as img_file:
upload_avatar_image(img_file, user_profile, user_profile)
upload_avatar_image(img_file, user_profile)
user_profile.avatar_source = "U"
user_profile.save()

View File

@ -276,7 +276,7 @@ class S3Test(ZulipTestCase):
medium_path_id = path_id + "-medium.png"
with get_test_image_file("img.png") as image_file:
zerver.lib.upload.upload_avatar_image(image_file, user_profile, user_profile)
zerver.lib.upload.upload_avatar_image(image_file, user_profile)
test_image_data = read_test_image_file("img.png")
test_medium_image_data = resize_avatar(test_image_data, MEDIUM_AVATAR_SIZE)
@ -353,7 +353,7 @@ class S3Test(ZulipTestCase):
medium_file_path = base_file_path + "-medium.png"
with get_test_image_file("img.png") as image_file:
zerver.lib.upload.upload_avatar_image(image_file, user_profile, user_profile)
zerver.lib.upload.upload_avatar_image(image_file, user_profile)
key = bucket.Object(original_file_path)
image_data = key.get()["Body"].read()

View File

@ -1310,7 +1310,7 @@ class UserProfileTest(ZulipTestCase):
# Upload cordelia's avatar
with get_test_image_file("img.png") as image_file:
upload_avatar_image(image_file, cordelia, cordelia)
upload_avatar_image(image_file, cordelia)
OnboardingStep.objects.filter(user=cordelia).delete()
OnboardingStep.objects.filter(user=iago).delete()

View File

@ -419,7 +419,7 @@ def set_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> HttpR
max_size=settings.MAX_AVATAR_FILE_SIZE_MIB,
)
)
upload_avatar_image(user_file, user_profile, user_profile)
upload_avatar_image(user_file, user_profile)
do_change_avatar_fields(user_profile, UserProfile.AVATAR_FROM_USER, acting_user=user_profile)
user_avatar_url = avatar_url(user_profile)

View File

@ -406,7 +406,7 @@ def patch_bot_backend(
[user_file] = request.FILES.values()
assert isinstance(user_file, UploadedFile)
assert user_file.size is not None
upload_avatar_image(user_file, user_profile, bot)
upload_avatar_image(user_file, bot)
avatar_source = UserProfile.AVATAR_FROM_USER
do_change_avatar_fields(bot, avatar_source, acting_user=user_profile)
else:
@ -554,7 +554,7 @@ def add_bot_backend(
[user_file] = request.FILES.values()
assert isinstance(user_file, UploadedFile)
assert user_file.size is not None
upload_avatar_image(user_file, user_profile, bot_profile)
upload_avatar_image(user_file, bot_profile)
if bot_type in (UserProfile.OUTGOING_WEBHOOK_BOT, UserProfile.EMBEDDED_BOT):
assert isinstance(service_name, str)

View File

@ -37,7 +37,7 @@ From image editing program:
def set_avatar(self, user: UserProfile, filename: str) -> None:
with open(filename, "rb") as f:
upload_avatar_image(f, user, user)
upload_avatar_image(f, user)
do_change_avatar_fields(user, UserProfile.AVATAR_FROM_USER, acting_user=None)
def add_message_formatting_conversation(self) -> None:

View File

@ -834,7 +834,7 @@ class ZulipLDAPAuthBackendBase(ZulipAuthMixin, LDAPBackend):
# any metadata, we auto-detect it.
content_type = magic.from_buffer(ldap_avatar[:1024], mime=True)
if content_type.startswith("image/"):
upload_avatar_image(BytesIO(ldap_avatar), user, user, content_type=content_type)
upload_avatar_image(BytesIO(ldap_avatar), user, content_type=content_type)
do_change_avatar_fields(user, UserProfile.AVATAR_FROM_USER, acting_user=None)
# Update avatar hash.
user.avatar_hash = user_avatar_content_hash(ldap_avatar)