this repo has no description
0
fork

Configure Feed

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

atproto: hand-roll com.atproto.admin.moderationReport helper

The motivation for this is to enable beemo to fetch and parse reports
using the proper ATP client code path in the near term, until lexgen can
handle this codegen directly.

+94
+94
api/atproto/admingetModerationReports.go
··· 1 + // NOTE: this is a hand-rolled implementation of this endpoint, until lexgen supports generating this endpoint 2 + // see: https://github.com/bluesky-social/indigo/issues/10 3 + 4 + package atproto 5 + 6 + import ( 7 + "context" 8 + "encoding/json" 9 + "fmt" 10 + 11 + "github.com/bluesky-social/indigo/lex/util" 12 + "github.com/bluesky-social/indigo/xrpc" 13 + ) 14 + 15 + func init() { 16 + //util.RegisterType("app.bsky.admin.moderationReport", &AdminGetModerationReports_Report{}) 17 + } 18 + 19 + // schema: com.atproto.admin.getModerationReports 20 + 21 + type AdminGetModerationReports_Report struct { 22 + LexiconTypeID string `json:"$type,omitempty"` 23 + Id int64 `json:"id" cborgen:"id"` 24 + ReasonType string `json:"reasonType" cborgen:"reasonType"` 25 + Reason string `json:"reason" cborgen:"reason"` 26 + Subject *AdminGetModerationReports_Subject `json:"subject" cborgen:"subject"` 27 + ReportedByDid string `json:"reportedByDid" cborgen:"reportedByDid"` 28 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 29 + ResolvedByActionIds []int64 `json:"resolvedByActionIds" cborgen:"resolvedByActionIds"` 30 + } 31 + 32 + type AdminGetModerationReports_Subject struct { 33 + RepoRepoRef *RepoRepoRef 34 + RepoStrongRef *RepoStrongRef 35 + } 36 + 37 + func (t *AdminGetModerationReports_Subject) MarshalJSON() ([]byte, error) { 38 + if t.RepoRepoRef != nil { 39 + t.RepoRepoRef.LexiconTypeID = "com.atproto.repo.repoRef" 40 + return json.Marshal(t.RepoRepoRef) 41 + } 42 + if t.RepoStrongRef != nil { 43 + t.RepoStrongRef.LexiconTypeID = "com.atproto.repo.strongRef" 44 + return json.Marshal(t.RepoStrongRef) 45 + } 46 + return nil, fmt.Errorf("cannot marshal empty enum") 47 + } 48 + func (t *AdminGetModerationReports_Subject) UnmarshalJSON(b []byte) error { 49 + typ, err := util.TypeExtract(b) 50 + if err != nil { 51 + return err 52 + } 53 + 54 + switch typ { 55 + case "com.atproto.repo.repoRef": 56 + t.RepoRepoRef = new(RepoRepoRef) 57 + return json.Unmarshal(b, t.RepoRepoRef) 58 + case "com.atproto.repo.strongRef": 59 + t.RepoStrongRef = new(RepoStrongRef) 60 + return json.Unmarshal(b, t.RepoStrongRef) 61 + 62 + default: 63 + return fmt.Errorf("closed enums must have a matching value") 64 + } 65 + } 66 + 67 + type AdminGetModerationReports_Output struct { 68 + LexiconTypeID string `json:"$type,omitempty"` 69 + Cursor string `json:"cursor" cborgen:"cursor"` 70 + Reports []*AdminGetModerationReports_Report `json:"reports" cborgen:"reports"` 71 + } 72 + 73 + func AdminGetModerationReports(ctx context.Context, c *xrpc.Client, subject *string, resolved *bool, before *string, limit *int64) (*AdminGetModerationReports_Output, error) { 74 + var out AdminGetModerationReports_Output 75 + 76 + params := map[string]interface{}{} 77 + if subject != nil { 78 + params["subject"] = *subject 79 + } 80 + if resolved != nil { 81 + params["resolved"] = resolved 82 + } 83 + if limit != nil { 84 + params["limit"] = *limit 85 + } 86 + if before != nil { 87 + params["before"] = *before 88 + } 89 + if err := c.Do(ctx, xrpc.Query, "", "com.atproto.admin.getModerationReports", params, nil, &out); err != nil { 90 + return nil, err 91 + } 92 + 93 + return &out, nil 94 + }