feat(comment): add campaignDiscussion comment type for campaign discussion board#4841
Merged
mashbean merged 6 commits intoJun 13, 2026
Merged
Conversation
…ssion board - new COMMENT_TYPE campaignDiscussion bound to campaign via targetId/targetTypeId - putComment: accept campaignId; only succeeded participants (campaign_user.state) or campaign organizers/managers may comment; cap content at 240 chars - WritingChallenge.discussion / discussionCount: public read resolvers - Comment.node resolves campaign comments to WritingChallenge - campaignService.isParticipant helper Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- run codegen so schema.graphql / schema.d.ts include the new campaignDiscussion comment type, campaign discussion field and CommentInput.campaignId (CI relies on committed generated types) - putComment: guard article/moment notification blocks with targetAuthor (now string|undefined since campaign discussions have no single author) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #4841 +/- ##
===========================================
- Coverage 72.82% 72.46% -0.36%
===========================================
Files 1054 1057 +3
Lines 21263 21013 -250
Branches 4671 4586 -85
===========================================
- Hits 15485 15228 -257
+ Misses 5706 5309 -397
- Partials 72 476 +404 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…archived campaign - commentService.upvote & unvoteComment: add explicit campaignDiscussion branch with participant/organizer permission, skip blocked check (no single target author) instead of falling through to circle - deleteComment: invalidate the Campaign node (not Circle) and allow campaign creator/organizers/managers to delete discussion comments - togglePinComment: throw ForbiddenError for campaignDiscussion instead of loading it as a circle - putComment: reject commenting on archived campaigns - discussionCount: count via commentService.count (active + collapsed) to match the public discussion list Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add integration tests for the campaign discussion comment feature covering putComment (participant/organizer/manager permission matrix, archived-campaign guard), vote/unvote (including the circle fallthrough fix), deleteComment author/organizer permissions, togglePinComment forbidden case, and discussion list/discussionCount consistency. Also add the missing DB migration that extends the comment_type_check constraint to allow 'campaign_discussion'. Without it, every attempt to create a campaignDiscussion comment fails at the database layer with a check-constraint violation, breaking the feature end-to-end. The feat branch added the code, GraphQL schema, and resolvers for the new type but never added this migration. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add error-path coverage for putComment campaignDiscussion: missing campaignId, non-existing campaign, and over-length content; plus organizer upvote and non-participant unvote-forbidden cases. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jun 13, 2026
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.
這是什麼
在寫作活動頁(
WritingChallenge)新增「留言區」討論板的後端支援:新增評論類型campaignDiscussion,沿用 Comment 體系的targetId/targetTypeId綁到 campaign(與moment類型先例同手法)。權限模型:公開可讀;只有報名成功者(
campaign_user.state = 'succeeded')與 creator / organizerIds / managerIds 可發言。前端對應 PR:thematters/matters-web 的同名分支
feat/campaign-discussion。產品脈絡:七日書活動頁要開一個輕量討論區,重用圍爐眾聊的既有架構。
改動
src/common/enums/index.tsCOMMENT_TYPE.campaignDiscussion;MAX_CAMPAIGN_COMMENT_LENGTH = 240(比照 moment)src/types/comment.tsCommentType加campaignDiscussion;CommentInput加 optionalcampaignIdsrc/types/campaign.tsWritingChallenge.discussion/discussionCountsrc/mutations/comment/putComment.tsNODE_TYPES.Campaign)src/queries/comment/campaign/discussion.ts(新)circle/discussion.ts(cursor 分頁、filter)src/queries/comment/campaign/discussionCount.ts(新)circle/discussionCount.tssrc/queries/campaign/index.tssrc/queries/comment/node.tsWritingChallenge(前端回覆/編輯靠comment.node取 campaignId)src/connectors/campaignService.tsisParticipant(campaignId, userId)helper不需要 migration
entity_type已有campaign(20240703145306_create_campaign_tables.js),comment 表 targetId/targetTypeId 為通用欄位。刻意不做(MVP)
權限驗收矩陣
備註
🤖 Generated with Claude Code