AO3-6001 Derive subscribable type from param name server-side#5932
Open
pmonfort wants to merge 1 commit into
Open
AO3-6001 Derive subscribable type from param name server-side#5932pmonfort wants to merge 1 commit into
pmonfort wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
AO3-1234 Fix thing)Issue
https://otwarchive.atlassian.net/browse/AO3-6001
Purpose
When a browser auto-translates a page, hidden fields containing class names like
"User"can be translated (e.g."用户"in Chinese), causing aNameErrorcrash when the form is submitted.This PR removes
subscribable_typeandsubscribable_idfrom the subscription form's hidden fields and replaces them with a single type-specific ID field (work_id,series_id, oruser_id). The controller derives the subscribable type from the parameter name using aSUBSCRIBABLE_PARAMSmapping, so no user-supplied class name ever reaches the server.Changes
subscription_paramsmass-assignment withload_subscribable, which mapswork_id→Work,series_id→Series,user_id→User. Returns 422 if zero or multiple IDs are provided. Remove unusedsubscription_paramsmethod.hidden_field_tagwith the type-specific param name (e.g.subscription[work_id]) only for new subscriptions. No hidden fields are sent for unsubscribe (the subscription ID is in the URL).POST #createcovering all three subscribable types, missing/multiple/nonexistent IDs, legacysubscribable_typeparams, and the specific regression case (validwork_idalongside a browser-translatedsubscribable_type).Testing Instructions
subscription[work_id](orseries_id/user_id) with a numeric value, and that nosubscribable_typeorsubscribable_idfields exist."用户"alongside the validwork_idsubscribing should still succeed.Credit
Pablo Monfort (he/him)