Skip to content

DEV: Simplify the webhook, playback lookup and their specs - #105

Merged
ZogStriP merged 1 commit into
fix-video-webhook-post-updatesfrom
dev-simplify-video-webhook
Oct 23, 2026
Merged

ZogStriP merged 1 commit into
fix-video-webhook-post-updatesfrom
dev-simplify-video-webhook

Conversation

@ZogStriP

@ZogStriP ZogStriP commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

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

Part of a stack of PRs, to be merged in order:

  1. FIX: Show a poster for Mux videos and play them inline on mobile #103
  2. FIX: Update the right posts when a Mux video becomes ready #104
  3. DEV: Simplify the webhook, playback lookup and their specs #105 👈 this PR
  4. PERF: Cut per-post queries and table scans for post videos #106
  5. FIX: Render each video in a post with its own status #107
  6. DEV: Simplify video rendering and consolidate its tests #108
  7. UX: Use sentence case for video strings and fix the preview placeholder #109
  8. FIX: Show video changes in posts without reloading the topic #110
  9. PERF: Load video streams only once playback starts #111
  10. DEV: Move video rendering into a module #112
  11. FIX: Restore video embeds in chat messages #113

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
@ZogStriP
ZogStriP merged commit 11b9872 into main Oct 23, 2026
7 checks passed
@ZogStriP
ZogStriP deleted the dev-simplify-video-webhook branch October 23, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants