The Discourse receiver stored each verified event body whole in
core.webhook_events.payload, so every forum signup's email address,
username, name, avatar, profile fields and external id stayed in the
database and its backups, members and non-members alike (#163). Nothing
reads a stored Discourse payload back: the receiver handles the event
from the body it was delivered.
The receiver now parses the body once, after it takes the dedupe key,
and stores only the ids processing reads: {"user":{"id":...}} for
user_created, {"group_user":{"group_id":...,"user_id":...}} for the two
group events. A missing id is stored as 0. A body that does not parse,
or lacks the object its event names, is stored as {} and recorded
failed. Email mode still reads the address from the delivered body.
Two answers change. A signed body that is not JSON, or is empty, failed
the JSONB insert: 500, no row, and redelivery of the same bytes, which
can only fail again. It now gets a failed row and 200, as every
recorded event does. A body Go parses but JSONB rejects (a \u0000
escape, invalid UTF-8) answered 500 on every delivery; its ids are now
stored and it is processed.
docs/models/payments-billing.md says what each receiver stores, and the
comments of scripts/db-reader-role.sql stop calling the column raw
provider payloads; no reader column changes. The OpenSpec change
discourse-events-keep-forum-ids is added with this commit. Ride-along:
the test helper newMapping drops a return value nothing read.
Deliberate breaks, scripts/mutation-check -side new, 29 records, all
CAUGHT:
the insert stores the raw body (8 rows of both tests)
keep copies the email into the stored user
keep drops UserID from the stored group user (both group rows)
keep swaps GroupID and UserID (both group rows)
keep takes the user object for every event type (3 rows)
keep stores a user with id 0 when the user object is nil
a parse error stores keep of the partly filled view
the parse-error path answers 500 (the three parse-error rows)
resolvePerson is called with an empty email
an event of another type is not dropped
a group event without group_user reconciles from the user object
the insert writes the body into provider_environment
the processed body is the stored one (NUL escape, invalid UTF-8)
the stored group user omits a zero group_id, and a zero user_id