An atproto PDS written in Go
103
fork

Configure Feed

Select the types of activity you want to include in your feed.

at d9201f3fccf4b794a2a83491dc7bbadbfd801a20 49 lines 1.2 kB view raw
1package server 2 3import ( 4 "github.com/haileyok/cocoon/models" 5 "github.com/ipfs/go-cid" 6 "github.com/labstack/echo/v4" 7) 8 9type ComAtprotoSyncListReposResponse struct { 10 Cursor *string `json:"cursor,omitempty"` 11 Repos []ComAtprotoSyncListReposRepoItem `json:"repos"` 12} 13 14type ComAtprotoSyncListReposRepoItem struct { 15 Did string `json:"did"` 16 Head string `json:"head"` 17 Rev string `json:"rev"` 18 Active bool `json:"active"` 19 Status *string `json:"status,omitempty"` 20} 21 22// TODO: paginate this bitch 23func (s *Server) handleListRepos(e echo.Context) error { 24 var repos []models.Repo 25 if err := s.db.Raw("SELECT * FROM repos ORDER BY created_at DESC LIMIT 500", nil).Scan(&repos).Error; err != nil { 26 return err 27 } 28 29 var items []ComAtprotoSyncListReposRepoItem 30 for _, r := range repos { 31 c, err := cid.Cast(r.Root) 32 if err != nil { 33 return err 34 } 35 36 items = append(items, ComAtprotoSyncListReposRepoItem{ 37 Did: r.Did, 38 Head: c.String(), 39 Rev: r.Rev, 40 Active: r.Active(), 41 Status: r.Status(), 42 }) 43 } 44 45 return e.JSON(200, ComAtprotoSyncListReposResponse{ 46 Cursor: nil, 47 Repos: items, 48 }) 49}