Comment editing
Authors can edit their own comments within 15 minutes of posting. An edit button appears next to the timestamp immediately after a comment is submitted. Clicking it opens an inline edit form in place, reusing the existing form styles. Save patches the comment and re-renders the widget. Cancel restores the original content.
The edit token is stateless — the server derives it from an HMAC-SHA256 of the comment ID and creation timestamp, so nothing extra is stored in the database. The token lives in memory on the widget instance and is cleared on page reload. The 15-minute window is enforced server-side regardless of token validity.
A new edited_at column is added to the comments table. The migration runs automatically on startup and is backwards-compatible with existing installs.
Fixes
- CORS preflight for cross-origin PATCH:
X-Edit-Tokenwas missing fromAccess-Control-Allow-Headers, which would have caused the preflight check to fail silently for cross-origin edit requests. - Edit cancel corrupting comment body: the cancel handler was re-attaching a click listener to the edit button on every cancel. On the next edit, two
_startInlineEditcalls fired per click — the second captured an empty serialised form asoriginalHtml, so cancelling replaced the comment body with a blank textarea. Removing the redundant re-attachment fixes both the blank-text symptom and the Reply/Share/Edit buttons staying visible while the form was open.
Other changes
X-App-Versionresponse header on every request, read frompackage.jsonat startup.- Demo index page hero updated with project-oriented copy and a docs link.
- Widget-note callouts on all four demo thread pages converted to GitHub-style callouts.
- README updated with comment editing docs, token design explanation, and v0.5.8 upgrading note.
- Dependency updates:
body-parser,brace-expansion,linkify-it,postcss(resolves 3 high-severity audit advisories).
Upgrading
Schema migration runs automatically on startup — no manual steps needed.
git pull origin main
npm install --production
sudo systemctl restart discuss