code
Clone this repository
https://tangled.org/bretton.dev/coves
git@knot.bretton.dev:bretton.dev/coves
For self-hosted knots, clone URLs may differ based on your setup.
- Add cursorSecret parameter to all NewCommunityFeedRepository calls
- Use 'test-cursor-secret' for test environments
- Add assertions to verify community handle is present in responses
- All 10 feed integration tests pass with HMAC-signed cursors
- Capture community.Handle when fetching community data
- Set Handle field in CommunityRef struct
- Improve error handling for missing communities:
- Log as ERROR (not warning) for data integrity issues
- Use DID as fallback for handle/name to prevent API breakage
- Surfaces orphaned post issues in logs while maintaining resilience
Fixes: Community handle field empty in post views from comment service
- Update NewCommunityFeedRepository to accept cursorSecret parameter
- Enables HMAC-signed cursors for security
- Consistent with timeline and discover feed repos
- Prevents cursor tampering and pagination attacks
- Update SELECT clauses to include c.handle as community_handle
- Update scanFeedPost to scan and populate handle field
- Changes apply to:
- Community feed (feed_repo.go)
- Timeline feed (timeline_repo.go)
- Discover feed (discover_repo.go)
- Shared base scanner (feed_repo_base.go)
All feed endpoints now return community handles in responses
- Update communityRef lexicon definition to include handle field
- Add Handle field to CommunityRef struct
- Follows atProto pattern of including both DID and handle
- Consistent with authorView which requires both fields
Fixes: Backend missing community handle in feed responses
Applied gofumpt strict formatting across entire codebase for consistency.
Changes:
- Import statement formatting (stdlib, external, internal order)
- Blank line grouping in imports
- Fix errcheck issue in user_repo.go (properly check rows.Close() error)
- Add log import for error logging
All tests pass after formatting changes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Addresses P0 PR review test coverage requirements:
Unit Tests (comment_service_test.go):
- Fix mockUserRepo to implement GetByDIDs method (compilation blocker)
- Update all buildCommentView calls to 4-parameter signature
- Add 5 tests for GetByDIDs mock (empty, single, multiple, missing, fields)
- Add 5 tests for JSON deserialization (facets, embeds, labels, malformed, nil/empty)
- Total: 10 new unit tests covering Phase 2C functionality
Integration Tests (user_test.go):
- Add TestUserRepository_GetByDIDs with 7 comprehensive test cases
- Test empty array, single/multiple DIDs, missing users, field preservation
- Test validation: batch size limit (>1000), invalid DID format
- All tests use real PostgreSQL database with migrations
Test Fixes (comment_query_test.go):
- Fix TestCommentQuery_InvalidInputs failing tests
- Create real test post/community for validation tests
- Tests now verify normalization works (negative depth, excessive limits)
- All 6 test cases now pass
Test Results:
- Unit tests: 43 total (33 existing + 10 new) - ALL PASS
- Integration tests: 26 total (19 comment + 7 user) - ALL PASS
- Zero compilation errors, zero test failures
Coverage validates:
- Batch user loading prevents N+1 queries
- Input validation rejects oversized/malformed inputs
- JSON deserialization handles errors gracefully
- Security validation prevents injection attacks
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>