this repo has no description
0
fork

Configure Feed

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

quick command to hit the list labels endpoint (#453)

authored by

Whyrusleeping and committed by
GitHub
25a236f7 4876fc41

+52
+52
cmd/gosky/main.go
··· 25 25 "github.com/bluesky-social/indigo/repo" 26 26 "github.com/bluesky-social/indigo/util" 27 27 "github.com/bluesky-social/indigo/util/cliutil" 28 + "github.com/bluesky-social/indigo/xrpc" 28 29 "golang.org/x/time/rate" 29 30 30 31 "github.com/gorilla/websocket" ··· 93 94 listAllRecordsCmd, 94 95 readRepoStreamCmd, 95 96 parseRkey, 97 + listLabelsCmd, 96 98 } 97 99 98 100 app.RunAndExitOnError() ··· 707 709 return nil 708 710 }, 709 711 } 712 + 713 + var listLabelsCmd = &cli.Command{ 714 + Name: "list-labels", 715 + Usage: "list labels", 716 + Flags: []cli.Flag{ 717 + &cli.DurationFlag{ 718 + Name: "since", 719 + Value: time.Hour, 720 + }, 721 + }, 722 + Action: func(cctx *cli.Context) error { 723 + 724 + ctx := context.TODO() 725 + 726 + delta := cctx.Duration("since") 727 + since := time.Now().Add(-1 * delta).UnixMilli() 728 + 729 + xrpcc := &xrpc.Client{ 730 + Host: "https://api.bsky.app", 731 + } 732 + 733 + for { 734 + out, err := atproto.TempFetchLabels(ctx, xrpcc, 100, since) 735 + if err != nil { 736 + return err 737 + } 738 + 739 + for _, l := range out.Labels { 740 + b, err := json.MarshalIndent(l, "", " ") 741 + if err != nil { 742 + return err 743 + } 744 + 745 + fmt.Println(string(b)) 746 + } 747 + 748 + if len(out.Labels) > 0 { 749 + last := out.Labels[len(out.Labels)-1] 750 + ts, err := util.ParseTimestamp(last.Cts) 751 + if err != nil { 752 + return fmt.Errorf("invalid cts: %w", err) 753 + } 754 + since = ts.UnixMilli() 755 + } else { 756 + break 757 + } 758 + } 759 + return nil 760 + }, 761 + }