Repository navigation
DEV: Simplify the webhook, playback lookup and their specs - #105
Merged
ZogStriP merged 1 commit intoOct 23, 2026
Merged
Conversation
Previously, the webhook checked its mutually exclusive event types with separate `if` blocks, and the playback lookup serialized a relation to read a single row by its unique id. The webhook specs pasted the same signed request, with a misspelled `Content-Type`, into every example and defined `mux_signature` on `Object` for the whole suite, and the `:video` fabricator used a fixed id, so specs had to pass one to fabricate a second video. This change: - turns the webhook into a `case` over the event type and reads the playback data with `find_by` - uses `staff?` in `can_upload_video?` - adds a `post_webhook` spec helper, scopes `mux_signature` to the webhook specs, uses `enable_current_plugin` and sequences the `:video` fabricator id - renames the "allows only verified requests" spec after what it checks, that a signed event of a type the webhook doesn't handle is acknowledged - drops the assertion on the error body of the blank secret rejection, since that body comes from core's `Discourse::InvalidAccess` handling, and keeps the checks on the 403 and the unchanged video
This was referenced Oct 22, 2026
Grubba27
approved these changes
Oct 22, 2026
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.
Previously, the webhook checked its mutually exclusive event types with separate
ifblocks, and the playback lookup serialized a relation to read a single row by its unique id. The webhook specs pasted the same signed request, with a misspelledContent-Type, into every example and definedmux_signatureonObjectfor the whole suite, and the:videofabricator used a fixed id, so specs had to pass one to fabricate a second video.This change:
caseover the event type and reads the playback data withfind_bystaff?incan_upload_video?post_webhookspec helper, scopesmux_signatureto the webhook specs, usesenable_current_pluginand sequences the:videofabricator idDiscourse::InvalidAccesshandling, and keeps the checks on the 403 and the unchanged videoPart of a stack of PRs, to be merged in order: