From 04e76216684663dbad6b4f023ae0624be715e824 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Tue, 28 Feb 2023 03:02:25 +0000 Subject: [PATCH] upload: Rename upload_message_image_from_request. The table is named Attachment, and not all of them are images. --- analytics/management/commands/populate_analytics_db.py | 4 ++-- zerver/lib/upload/__init__.py | 2 +- zerver/views/upload.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/analytics/management/commands/populate_analytics_db.py b/analytics/management/commands/populate_analytics_db.py index bbe82b5c7f..bfca7b38bd 100644 --- a/analytics/management/commands/populate_analytics_db.py +++ b/analytics/management/commands/populate_analytics_db.py @@ -23,7 +23,7 @@ from zerver.lib.create_user import create_user from zerver.lib.storage import static_path from zerver.lib.stream_color import STREAM_ASSIGNMENT_COLORS from zerver.lib.timestamp import floor_to_day -from zerver.lib.upload import upload_message_image_from_request +from zerver.lib.upload import upload_message_attachment_from_request from zerver.models import Client, Realm, Recipient, Stream, Subscription, UserGroup, UserProfile @@ -132,7 +132,7 @@ class Command(BaseCommand): file_info = os.stat(IMAGE_FILE_PATH) file_size = file_info.st_size with open(IMAGE_FILE_PATH, "rb") as fp: - upload_message_image_from_request(UploadedFile(fp), shylock, file_size) + upload_message_attachment_from_request(UploadedFile(fp), shylock, file_size) FixtureData = Mapping[Union[str, int, None], List[int]] diff --git a/zerver/lib/upload/__init__.py b/zerver/lib/upload/__init__.py index a70d6ac068..08f10449e0 100644 --- a/zerver/lib/upload/__init__.py +++ b/zerver/lib/upload/__init__.py @@ -136,7 +136,7 @@ def claim_attachment( return attachment -def upload_message_image_from_request( +def upload_message_attachment_from_request( user_file: UploadedFile, user_profile: UserProfile, user_file_size: int ) -> str: uploaded_file_name, content_type = get_file_info(user_file) diff --git a/zerver/views/upload.py b/zerver/views/upload.py index 967567a7e9..edb6aff99d 100644 --- a/zerver/views/upload.py +++ b/zerver/views/upload.py @@ -29,7 +29,7 @@ from zerver.lib.response import json_success from zerver.lib.upload import ( check_upload_within_quota, get_public_upload_root_url, - upload_message_image_from_request, + upload_message_attachment_from_request, ) from zerver.lib.upload.base import INLINE_MIME_TYPES from zerver.lib.upload.local import assert_is_local_storage_path @@ -300,5 +300,5 @@ def upload_file_backend(request: HttpRequest, user_profile: UserProfile) -> Http ) check_upload_within_quota(user_profile.realm, file_size) - uri = upload_message_image_from_request(user_file, user_profile, file_size) + uri = upload_message_attachment_from_request(user_file, user_profile, file_size) return json_success(request, data={"uri": uri})