A community based topic aggregation platform built on atproto

feat(server): integrate vote XRPC endpoints

Wire up vote service and routes in main server:
- Initialize VoteService with OAuth client for PDS authentication
- Register vote XRPC routes with auth middleware

Also adds E2E test helpers:
- AddSessionWithPDS: Store session with specific PDS URL
- AddUserWithPDSToken: Register user with real PDS access token

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

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

Changed files
+23 -2
cmd
server
tests
integration
+7 -2
cmd/server/main.go
···
"Coves/internal/core/timeline"
"Coves/internal/core/unfurl"
"Coves/internal/core/users"
+
"Coves/internal/core/votes"
"bytes"
"context"
"crypto/rand"
···
voteRepo := postgresRepo.NewVoteRepository(db)
log.Println("✅ Vote repository initialized (Jetstream indexing only)")
+
// Initialize vote service (for XRPC API endpoints)
+
voteService := votes.NewService(voteRepo, oauthClient, oauthStore, nil)
+
log.Println("✅ Vote service initialized (with OAuth authentication)")
+
// Initialize comment repository (used by Jetstream consumer for indexing)
commentRepo := postgresRepo.NewCommentRepository(db)
log.Println("✅ Comment repository initialized (Jetstream indexing only)")
···
routes.RegisterPostRoutes(r, postService, authMiddleware)
log.Println("Post XRPC endpoints registered with OAuth authentication")
-
// Vote write endpoints removed - clients write directly to their PDS
-
// The AppView indexes votes from Jetstream (see vote consumer above)
+
routes.RegisterVoteRoutes(r, voteService, authMiddleware)
+
log.Println("Vote XRPC endpoints registered with OAuth authentication")
routes.RegisterCommunityFeedRoutes(r, feedService)
log.Println("Feed XRPC endpoints registered (public, no auth required)")
+16
tests/integration/helpers.go
···
// AddSession adds a session to the store
func (m *MockOAuthStore) AddSession(did, sessionID, accessToken string) {
+
m.AddSessionWithPDS(did, sessionID, accessToken, getTestPDSURL())
+
}
+
+
// AddSessionWithPDS adds a session to the store with a specific PDS URL
+
func (m *MockOAuthStore) AddSessionWithPDS(did, sessionID, accessToken, pdsURL string) {
key := did + ":" + sessionID
parsedDID, _ := syntax.ParseDID(did)
m.sessions[key] = &oauthlib.ClientSessionData{
AccountDID: parsedDID,
SessionID: sessionID,
AccessToken: accessToken,
+
HostURL: pdsURL,
}
}
···
e.store.AddSession(did, sessionID, "access-token-"+did)
return token
}
+
+
// AddUserWithPDSToken registers a user with their real PDS access token
+
// Use this for E2E tests that need to write to the real PDS
+
func (e *E2EOAuthMiddleware) AddUserWithPDSToken(did, pdsAccessToken, pdsURL string) string {
+
token := "test-token-" + did
+
sessionID := "session-" + did
+
e.unsealer.AddSession(token, did, sessionID)
+
e.store.AddSessionWithPDS(did, sessionID, pdsAccessToken, pdsURL)
+
return token
+
}