From b1c8daab0c4874e2346ccb2305dedab5b0c29aff Mon Sep 17 00:00:00 2001 From: Dame-Zoom-A-Lot Date: Sat, 27 Dec 2025 18:30:37 -0500 Subject: [PATCH 1/3] A03-7219 explicitly handle view_full_work param as either text or option --- app/controllers/comments_controller.rb | 5 +++-- app/controllers/works_controller.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index e89d919d904..415c8338ad6 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -384,7 +384,8 @@ def create elsif @comment.unreviewed? redirect_to_all_comments(@commentable) else - redirect_to_comment(@comment, { view_full_work: (params[:view_full_work] == "true"), page: params[:page] }) + user_chose_to_view_full_work = (current_user.try(:preference).try(:view_full_works) && params[:view_full_work] != "false") + redirect_to_comment(@comment, { view_full_work: (params[:view_full_work] == "true" || user_chose_to_view_full_work), page: params[:page] }) end end end @@ -689,7 +690,7 @@ def redirect_to_all_comments(commentable, options = {}) page: options[:page], anchor: options[:anchor]) else - if commentable.is_a?(Chapter) && (options[:view_full_work] || current_user.try(:preference).try(:view_full_works)) + if commentable.is_a?(Chapter) && (options[:view_full_work] || (current_user.try(:preference).try(:view_full_works) && options[:view_full_work] != false)) commentable = commentable.work end redirect_to polymorphic_path(commentable, diff --git a/app/controllers/works_controller.rb b/app/controllers/works_controller.rb index b42c7470c4e..82d17b1ffba 100755 --- a/app/controllers/works_controller.rb +++ b/app/controllers/works_controller.rb @@ -191,7 +191,7 @@ def show # Users must explicitly okay viewing of entire work if @work.chaptered? - if params[:view_full_work] || (logged_in? && current_user.preference.try(:view_full_works)) + if params[:view_full_work] == "true" || (logged_in? && current_user.preference.try(:view_full_works) && params[:view_full_works] != "false") @chapters = @work.chapters_in_order( include_drafts: (logged_in_as_admin? || @work.user_is_owner_or_invited?(current_user)) From f4311570b3c9333b34b8d57a26f6975cfdd9de17 Mon Sep 17 00:00:00 2001 From: Dame-Zoom-A-Lot Date: Sat, 27 Dec 2025 19:31:29 -0500 Subject: [PATCH 2/3] AO3-7219 use single line if and fix option setting bug --- app/controllers/comments_controller.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 415c8338ad6..98cefa1d01f 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -55,8 +55,10 @@ def check_blocked def check_pseud_ownership return unless params[:comment][:pseud_id] + pseud = Pseud.find(params[:comment][:pseud_id]) return if pseud && current_user && current_user.pseuds.include?(pseud) + flash[:error] = ts("You can't comment with that pseud.") redirect_to root_path end @@ -180,14 +182,17 @@ def check_not_replying_to_spam def check_permission_to_review parent = find_parent return if logged_in_as_admin? || current_user_owns?(parent) + flash[:error] = ts("Sorry, you don't have permission to see those unreviewed comments.") redirect_to logged_in? ? root_path : new_user_session_path(return_to: request.fullpath) end def check_permission_to_access_single_unreviewed return unless @comment.unreviewed? + parent = find_parent return if logged_in_as_admin? || current_user_owns?(parent) || current_user_owns?(@comment) + flash[:error] = ts("Sorry, that comment is currently in moderation.") redirect_to logged_in? ? root_path : new_user_session_path(return_to: request.fullpath) end @@ -384,7 +389,9 @@ def create elsif @comment.unreviewed? redirect_to_all_comments(@commentable) else - user_chose_to_view_full_work = (current_user.try(:preference).try(:view_full_works) && params[:view_full_work] != "false") + # keep the user in chapter by chapter view if that was the view they were in when they commented + # An entire work view url would look like works/:id + user_chose_to_view_full_work = (current_user.try(:preference).try(:view_full_works) && request.referer&.match(/chapters/).nil?) redirect_to_comment(@comment, { view_full_work: (params[:view_full_work] == "true" || user_chose_to_view_full_work), page: params[:page] }) end end @@ -690,8 +697,9 @@ def redirect_to_all_comments(commentable, options = {}) page: options[:page], anchor: options[:anchor]) else - if commentable.is_a?(Chapter) && (options[:view_full_work] || (current_user.try(:preference).try(:view_full_works) && options[:view_full_work] != false)) - commentable = commentable.work + if commentable.is_a?(Chapter) + user_chose_to_view_full_work = current_user.try(:preference).try(:view_full_works) && options[:view_full_work] != false + commentable = commentable.work if options[:view_full_work] || user_chose_to_view_full_work end redirect_to polymorphic_path(commentable, options.slice(:show_comments, From b2cce493e26be0f2b2c2ae3de8da5af6688cb072 Mon Sep 17 00:00:00 2001 From: Dame-Zoom-A-Lot Date: Sat, 27 Dec 2025 20:10:41 -0500 Subject: [PATCH 3/3] AO3-7219 update cucumber test to match new desired behavior --- features/comments_and_kudos/comments_redirect.feature | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/features/comments_and_kudos/comments_redirect.feature b/features/comments_and_kudos/comments_redirect.feature index ec20253a7f9..6b3b3929965 100644 --- a/features/comments_and_kudos/comments_redirect.feature +++ b/features/comments_and_kudos/comments_redirect.feature @@ -49,8 +49,7 @@ Scenario: Posting top level comment on a chaptered work, with view full work in And I post a comment "Woohoo" Then I should see "Woohoo" And I should see "Chapter 2" within "div#chapters" - # Once you've commented, it defaults back to your preference - And I should see "Chapter 1" within "div#chapters" + And I should not see "Chapter 1" within "div#chapters" # REPLY COMMENTS