diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb
index a0de157b5..14306a90d 100644
--- a/app/presenters/post_presenter.rb
+++ b/app/presenters/post_presenter.rb
@@ -14,7 +14,11 @@ class PostPresenter
@humanized_essential_tag_string ||= tag_set_presenter.humanized_essential_tag_string.presence || "##{@post.id}"
end
- def filename_for_download
- "#{humanized_essential_tag_string} - #{@post.md5}.#{@post.file_ext}"
+ def filename_for_download(current_user)
+ if current_user.disable_tagged_filenames?
+ "#{@post.md5}.#{@post.file_ext}"
+ else
+ "#{humanized_essential_tag_string} - #{@post.md5}.#{@post.file_ext}"
+ end
end
end
diff --git a/app/views/posts/partials/show/_options.html.erb b/app/views/posts/partials/show/_options.html.erb
index ae66430f2..ee7d21f58 100644
--- a/app/views/posts/partials/show/_options.html.erb
+++ b/app/views/posts/partials/show/_options.html.erb
@@ -17,7 +17,7 @@
<% if policy(post).visible? %>
- <%= link_to "Download", post.tagged_file_url + "?download=1", download: post.presenter.filename_for_download %>
+ <%= link_to "Download", post.tagged_file_url + "?download=1", download: post.presenter.filename_for_download(CurrentUser.user) %>
<% end %>
diff --git a/test/functional/posts_controller_test.rb b/test/functional/posts_controller_test.rb
index fc680e21a..1c694e83a 100644
--- a/test/functional/posts_controller_test.rb
+++ b/test/functional/posts_controller_test.rb
@@ -593,6 +593,14 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
assert_nil(response.parsed_body["file_url"])
end
end
+
+ should "respect the disable tagged filenames option in the Download link" do
+ @user.update!(disable_tagged_filenames: true)
+ get_auth post_path(@post), @user
+
+ assert_response :success
+ assert_equal("#{@post.md5}.#{@post.file_ext}", response.parsed_body.css("#post-option-download a").attr("download").value)
+ end
end
context "update action" do