this repo has no description
0
fork

Configure Feed

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

remove more pds dead code

-66
-66
pds/server.go
··· 24 24 "github.com/bluesky-social/indigo/plc" 25 25 "github.com/bluesky-social/indigo/repomgr" 26 26 "github.com/bluesky-social/indigo/util" 27 - bsutil "github.com/bluesky-social/indigo/util" 28 27 "github.com/bluesky-social/indigo/xrpc" 29 28 gojwt "github.com/golang-jwt/jwt" 30 29 "github.com/gorilla/websocket" 31 - "github.com/ipfs/go-cid" 32 30 "github.com/labstack/echo/v4" 33 31 "github.com/labstack/echo/v4/middleware" 34 32 "github.com/lestrrat-go/jwx/v2/jwt" ··· 111 109 return s.echo.Shutdown(ctx) 112 110 } 113 111 114 - func (s *Server) handleFedEvent(ctx context.Context, host *Peering, env *events.XRPCStreamEvent) error { 115 - fmt.Printf("[%s] got fed event from %q\n", s.serviceUrl, host.Host) 116 - switch { 117 - case env.RepoCommit != nil: 118 - evt := env.RepoCommit 119 - u, err := s.lookupUserByDid(ctx, evt.Repo) 120 - if err != nil { 121 - if !errors.Is(err, gorm.ErrRecordNotFound) { 122 - return fmt.Errorf("looking up event user: %w", err) 123 - } 124 - 125 - subj, err := s.createExternalUser(ctx, evt.Repo) 126 - if err != nil { 127 - return err 128 - } 129 - 130 - u = new(User) 131 - u.ID = subj.Uid 132 - } 133 - 134 - return s.repoman.HandleExternalUserEvent(ctx, host.ID, u.ID, u.Did, evt.Since, evt.Rev, evt.Blocks, evt.Ops) 135 - default: 136 - return fmt.Errorf("invalid fed event") 137 - } 138 - } 139 - 140 112 func (s *Server) createExternalUser(ctx context.Context, did string) (*models.ActorInfo, error) { 141 113 doc, err := s.plc.GetDocument(ctx, did) 142 114 if err != nil { ··· 215 187 } 216 188 217 189 return subj, nil 218 - } 219 - 220 - func (s *Server) repoEventToFedEvent(ctx context.Context, evt *repomgr.RepoEvent) (*comatproto.SyncSubscribeRepos_Commit, error) { 221 - did, err := s.indexer.DidForUser(ctx, evt.User) 222 - if err != nil { 223 - return nil, err 224 - } 225 - 226 - out := &comatproto.SyncSubscribeRepos_Commit{ 227 - Blocks: evt.RepoSlice, 228 - Repo: did, 229 - Time: time.Now().Format(bsutil.ISO8601), 230 - //PrivUid: evt.User, 231 - } 232 - 233 - for _, op := range evt.Ops { 234 - out.Ops = append(out.Ops, &comatproto.SyncSubscribeRepos_RepoOp{ 235 - Path: op.Collection + "/" + op.Rkey, 236 - Action: string(op.Kind), 237 - Cid: (*lexutil.LexLink)(op.RecCid), 238 - }) 239 - } 240 - 241 - return out, nil 242 - } 243 - 244 - func (s *Server) readRecordFunc(ctx context.Context, user models.Uid, c cid.Cid) (lexutil.CBOR, error) { 245 - bs, err := s.cs.ReadOnlySession(user) 246 - if err != nil { 247 - return nil, err 248 - } 249 - 250 - blk, err := bs.Get(ctx, c) 251 - if err != nil { 252 - return nil, err 253 - } 254 - 255 - return lexutil.CborDecodeValue(blk.RawData()) 256 190 } 257 191 258 192 func (s *Server) RunAPI(addr string) error {