Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
upload: Remove redundant acting_user_profile argument.
Alex Vandiver08b24484d16a
diff --git a/tools/screenshots/generate-integration-docs-screenshot b/tools/screenshots/generate-integration-docs-screenshotindex 6b9fee808af..d2fea287380 100755--- a/tools/screenshots/generate-integration-docs-screenshot+++ b/tools/screenshots/generate-integration-docs-screenshot@@ -81,7 +81,7 @@ def create_integration_bot(integration: Integration, bot_name: Optional[str] = Nbot_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 botdiff --git a/tools/screenshots/generate-user-messages-screenshot b/tools/screenshots/generate-user-messages-screenshotindex 5fd7834369a..e6524ac06e3 100755--- a/tools/screenshots/generate-user-messages-screenshot+++ b/tools/screenshots/generate-user-messages-screenshot@@ -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)diff --git a/zerver/lib/transfer.py b/zerver/lib/transfer.pyindex bf666242585..b48ecf2d666 100644--- a/zerver/lib/transfer.py+++ b/zerver/lib/transfer.py@@ -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:passdiff --git a/zerver/lib/upload/__init__.py b/zerver/lib/upload/__init__.pyindex 425b5306931..857cac85d66 100644--- a/zerver/lib/upload/__init__.py+++ b/zerver/lib/upload/__init__.py@@ -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)diff --git a/zerver/tests/test_import_export.py b/zerver/tests/test_import_export.pyindex 2625b5cbd89..6c706bfcc35 100644--- a/zerver/tests/test_import_export.py+++ b/zerver/tests/test_import_export.py@@ -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()diff --git a/zerver/tests/test_upload_s3.py b/zerver/tests/test_upload_s3.pyindex ba934daf56d..238f44439c0 100644--- a/zerver/tests/test_upload_s3.py+++ b/zerver/tests/test_upload_s3.py@@ -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()diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.pyindex f0dc6c516c2..715362acf65 100644--- a/zerver/tests/test_users.py+++ b/zerver/tests/test_users.py@@ -1310,7 +1310,7 @@ class UserProfileTest(ZulipTestCase):# Upload cordelia's avatarwith 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()diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.pyindex 3a0f34b8816..96221db4c2b 100644--- a/zerver/views/user_settings.py+++ b/zerver/views/user_settings.py@@ -419,7 +419,7 @@ def set_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> HttpRmax_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)diff --git a/zerver/views/users.py b/zerver/views/users.pyindex 773fe12f0b0..749b408a82f 100644--- a/zerver/views/users.py+++ b/zerver/views/users.py@@ -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_USERdo_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)diff --git a/zilencer/management/commands/add_mock_conversation.py b/zilencer/management/commands/add_mock_conversation.pyindex 548a25d8d43..7979f58be2a 100644--- a/zilencer/management/commands/add_mock_conversation.py+++ b/zilencer/management/commands/add_mock_conversation.py@@ -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:diff --git a/zproject/backends.py b/zproject/backends.pyindex a7ea76b6103..bd0639c453b 100644--- a/zproject/backends.py+++ b/zproject/backends.py@@ -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)