A community based topic aggregation platform built on atproto
1package routes
2
3import (
4 "Coves/internal/api/handlers/community"
5 "Coves/internal/api/middleware"
6 "Coves/internal/core/communities"
7
8 "github.com/go-chi/chi/v5"
9)
10
11// RegisterCommunityRoutes registers community-related XRPC endpoints on the router
12// Implements social.coves.community.* lexicon endpoints
13func RegisterCommunityRoutes(r chi.Router, service communities.Service, authMiddleware *middleware.AtProtoAuthMiddleware) {
14 // Initialize handlers
15 createHandler := community.NewCreateHandler(service)
16 getHandler := community.NewGetHandler(service)
17 updateHandler := community.NewUpdateHandler(service)
18 listHandler := community.NewListHandler(service)
19 searchHandler := community.NewSearchHandler(service)
20 subscribeHandler := community.NewSubscribeHandler(service)
21 blockHandler := community.NewBlockHandler(service)
22
23 // Query endpoints (GET) - public access
24 // social.coves.community.get - get a single community by identifier
25 r.Get("/xrpc/social.coves.community.get", getHandler.HandleGet)
26
27 // social.coves.community.list - list communities with filters
28 r.Get("/xrpc/social.coves.community.list", listHandler.HandleList)
29
30 // social.coves.community.search - search communities
31 r.Get("/xrpc/social.coves.community.search", searchHandler.HandleSearch)
32
33 // Procedure endpoints (POST) - require authentication
34 // social.coves.community.create - create a new community
35 r.With(authMiddleware.RequireAuth).Post("/xrpc/social.coves.community.create", createHandler.HandleCreate)
36
37 // social.coves.community.update - update an existing community
38 r.With(authMiddleware.RequireAuth).Post("/xrpc/social.coves.community.update", updateHandler.HandleUpdate)
39
40 // social.coves.community.subscribe - subscribe to a community
41 r.With(authMiddleware.RequireAuth).Post("/xrpc/social.coves.community.subscribe", subscribeHandler.HandleSubscribe)
42
43 // social.coves.community.unsubscribe - unsubscribe from a community
44 r.With(authMiddleware.RequireAuth).Post("/xrpc/social.coves.community.unsubscribe", subscribeHandler.HandleUnsubscribe)
45
46 // social.coves.community.blockCommunity - block a community
47 r.With(authMiddleware.RequireAuth).Post("/xrpc/social.coves.community.blockCommunity", blockHandler.HandleBlock)
48
49 // social.coves.community.unblockCommunity - unblock a community
50 r.With(authMiddleware.RequireAuth).Post("/xrpc/social.coves.community.unblockCommunity", blockHandler.HandleUnblock)
51
52 // TODO: Add delete handler when implemented
53 // r.With(authMiddleware.RequireAuth).Post("/xrpc/social.coves.community.delete", deleteHandler.HandleDelete)
54}