A community based topic aggregation platform built on atproto

feat(comments): add routes and wire up comment service

- Add RegisterCommentRoutes for comment write XRPC endpoints
- Wire comment service with OAuth dependencies in main.go
- All write endpoints require OAuth authentication middleware

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

+46 -3
+11 -3
cmd/server/main.go
··· 408 408 voteService := votes.NewService(voteRepo, oauthClient, oauthStore, voteCache, nil) 409 409 log.Println("✅ Vote service initialized (with OAuth authentication and vote cache)") 410 410 411 - // Initialize comment service (for query API) 411 + // Initialize comment service (for query and write APIs) 412 412 // Requires user and community repos for proper author/community hydration per lexicon 413 - commentService := comments.NewCommentService(commentRepo, userRepo, postRepo, communityRepo) 414 - log.Println("✅ Comment service initialized (with author/community hydration)") 413 + // OAuth client and store are needed for write operations (create, update, delete) 414 + commentService := comments.NewCommentService(commentRepo, userRepo, postRepo, communityRepo, oauthClient, oauthStore, nil) 415 + log.Println("✅ Comment service initialized (with author/community hydration and write support)") 415 416 416 417 // Initialize feed service 417 418 feedRepo := postgresRepo.NewCommunityFeedRepository(db, cursorSecret) ··· 528 529 529 530 routes.RegisterVoteRoutes(r, voteService, authMiddleware) 530 531 log.Println("Vote XRPC endpoints registered with OAuth authentication") 532 + 533 + // Register comment write routes (create, update, delete) 534 + routes.RegisterCommentRoutes(r, commentService, authMiddleware) 535 + log.Println("Comment write XRPC endpoints registered") 536 + log.Println(" - POST /xrpc/social.coves.community.comment.create") 537 + log.Println(" - POST /xrpc/social.coves.community.comment.update") 538 + log.Println(" - POST /xrpc/social.coves.community.comment.delete") 531 539 532 540 routes.RegisterCommunityFeedRoutes(r, feedService, voteService, authMiddleware) 533 541 log.Println("Feed XRPC endpoints registered (public with optional auth for viewer vote state)")
+35
internal/api/routes/comment.go
··· 1 + package routes 2 + 3 + import ( 4 + "Coves/internal/api/handlers/comments" 5 + "Coves/internal/api/middleware" 6 + commentsCore "Coves/internal/core/comments" 7 + 8 + "github.com/go-chi/chi/v5" 9 + ) 10 + 11 + // RegisterCommentRoutes registers comment-related XRPC endpoints on the router 12 + // Implements social.coves.community.comment.* lexicon endpoints 13 + // All write operations (create, update, delete) require authentication 14 + func RegisterCommentRoutes(r chi.Router, service commentsCore.Service, authMiddleware *middleware.OAuthAuthMiddleware) { 15 + // Initialize handlers 16 + createHandler := comments.NewCreateCommentHandler(service) 17 + updateHandler := comments.NewUpdateCommentHandler(service) 18 + deleteHandler := comments.NewDeleteCommentHandler(service) 19 + 20 + // Procedure endpoints (POST) - require authentication 21 + // social.coves.community.comment.create - create a new comment on a post or another comment 22 + r.With(authMiddleware.RequireAuth).Post( 23 + "/xrpc/social.coves.community.comment.create", 24 + createHandler.HandleCreate) 25 + 26 + // social.coves.community.comment.update - update an existing comment's content 27 + r.With(authMiddleware.RequireAuth).Post( 28 + "/xrpc/social.coves.community.comment.update", 29 + updateHandler.HandleUpdate) 30 + 31 + // social.coves.community.comment.delete - soft delete a comment 32 + r.With(authMiddleware.RequireAuth).Post( 33 + "/xrpc/social.coves.community.comment.delete", 34 + deleteHandler.HandleDelete) 35 + }