Skip to content

v0.5.8

Latest

Choose a tag to compare

@karthikeyankc karthikeyankc released this 27 Jul 13:28
e858e78

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-Token was missing from Access-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 _startInlineEdit calls fired per click — the second captured an empty serialised form as originalHtml, 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-Version response header on every request, read from package.json at 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