this repo has no description
0
fork

Configure Feed

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

add command to help debug feed generators (#183)

Some basic checks to help find issues with feed generator deployments

authored by

Whyrusleeping and committed by
GitHub
7f792c32 80c094da

+108 -2
+108 -2
cmd/gosky/debug.go
··· 9 9 "net/http" 10 10 "strconv" 11 11 12 + "github.com/bluesky-social/indigo/api/atproto" 12 13 comatproto "github.com/bluesky-social/indigo/api/atproto" 14 + "github.com/bluesky-social/indigo/api/bsky" 15 + cliutil "github.com/bluesky-social/indigo/cmd/gosky/util" 16 + "github.com/bluesky-social/indigo/did" 13 17 "github.com/bluesky-social/indigo/events" 14 - "github.com/bluesky-social/indigo/lex/util" 18 + lexutil "github.com/bluesky-social/indigo/lex/util" 15 19 "github.com/bluesky-social/indigo/repo" 16 20 "github.com/bluesky-social/indigo/repomgr" 21 + "github.com/bluesky-social/indigo/util" 22 + "github.com/bluesky-social/indigo/xrpc" 17 23 18 24 "github.com/gorilla/websocket" 19 25 "github.com/ipfs/go-cid" ··· 27 33 Subcommands: []*cli.Command{ 28 34 inspectEventCmd, 29 35 debugStreamCmd, 36 + debugFeedGenCmd, 30 37 }, 31 38 } 32 39 ··· 145 152 LastSeq int64 146 153 } 147 154 148 - func cidStr(c *util.LexLink) string { 155 + func cidStr(c *lexutil.LexLink) string { 149 156 if c == nil { 150 157 return "<nil>" 151 158 } ··· 244 251 return nil 245 252 }, 246 253 } 254 + 255 + var debugFeedGenCmd = &cli.Command{ 256 + Name: "debug-feed", 257 + Action: func(cctx *cli.Context) error { 258 + xrpcc, err := cliutil.GetXrpcClient(cctx, true) 259 + if err != nil { 260 + return err 261 + } 262 + 263 + didr := cliutil.GetDidResolver(cctx) 264 + 265 + uri := cctx.Args().First() 266 + puri, err := util.ParseAtUri(uri) 267 + if err != nil { 268 + return err 269 + } 270 + 271 + ctx := context.TODO() 272 + 273 + out, err := atproto.RepoGetRecord(ctx, xrpcc, "", puri.Collection, puri.Did, puri.Rkey) 274 + if err != nil { 275 + return fmt.Errorf("getting record: %w", err) 276 + } 277 + 278 + fgr, ok := out.Value.Val.(*bsky.FeedGenerator) 279 + if !ok { 280 + return fmt.Errorf("invalid feedgen record") 281 + } 282 + 283 + fmt.Println("Feed DID is: ", fgr.Did) 284 + doc, err := didr.GetDocument(ctx, fgr.Did) 285 + if err != nil { 286 + return err 287 + } 288 + 289 + fmt.Println("Got service did document:") 290 + b, err := json.MarshalIndent(doc, "", " ") 291 + if err != nil { 292 + return err 293 + } 294 + fmt.Println(string(b)) 295 + 296 + var ss *did.Service 297 + for _, s := range doc.Service { 298 + if s.ID.String() == "#bsky_fg" { 299 + cp := s 300 + ss = &cp 301 + break 302 + } 303 + } 304 + 305 + if ss == nil { 306 + return fmt.Errorf("No '#bsky_fg' service entry found in feedgens DID document") 307 + } 308 + 309 + fmt.Println("Service endpoint is: ", ss.ServiceEndpoint) 310 + 311 + fgclient := &xrpc.Client{ 312 + Host: ss.ServiceEndpoint, 313 + } 314 + 315 + desc, err := bsky.FeedDescribeFeedGenerator(ctx, fgclient) 316 + if err != nil { 317 + return err 318 + } 319 + 320 + fmt.Printf("Found %d feeds at discovered endpoint\n", len(desc.Feeds)) 321 + var found bool 322 + for _, f := range desc.Feeds { 323 + fmt.Println("Feed: ", f.Uri) 324 + if f.Uri == uri { 325 + found = true 326 + break 327 + } 328 + } 329 + 330 + if !found { 331 + return fmt.Errorf("specified feed was not present in linked feedGenerators 'describe' method output") 332 + } 333 + 334 + skel, err := bsky.FeedGetFeedSkeleton(ctx, fgclient, "", uri, 30) 335 + if err != nil { 336 + return fmt.Errorf("failed to fetch feed skeleton: %w", err) 337 + } 338 + 339 + if len(skel.Feed) > 30 { 340 + return fmt.Errorf("feedgen not respecting limit param (returned %d posts)", len(skel.Feed)) 341 + } 342 + 343 + if len(skel.Feed) == 0 { 344 + return fmt.Errorf("feedgen response is empty (might be expected since we aren't authed)") 345 + 346 + } 347 + 348 + fmt.Println("Feed response looks good!") 349 + 350 + return nil 351 + }, 352 + }