mirror of https://github.com/zulip/zulip.git
upload: Remove redundant acting_user_profile argument.
This argument, effectively added in 9eb47f108c
, was never actually
used.
This commit is contained in:
parent
41d1b417e7
commit
08b24484d1
|
@ -81,7 +81,7 @@ def create_integration_bot(integration: Integration, bot_name: Optional[str] = N
|
||||||
bot_avatar_path = static_path(bot_avatar_path)
|
bot_avatar_path = static_path(bot_avatar_path)
|
||||||
if os.path.isfile(bot_avatar_path):
|
if os.path.isfile(bot_avatar_path):
|
||||||
with open(bot_avatar_path, "rb") as f:
|
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)
|
do_change_avatar_fields(bot, UserProfile.AVATAR_FROM_USER, acting_user=owner)
|
||||||
|
|
||||||
return bot
|
return bot
|
||||||
|
|
|
@ -75,7 +75,7 @@ def create_user(full_name: str, avatar_filename: str) -> None:
|
||||||
|
|
||||||
def set_avatar(user: UserProfile, filename: str) -> None:
|
def set_avatar(user: UserProfile, filename: str) -> None:
|
||||||
with open(filename, "rb") as f:
|
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)
|
do_change_avatar_fields(user, UserProfile.AVATAR_FROM_USER, acting_user=DEFAULT_USER)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ def _transfer_avatar_to_s3(user: UserProfile) -> None:
|
||||||
file_path = os.path.join(settings.LOCAL_AVATARS_DIR, avatar_path)
|
file_path = os.path.join(settings.LOCAL_AVATARS_DIR, avatar_path)
|
||||||
try:
|
try:
|
||||||
with open(file_path + ".original", "rb") as f:
|
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)
|
logging.info("Uploaded avatar for %s in realm %s", user.id, user.realm.name)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -181,18 +181,17 @@ def write_avatar_images(
|
||||||
|
|
||||||
def upload_avatar_image(
|
def upload_avatar_image(
|
||||||
user_file: IO[bytes],
|
user_file: IO[bytes],
|
||||||
acting_user_profile: UserProfile,
|
user_profile: UserProfile,
|
||||||
target_user_profile: UserProfile,
|
|
||||||
content_type: Optional[str] = None,
|
content_type: Optional[str] = None,
|
||||||
backend: Optional[ZulipUploadBackend] = None,
|
backend: Optional[ZulipUploadBackend] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
if content_type is None:
|
if content_type is None:
|
||||||
content_type = guess_type(user_file.name)[0]
|
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()
|
image_data = user_file.read()
|
||||||
write_avatar_images(
|
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
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ class ExportFile(ZulipTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
with get_test_image_file("img.png") as img_file:
|
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.avatar_source = "U"
|
||||||
user_profile.save()
|
user_profile.save()
|
||||||
|
|
|
@ -276,7 +276,7 @@ class S3Test(ZulipTestCase):
|
||||||
medium_path_id = path_id + "-medium.png"
|
medium_path_id = path_id + "-medium.png"
|
||||||
|
|
||||||
with get_test_image_file("img.png") as image_file:
|
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_image_data = read_test_image_file("img.png")
|
||||||
test_medium_image_data = resize_avatar(test_image_data, MEDIUM_AVATAR_SIZE)
|
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"
|
medium_file_path = base_file_path + "-medium.png"
|
||||||
|
|
||||||
with get_test_image_file("img.png") as image_file:
|
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)
|
key = bucket.Object(original_file_path)
|
||||||
image_data = key.get()["Body"].read()
|
image_data = key.get()["Body"].read()
|
||||||
|
|
|
@ -1310,7 +1310,7 @@ class UserProfileTest(ZulipTestCase):
|
||||||
|
|
||||||
# Upload cordelia's avatar
|
# Upload cordelia's avatar
|
||||||
with get_test_image_file("img.png") as image_file:
|
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=cordelia).delete()
|
||||||
OnboardingStep.objects.filter(user=iago).delete()
|
OnboardingStep.objects.filter(user=iago).delete()
|
||||||
|
|
|
@ -419,7 +419,7 @@ def set_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> HttpR
|
||||||
max_size=settings.MAX_AVATAR_FILE_SIZE_MIB,
|
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)
|
do_change_avatar_fields(user_profile, UserProfile.AVATAR_FROM_USER, acting_user=user_profile)
|
||||||
user_avatar_url = avatar_url(user_profile)
|
user_avatar_url = avatar_url(user_profile)
|
||||||
|
|
||||||
|
|
|
@ -406,7 +406,7 @@ def patch_bot_backend(
|
||||||
[user_file] = request.FILES.values()
|
[user_file] = request.FILES.values()
|
||||||
assert isinstance(user_file, UploadedFile)
|
assert isinstance(user_file, UploadedFile)
|
||||||
assert user_file.size is not None
|
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
|
avatar_source = UserProfile.AVATAR_FROM_USER
|
||||||
do_change_avatar_fields(bot, avatar_source, acting_user=user_profile)
|
do_change_avatar_fields(bot, avatar_source, acting_user=user_profile)
|
||||||
else:
|
else:
|
||||||
|
@ -554,7 +554,7 @@ def add_bot_backend(
|
||||||
[user_file] = request.FILES.values()
|
[user_file] = request.FILES.values()
|
||||||
assert isinstance(user_file, UploadedFile)
|
assert isinstance(user_file, UploadedFile)
|
||||||
assert user_file.size is not None
|
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):
|
if bot_type in (UserProfile.OUTGOING_WEBHOOK_BOT, UserProfile.EMBEDDED_BOT):
|
||||||
assert isinstance(service_name, str)
|
assert isinstance(service_name, str)
|
||||||
|
|
|
@ -37,7 +37,7 @@ From image editing program:
|
||||||
|
|
||||||
def set_avatar(self, user: UserProfile, filename: str) -> None:
|
def set_avatar(self, user: UserProfile, filename: str) -> None:
|
||||||
with open(filename, "rb") as f:
|
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)
|
do_change_avatar_fields(user, UserProfile.AVATAR_FROM_USER, acting_user=None)
|
||||||
|
|
||||||
def add_message_formatting_conversation(self) -> None:
|
def add_message_formatting_conversation(self) -> None:
|
||||||
|
|
|
@ -834,7 +834,7 @@ class ZulipLDAPAuthBackendBase(ZulipAuthMixin, LDAPBackend):
|
||||||
# any metadata, we auto-detect it.
|
# any metadata, we auto-detect it.
|
||||||
content_type = magic.from_buffer(ldap_avatar[:1024], mime=True)
|
content_type = magic.from_buffer(ldap_avatar[:1024], mime=True)
|
||||||
if content_type.startswith("image/"):
|
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)
|
do_change_avatar_fields(user, UserProfile.AVATAR_FROM_USER, acting_user=None)
|
||||||
# Update avatar hash.
|
# Update avatar hash.
|
||||||
user.avatar_hash = user_avatar_content_hash(ldap_avatar)
|
user.avatar_hash = user_avatar_content_hash(ldap_avatar)
|
||||||
|
|
Loading…
Reference in New Issue