mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	ldap: Fix avatar sync not working with the S3 backend.
This fixes an issue that caused LDAP synchronization to fail for avatars. The problem occurred due to the lack of a 'name' attribute on the BytesIO object that we pass to the upload backend (which is only used in the S3 backend for computing Content-Type). Fixes #12411.
This commit is contained in:
		@@ -197,7 +197,8 @@ class ZulipUploadBackend:
 | 
			
		||||
 | 
			
		||||
    def upload_avatar_image(self, user_file: File,
 | 
			
		||||
                            acting_user_profile: UserProfile,
 | 
			
		||||
                            target_user_profile: UserProfile) -> None:
 | 
			
		||||
                            target_user_profile: UserProfile,
 | 
			
		||||
                            content_type: Optional[str]=None) -> None:
 | 
			
		||||
        raise NotImplementedError()
 | 
			
		||||
 | 
			
		||||
    def delete_avatar_image(self, user: UserProfile) -> None:
 | 
			
		||||
@@ -389,8 +390,10 @@ class S3UploadBackend(ZulipUploadBackend):
 | 
			
		||||
 | 
			
		||||
    def upload_avatar_image(self, user_file: File,
 | 
			
		||||
                            acting_user_profile: UserProfile,
 | 
			
		||||
                            target_user_profile: UserProfile) -> None:
 | 
			
		||||
        content_type = guess_type(user_file.name)[0]
 | 
			
		||||
                            target_user_profile: UserProfile,
 | 
			
		||||
                            content_type: Optional[str] = None) -> None:
 | 
			
		||||
        if content_type is None:
 | 
			
		||||
            content_type = guess_type(user_file.name)[0]
 | 
			
		||||
        s3_file_name = user_avatar_path(target_user_profile)
 | 
			
		||||
 | 
			
		||||
        image_data = user_file.read()
 | 
			
		||||
@@ -631,7 +634,8 @@ class LocalUploadBackend(ZulipUploadBackend):
 | 
			
		||||
 | 
			
		||||
    def upload_avatar_image(self, user_file: File,
 | 
			
		||||
                            acting_user_profile: UserProfile,
 | 
			
		||||
                            target_user_profile: UserProfile) -> None:
 | 
			
		||||
                            target_user_profile: UserProfile,
 | 
			
		||||
                            content_type: Optional[str] = None) -> None:
 | 
			
		||||
        file_path = user_avatar_path(target_user_profile)
 | 
			
		||||
 | 
			
		||||
        image_data = user_file.read()
 | 
			
		||||
@@ -756,8 +760,10 @@ def delete_message_image(path_id: str) -> bool:
 | 
			
		||||
    return upload_backend.delete_message_image(path_id)
 | 
			
		||||
 | 
			
		||||
def upload_avatar_image(user_file: File, acting_user_profile: UserProfile,
 | 
			
		||||
                        target_user_profile: UserProfile) -> None:
 | 
			
		||||
    upload_backend.upload_avatar_image(user_file, acting_user_profile, target_user_profile)
 | 
			
		||||
                        target_user_profile: UserProfile,
 | 
			
		||||
                        content_type: Optional[str]=None) -> None:
 | 
			
		||||
    upload_backend.upload_avatar_image(user_file, acting_user_profile,
 | 
			
		||||
                                       target_user_profile, content_type=content_type)
 | 
			
		||||
 | 
			
		||||
def delete_avatar_image(user_profile: UserProfile) -> None:
 | 
			
		||||
    upload_backend.delete_avatar_image(user_profile)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user