[Dmails] Don't mark as read on show for API requests

This commit is contained in:
Earlopain 2023-12-17 20:08:44 +01:00
parent f477141c63
commit 18f8f99730
No known key found for this signature in database
GPG Key ID: 48860312319ADF61
2 changed files with 10 additions and 2 deletions

View File

@ -27,8 +27,9 @@ class DmailsController < ApplicationController
def show
@dmail = Dmail.find(params[:id])
check_privilege(@dmail)
@dmail.mark_as_read! unless Danbooru.config.readonly_mode?
respond_with(@dmail)
respond_with(@dmail) do |fmt|
fmt.html { @dmail.mark_as_read! unless Danbooru.config.readonly_mode? }
end
end
def create

View File

@ -63,6 +63,13 @@ class DmailsControllerTest < ActionDispatch::IntegrationTest
should "show dmails owned by the current user" do
get_auth dmail_path(@dmail), @dmail.owner
assert_response :success
assert_predicate @dmail.reload, :is_read?
end
should "not mark the dmail as read for json requests" do
get_auth dmail_path(@dmail), @dmail.owner, params: { format: :json }
assert_response :success
assert_not_predicate @dmail.reload, :is_read?
end
should "not show dmails not owned by the current user" do