mirror of https://github.com/zulip/zulip.git
uploads: Remove redir=False codepath for serving S3 files.
It does not seem that we need to support this any more. Eliminating the code gets us to 100% line coverage with our tests on view/uploads.py.
This commit is contained in:
parent
9c0282139a
commit
1c37c0e93f
|
@ -14,8 +14,8 @@ from zerver.lib.validator import check_bool
|
||||||
from zerver.models import UserProfile
|
from zerver.models import UserProfile
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
def serve_s3(request, user_profile, realm_id_str, filename, redir):
|
def serve_s3(request, user_profile, realm_id_str, filename):
|
||||||
# type: (HttpRequest, UserProfile, str, str, bool) -> HttpResponse
|
# type: (HttpRequest, UserProfile, str, str) -> HttpResponse
|
||||||
url_path = "%s/%s" % (realm_id_str, filename)
|
url_path = "%s/%s" % (realm_id_str, filename)
|
||||||
|
|
||||||
if realm_id_str == "unk":
|
if realm_id_str == "unk":
|
||||||
|
@ -29,10 +29,7 @@ def serve_s3(request, user_profile, realm_id_str, filename, redir):
|
||||||
# Internal users can access all uploads so we can receive attachments in cross-realm messages
|
# Internal users can access all uploads so we can receive attachments in cross-realm messages
|
||||||
if user_profile.realm.id == realm_id or user_profile.realm.domain == 'zulip.com':
|
if user_profile.realm.id == realm_id or user_profile.realm.domain == 'zulip.com':
|
||||||
uri = get_signed_upload_url(url_path)
|
uri = get_signed_upload_url(url_path)
|
||||||
if redir:
|
return redirect(uri)
|
||||||
return redirect(uri)
|
|
||||||
else:
|
|
||||||
return json_success({'uri': uri})
|
|
||||||
else:
|
else:
|
||||||
return HttpResponseForbidden()
|
return HttpResponseForbidden()
|
||||||
|
|
||||||
|
@ -49,14 +46,13 @@ def serve_local(request, path_id):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
def serve_file_backend(request, user_profile, realm_id_str, filename,
|
def serve_file_backend(request, user_profile, realm_id_str, filename):
|
||||||
redir=REQ(validator=check_bool, default=True)):
|
# type: (HttpRequest, UserProfile, str, str) -> HttpResponse
|
||||||
# type: (HttpRequest, UserProfile, str, str, bool) -> HttpResponse
|
|
||||||
path_id = "%s/%s" % (realm_id_str, filename)
|
path_id = "%s/%s" % (realm_id_str, filename)
|
||||||
if settings.LOCAL_UPLOADS_DIR is not None:
|
if settings.LOCAL_UPLOADS_DIR is not None:
|
||||||
return serve_local(request, path_id)
|
return serve_local(request, path_id)
|
||||||
|
|
||||||
return serve_s3(request, user_profile, realm_id_str, filename, redir)
|
return serve_s3(request, user_profile, realm_id_str, filename)
|
||||||
|
|
||||||
@authenticated_json_post_view
|
@authenticated_json_post_view
|
||||||
def json_upload_file(request, user_profile):
|
def json_upload_file(request, user_profile):
|
||||||
|
|
Loading…
Reference in New Issue