feat: add guest comment support#515
Merged
Merged
Conversation
|
🚀 Preview deployed! |
|
🧹 Preview deployment has been cleaned up. The temporary preview environment for this PR has been deleted. |
Collaborator
Author
|
solves #514 |
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.
Summary
Allow unauthenticated users to leave comments on articles. Guest commenters provide a name (required) and optionally an email and website URL.
Changes
Database
0010.sql: Rebuildcommentstable to makeuser_idnullable; addguest_name,guest_email,guest_website,approvedcolumnsSchema & Types (
packages/api)Comment.useris now nullable; addguestName/guestEmail/guestWebsitefieldsCreateCommentRequestaccepts optionalguestName/guestEmail/guestWebsiteServer (
server/src/services/comments.ts)POST /:feed: Authenticated users post as before; unauthenticated requests requireguestName, accept optionalguestEmail/guestWebsiteGET /:feed: Guest comments returnuser: null+ guest fields; logged-in comments unchangedDELETE /:id: Admins can delete any comment; users can only delete their ownClient (
client/src/page/feed.tsx)CommentInput: When not logged in, shows guest form (name/email/website) + textarea, controlled by client configcomment.guest.enabled(default: on)CommentItem: Displays guest name with optional website link; handlesuser: nullgracefullycommenterAvatarnow falls back to/avatar.pnginstead of empty string, preventingTypeError: e.user is nullon some render pathsi18n
anonymous+ 4comment.guest_*keys to zh-CN, en, ja, zh-TWTests
guestName→ 400, not 401)