Skip to content

feat: add guest comment support#515

Merged
OXeu merged 1 commit into
mainfrom
feat/guest-comments
May 25, 2026
Merged

feat: add guest comment support#515
OXeu merged 1 commit into
mainfrom
feat/guest-comments

Conversation

@OXeu

@OXeu OXeu commented May 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Allow unauthenticated users to leave comments on articles. Guest commenters provide a name (required) and optionally an email and website URL.

Changes

Database

  • Migration 0010.sql: Rebuild comments table to make user_id nullable; add guest_name, guest_email, guest_website, approved columns
  • Test fixture: Update in-memory DDL to match new schema

Schema & Types (packages/api)

  • Comment.user is now nullable; add guestName/guestEmail/guestWebsite fields
  • CreateCommentRequest accepts optional guestName/guestEmail/guestWebsite

Server (server/src/services/comments.ts)

  • POST /:feed: Authenticated users post as before; unauthenticated requests require guestName, accept optional guestEmail/guestWebsite
  • GET /:feed: Guest comments return user: null + guest fields; logged-in comments unchanged
  • DELETE /:id: Admins can delete any comment; users can only delete their own

Client (client/src/page/feed.tsx)

  • CommentInput: When not logged in, shows guest form (name/email/website) + textarea, controlled by client config comment.guest.enabled (default: on)
  • CommentItem: Displays guest name with optional website link; handles user: null gracefully
  • Bugfix: Guest comment commenterAvatar now falls back to /avatar.png instead of empty string, preventing TypeError: e.user is null on some render paths

i18n

  • Add anonymous + 4 comment.guest_* keys to zh-CN, en, ja, zh-TW

Tests

  • 4 new test cases covering guest comment creation, validation, and listing
  • Existing auth test updated (unauthenticated without guestName → 400, not 401)

@github-actions

github-actions Bot commented May 25, 2026

Copy link
Copy Markdown

🚀 Preview deployed!

🔗 https://rin-server-pr-515.xeu.workers.dev

@OXeu OXeu force-pushed the feat/guest-comments branch from ed944ff to 04fa9d0 Compare May 25, 2026 03:41
@OXeu OXeu merged commit 869ddf2 into main May 25, 2026
7 checks passed
@github-actions

Copy link
Copy Markdown

🧹 Preview deployment has been cleaned up.

The temporary preview environment for this PR has been deleted.

@OXeu

OXeu commented May 25, 2026

Copy link
Copy Markdown
Collaborator Author

solves #514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant