Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-5506 Don't include hidden works in Readings #4781

Merged
merged 2 commits into from
May 17, 2024

Conversation

de3sw2aq1
Copy link
Contributor

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-5506

Purpose

Don't include hidden works in reading history

  • Require works to be visible to mark for later

  • Hide draft works and hidden by admin works from the reading history

  • Test for visibility of hidden by admin works in reading history

Testing Instructions

An automated test for hidden by admin works not being visible in the reading list is included. This may be tested manually by adding a work to a users reading list, an admin hiding it, and then viewing the users reading list and confirming it's absence.

Accessing a URL for a draft work like http://localhost:3000/works/110/mark_for_later (manually replace 110 with the id of a draft work owned by another user) should now return the error "Sorry, you don't have permission to access the page you were trying to reach." This URL was never linked in the UI for draft works, but could be guessed and draft works could previously be added to the reading list.

I don't know how to test the fact that the reading list no longer shows draft works if they somehow get added to the reading list (the above .../mark_for_later action is now blocked), but they should no longer be visible in the reading list now.

Credit

@de3sw2aq1

Thanks @sarken for initial review of the security aspect of this issue and the pointer to visible_to_registered_user in Jira was helpful.

* Require works to be visible to mark for later

* Hide draft works and hidden by admin works from the reading history

* Test for visibility of hidden by admin works in reading history
@@ -16,7 +16,7 @@ def index
@readings = @readings.where(toread: true)
@page_subtitle = ts("Marked For Later")
end
@readings = @readings.order("last_viewed DESC").page(params[:page])
@readings = @readings.left_joins(:work).merge(Work.visible_to_registered_user).or(Work.where(id: nil)).order("last_viewed DESC").page(params[:page])
Copy link
Contributor Author

@de3sw2aq1 de3sw2aq1 Apr 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A join is required to query by work fields, with the visible_to_registered_user scope

It must be a left join and .or(Work.where(id: nil)) included, otherwise deleted works won't be included in the reading history.

@brianjaustin brianjaustin merged commit d6d6e20 into otwcode:master May 17, 2024
26 checks passed
sarken added a commit that referenced this pull request May 31, 2024
sarken added a commit that referenced this pull request May 31, 2024
Revert "AO3-5506 Don't include hidden works in Readings (#4781)"

This reverts commit d6d6e20.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants