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.
Register community blocking XRPC endpoints:
- POST /xrpc/social.coves.community.blockCommunity (requires auth)
- POST /xrpc/social.coves.community.unblockCommunity (requires auth)
Both routes use RequireAuth middleware to ensure proper authentication
before allowing block/unblock operations.
Add XRPC handlers for community blocking endpoints:
- HandleBlock: POST /xrpc/social.coves.community.blockCommunity
- HandleUnblock: POST /xrpc/social.coves.community.unblockCommunity
Features:
- Input validation: Community must be DID (did:plc:...) or handle (!name@instance)
- Authentication: Requires user DID and access token from middleware
- Response format: Follows atProto conventions with recordUri/recordCid
- Error handling: Uses shared handleServiceError for consistency
Addresses PR review comment on input validation.
Implement service layer for community blocking following atProto
write-forward architecture:
- BlockCommunity: Creates block record on PDS using user's access token,
handles duplicate errors gracefully by fetching existing block
- UnblockCommunity: Deletes block record from PDS, extracts rkey from URI
- GetBlockedCommunities: Queries AppView with pagination
- IsBlocked: Fast boolean check for block status
Key architectural decisions:
- Write-forward pattern: All mutations go through PDS first
- Race condition fix: Removed preemptive existence check, rely on PDS
duplicate detection + repository ON CONFLICT handling
- User authentication: Uses user's access token (not instance token)
- Identifier resolution: Supports both DIDs and handles via
resolveCommunityIdentifier
Resolves race condition identified in PR review.
Add core domain support for community blocking feature:
- CommunityBlock struct with proper atProto metadata (RecordURI, RecordCID)
- ErrBlockNotFound error constant
- Repository interface methods: BlockCommunity, UnblockCommunity, GetBlock,
GetBlockByURI, ListBlockedCommunities, IsBlocked
- Service interface methods: BlockCommunity, UnblockCommunity,
GetBlockedCommunities, IsBlocked
This establishes the domain layer contracts that will be implemented
in subsequent commits following clean architecture principles.
Implement PostgreSQL repository for community blocking with:
- BlockCommunity: Create/update block (idempotent via ON CONFLICT DO UPDATE)
- UnblockCommunity: Remove block
- GetBlock: Retrieve block by user/community DIDs
- GetBlockByURI: Retrieve block by AT-URI (for Jetstream DELETE ops)
- ListBlockedCommunities: Paginated list of user's blocks
- IsBlocked: Fast boolean check using EXISTS
All methods use direct string values (not sql.NullString) since
record_uri and record_cid are NOT NULL in the schema.
Fixes: PR review comment #2, #3 (P0 - Critical)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Create migration for community blocking feature with:
- user_did and community_did with widened regex validation
- blocked_at timestamp for chronological ordering
- record_uri and record_cid for atProto federation
- Unique constraint on (user_did, community_did) pairs
- Indexes for efficient queries
DID regex pattern ^did:(plc|web):[a-zA-Z0-9._:%-]+$ supports:
- Uppercase and lowercase letters
- Dots for did:web domains (e.g., did:web:coves.social)
- Hyphens, underscores, colons, percent signs per DID spec
- Anchored to end for strict matching
Fixes: PR review comment #1 (P0 - Critical)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>