this repo has no description
0
fork

Configure Feed

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

update cborgen to fix nil vs empty slice issue (#516)

authored by

Whyrusleeping and committed by
GitHub
c207fa0c e500a624

+139 -59
+25 -2
api/atproto/admindefs.go
··· 154 154 ReportType *string `json:"reportType" cborgen:"reportType"` 155 155 } 156 156 157 + // AdminDefs_ModEventResolveAppeal is a "modEventResolveAppeal" in the com.atproto.admin.defs schema. 158 + // 159 + // # Resolve appeal on a subject 160 + // 161 + // RECORDTYPE: AdminDefs_ModEventResolveAppeal 162 + type AdminDefs_ModEventResolveAppeal struct { 163 + LexiconTypeID string `json:"$type,const=com.atproto.admin.defs#modEventResolveAppeal" cborgen:"$type,const=com.atproto.admin.defs#modEventResolveAppeal"` 164 + // comment: Describe resolution. 165 + Comment *string `json:"comment,omitempty" cborgen:"comment,omitempty"` 166 + } 167 + 157 168 // AdminDefs_ModEventReverseTakedown is a "modEventReverseTakedown" in the com.atproto.admin.defs schema. 158 169 // 159 170 // # Revert take down action on a subject ··· 219 230 AdminDefs_ModEventAcknowledge *AdminDefs_ModEventAcknowledge 220 231 AdminDefs_ModEventEscalate *AdminDefs_ModEventEscalate 221 232 AdminDefs_ModEventMute *AdminDefs_ModEventMute 233 + AdminDefs_ModEventResolveAppeal *AdminDefs_ModEventResolveAppeal 222 234 } 223 235 224 236 func (t *AdminDefs_ModEventViewDetail_Event) MarshalJSON() ([]byte, error) { ··· 254 266 t.AdminDefs_ModEventMute.LexiconTypeID = "com.atproto.admin.defs#modEventMute" 255 267 return json.Marshal(t.AdminDefs_ModEventMute) 256 268 } 269 + if t.AdminDefs_ModEventResolveAppeal != nil { 270 + t.AdminDefs_ModEventResolveAppeal.LexiconTypeID = "com.atproto.admin.defs#modEventResolveAppeal" 271 + return json.Marshal(t.AdminDefs_ModEventResolveAppeal) 272 + } 257 273 return nil, fmt.Errorf("cannot marshal empty enum") 258 274 } 259 275 func (t *AdminDefs_ModEventViewDetail_Event) UnmarshalJSON(b []byte) error { ··· 287 303 case "com.atproto.admin.defs#modEventMute": 288 304 t.AdminDefs_ModEventMute = new(AdminDefs_ModEventMute) 289 305 return json.Unmarshal(b, t.AdminDefs_ModEventMute) 306 + case "com.atproto.admin.defs#modEventResolveAppeal": 307 + t.AdminDefs_ModEventResolveAppeal = new(AdminDefs_ModEventResolveAppeal) 308 + return json.Unmarshal(b, t.AdminDefs_ModEventResolveAppeal) 290 309 291 310 default: 292 311 return nil ··· 690 709 691 710 // AdminDefs_SubjectStatusView is a "subjectStatusView" in the com.atproto.admin.defs schema. 692 711 type AdminDefs_SubjectStatusView struct { 712 + // appealed: True indicates that the a previously taken moderator action was appealed against, by the author of the content. False indicates last appeal was resolved by moderators. 713 + Appealed *bool `json:"appealed,omitempty" cborgen:"appealed,omitempty"` 693 714 // comment: Sticky comment on the subject. 694 715 Comment *string `json:"comment,omitempty" cborgen:"comment,omitempty"` 695 716 // createdAt: Timestamp referencing the first moderation status impacting event was emitted on the subject 696 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 697 - Id int64 `json:"id" cborgen:"id"` 717 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 718 + Id int64 `json:"id" cborgen:"id"` 719 + // lastAppealedAt: Timestamp referencing when the author of the subject appealed a moderation action 720 + LastAppealedAt *string `json:"lastAppealedAt,omitempty" cborgen:"lastAppealedAt,omitempty"` 698 721 LastReportedAt *string `json:"lastReportedAt,omitempty" cborgen:"lastReportedAt,omitempty"` 699 722 LastReviewedAt *string `json:"lastReviewedAt,omitempty" cborgen:"lastReviewedAt,omitempty"` 700 723 LastReviewedBy *string `json:"lastReviewedBy,omitempty" cborgen:"lastReviewedBy,omitempty"`
+3 -1
api/atproto/adminqueryModerationStatuses.go
··· 18 18 19 19 // AdminQueryModerationStatuses calls the XRPC method "com.atproto.admin.queryModerationStatuses". 20 20 // 21 + // appealed: Get subjects in unresolved appealed status 21 22 // comment: Search subjects by keyword from comments 22 23 // includeMuted: By default, we don't include muted subjects in the results. Set this to true to include them. 23 24 // lastReviewedBy: Get all subject statuses that were reviewed by a specific moderator ··· 27 28 // reviewedAfter: Search subjects reviewed after a given timestamp 28 29 // reviewedBefore: Search subjects reviewed before a given timestamp 29 30 // takendown: Get subjects that were taken down 30 - func AdminQueryModerationStatuses(ctx context.Context, c *xrpc.Client, comment string, cursor string, ignoreSubjects []string, includeMuted bool, lastReviewedBy string, limit int64, reportedAfter string, reportedBefore string, reviewState string, reviewedAfter string, reviewedBefore string, sortDirection string, sortField string, subject string, takendown bool) (*AdminQueryModerationStatuses_Output, error) { 31 + func AdminQueryModerationStatuses(ctx context.Context, c *xrpc.Client, appealed bool, comment string, cursor string, ignoreSubjects []string, includeMuted bool, lastReviewedBy string, limit int64, reportedAfter string, reportedBefore string, reviewState string, reviewedAfter string, reviewedBefore string, sortDirection string, sortField string, subject string, takendown bool) (*AdminQueryModerationStatuses_Output, error) { 31 32 var out AdminQueryModerationStatuses_Output 32 33 33 34 params := map[string]interface{}{ 35 + "appealed": appealed, 34 36 "comment": comment, 35 37 "cursor": cursor, 36 38 "ignoreSubjects": ignoreSubjects,
+69 -41
api/atproto/cbor_gen.go
··· 226 226 if err := v.MarshalCBOR(cw); err != nil { 227 227 return err 228 228 } 229 + 229 230 } 230 231 231 232 // t.Rev (string) (string) ··· 358 359 if err := v.MarshalCBOR(cw); err != nil { 359 360 return err 360 361 } 362 + 361 363 } 362 364 363 365 // t.Since (string) (string) ··· 414 416 if _, err := cw.Write(t.Blocks[:]); err != nil { 415 417 return err 416 418 } 419 + 417 420 } 418 421 419 422 // t.Commit (util.LexLink) (struct) ··· 550 553 } 551 554 552 555 } 556 + 553 557 } 554 558 } 555 - 556 559 // t.Rev (string) (string) 557 560 case "rev": 558 561 ··· 668 671 } 669 672 670 673 } 674 + 671 675 } 672 676 } 673 - 674 677 // t.Since (string) (string) 675 678 case "since": 676 679 ··· 714 717 if _, err := io.ReadFull(cr, t.Blocks[:]); err != nil { 715 718 return err 716 719 } 720 + 717 721 // t.Commit (util.LexLink) (struct) 718 722 case "commit": 719 723 ··· 1749 1753 return xerrors.Errorf("Slice value in field t.Values was too long") 1750 1754 } 1751 1755 1752 - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Values))); err != nil { 1753 - return err 1754 - } 1755 - for _, v := range t.Values { 1756 - if err := v.MarshalCBOR(cw); err != nil { 1756 + if t.Values == nil { 1757 + _, err := w.Write(cbg.CborNull) 1758 + if err != nil { 1757 1759 return err 1758 1760 } 1761 + } else { 1762 + 1763 + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Values))); err != nil { 1764 + return err 1765 + } 1766 + for _, v := range t.Values { 1767 + if err := v.MarshalCBOR(cw); err != nil { 1768 + return err 1769 + } 1770 + 1771 + } 1772 + 1759 1773 } 1760 1774 return nil 1761 1775 } ··· 1812 1826 // t.Values ([]*atproto.LabelDefs_SelfLabel) (slice) 1813 1827 case "values": 1814 1828 1815 - maj, extra, err = cr.ReadHeader() 1816 - if err != nil { 1817 - return err 1818 - } 1829 + { 1830 + b, err := cr.ReadByte() 1831 + if err != nil { 1832 + return err 1833 + } 1834 + if b != cbg.CborNull[0] { 1835 + if err := cr.UnreadByte(); err != nil { 1836 + return err 1837 + } 1819 1838 1820 - if extra > cbg.MaxLength { 1821 - return fmt.Errorf("t.Values: array too large (%d)", extra) 1822 - } 1839 + maj, extra, err = cr.ReadHeader() 1840 + if err != nil { 1841 + return err 1842 + } 1823 1843 1824 - if maj != cbg.MajArray { 1825 - return fmt.Errorf("expected cbor array") 1826 - } 1844 + if extra > cbg.MaxLength { 1845 + return fmt.Errorf("t.Values: array too large (%d)", extra) 1846 + } 1827 1847 1828 - if extra > 0 { 1829 - t.Values = make([]*LabelDefs_SelfLabel, extra) 1830 - } 1848 + if maj != cbg.MajArray { 1849 + return fmt.Errorf("expected cbor array") 1850 + } 1851 + 1852 + t.Values = make([]*LabelDefs_SelfLabel, extra) 1853 + 1854 + for i := 0; i < int(extra); i++ { 1855 + { 1856 + var maj byte 1857 + var extra uint64 1858 + var err error 1859 + _ = maj 1860 + _ = extra 1861 + _ = err 1831 1862 1832 - for i := 0; i < int(extra); i++ { 1833 - { 1834 - var maj byte 1835 - var extra uint64 1836 - var err error 1837 - _ = maj 1838 - _ = extra 1839 - _ = err 1863 + { 1840 1864 1841 - { 1865 + b, err := cr.ReadByte() 1866 + if err != nil { 1867 + return err 1868 + } 1869 + if b != cbg.CborNull[0] { 1870 + if err := cr.UnreadByte(); err != nil { 1871 + return err 1872 + } 1873 + t.Values[i] = new(LabelDefs_SelfLabel) 1874 + if err := t.Values[i].UnmarshalCBOR(cr); err != nil { 1875 + return xerrors.Errorf("unmarshaling t.Values[i] pointer: %w", err) 1876 + } 1877 + } 1842 1878 1843 - b, err := cr.ReadByte() 1844 - if err != nil { 1845 - return err 1846 - } 1847 - if b != cbg.CborNull[0] { 1848 - if err := cr.UnreadByte(); err != nil { 1849 - return err 1850 1879 } 1851 - t.Values[i] = new(LabelDefs_SelfLabel) 1852 - if err := t.Values[i].UnmarshalCBOR(cr); err != nil { 1853 - return xerrors.Errorf("unmarshaling t.Values[i] pointer: %w", err) 1854 - } 1880 + 1855 1881 } 1882 + } 1856 1883 1857 - } 1858 1884 } 1859 1885 } 1860 1886 ··· 2335 2361 if err := v.MarshalCBOR(cw); err != nil { 2336 2362 return err 2337 2363 } 2364 + 2338 2365 } 2339 2366 return nil 2340 2367 } ··· 2449 2476 } 2450 2477 2451 2478 } 2479 + 2452 2480 } 2453 2481 } 2454 2482
+1 -1
api/atproto/labeldefs.go
··· 37 37 // RECORDTYPE: LabelDefs_SelfLabels 38 38 type LabelDefs_SelfLabels struct { 39 39 LexiconTypeID string `json:"$type,const=com.atproto.label.defs#selfLabels" cborgen:"$type,const=com.atproto.label.defs#selfLabels"` 40 - Values []*LabelDefs_SelfLabel `json:"values" cborgen:"values"` 40 + Values []*LabelDefs_SelfLabel `json:"values" cborgen:"values,preservenil"` 41 41 }
+18 -5
api/bsky/cbor_gen.go
··· 93 93 if _, err := cw.WriteString(string(v)); err != nil { 94 94 return err 95 95 } 96 + 96 97 } 97 98 } 98 99 ··· 189 190 if _, err := cw.WriteString(string(v)); err != nil { 190 191 return err 191 192 } 193 + 192 194 } 193 195 } 194 196 ··· 236 238 if err := v.MarshalCBOR(cw); err != nil { 237 239 return err 238 240 } 241 + 239 242 } 240 243 } 241 244 ··· 283 286 if err := v.MarshalCBOR(cw); err != nil { 284 287 return err 285 288 } 289 + 286 290 } 287 291 } 288 292 ··· 386 390 387 391 t.Tags[i] = string(sval) 388 392 } 393 + 389 394 } 390 395 } 391 - 392 396 // t.Text (string) (string) 393 397 case "text": 394 398 ··· 468 472 469 473 t.Langs[i] = string(sval) 470 474 } 475 + 471 476 } 472 477 } 473 - 474 478 // t.Reply (bsky.FeedPost_ReplyRef) (struct) 475 479 case "reply": 476 480 ··· 537 541 } 538 542 539 543 } 544 + 540 545 } 541 546 } 542 - 543 547 // t.Labels (bsky.FeedPost_Labels) (struct) 544 548 case "labels": 545 549 ··· 606 610 } 607 611 608 612 } 613 + 609 614 } 610 615 } 611 - 612 616 // t.CreatedAt (string) (string) 613 617 case "createdAt": 614 618 ··· 1299 1303 if err := v.MarshalCBOR(cw); err != nil { 1300 1304 return err 1301 1305 } 1306 + 1302 1307 } 1303 1308 return nil 1304 1309 } ··· 1398 1403 } 1399 1404 1400 1405 } 1406 + 1401 1407 } 1402 1408 } 1403 1409 ··· 2751 2757 if err := v.MarshalCBOR(cw); err != nil { 2752 2758 return err 2753 2759 } 2760 + 2754 2761 } 2755 2762 return nil 2756 2763 } ··· 2859 2866 } 2860 2867 2861 2868 } 2869 + 2862 2870 } 2863 2871 } 2864 2872 ··· 4101 4109 if err := v.MarshalCBOR(cw); err != nil { 4102 4110 return err 4103 4111 } 4112 + 4104 4113 } 4105 4114 } 4106 4115 return nil ··· 4305 4314 } 4306 4315 4307 4316 } 4317 + 4308 4318 } 4309 4319 } 4310 4320 ··· 4721 4731 if err := v.MarshalCBOR(cw); err != nil { 4722 4732 return err 4723 4733 } 4734 + 4724 4735 } 4725 4736 } 4726 4737 return nil ··· 4915 4926 } 4916 4927 4917 4928 } 4929 + 4918 4930 } 4919 4931 } 4920 4932 ··· 5326 5338 if err := v.MarshalCBOR(cw); err != nil { 5327 5339 return err 5328 5340 } 5341 + 5329 5342 } 5330 5343 } 5331 5344 ··· 5460 5473 } 5461 5474 5462 5475 } 5476 + 5463 5477 } 5464 5478 } 5465 - 5466 5479 // t.CreatedAt (string) (string) 5467 5480 case "createdAt": 5468 5481
+1 -1
cmd/gosky/admin.go
··· 675 675 did = resp 676 676 } 677 677 678 - resp, err := atproto.AdminQueryModerationStatuses(ctx, xrpcc, "", "", nil, true, "", 100, "", "", "", "", "", "", "", "", false) 678 + resp, err := atproto.AdminQueryModerationStatuses(ctx, xrpcc, false, "", "", nil, true, "", 100, "", "", "", "", "", "", "", "", false) 679 679 if err != nil { 680 680 return err 681 681 }
+1 -1
gen/main.go
··· 6 6 "github.com/bluesky-social/indigo/api" 7 7 atproto "github.com/bluesky-social/indigo/api/atproto" 8 8 bsky "github.com/bluesky-social/indigo/api/bsky" 9 + "github.com/bluesky-social/indigo/atproto/data" 9 10 "github.com/bluesky-social/indigo/events" 10 11 lexutil "github.com/bluesky-social/indigo/lex/util" 11 12 "github.com/bluesky-social/indigo/mst" 12 13 "github.com/bluesky-social/indigo/repo" 13 - "github.com/bluesky-social/indigo/atproto/data" 14 14 15 15 cbg "github.com/whyrusleeping/cbor-gen" 16 16 )
+1 -1
go.mod
··· 52 52 github.com/scylladb/gocqlx/v2 v2.8.1-0.20230309105046-dec046bd85e6 53 53 github.com/stretchr/testify v1.8.4 54 54 github.com/urfave/cli/v2 v2.25.7 55 - github.com/whyrusleeping/cbor-gen v0.0.0-20230923211252-36a87e1ba72f 55 + github.com/whyrusleeping/cbor-gen v0.0.0-20240104201801-075d1573fac9 56 56 github.com/whyrusleeping/go-did v0.0.0-20230824162731-404d1707d5d6 57 57 gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b 58 58 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1
+2 -2
go.sum
··· 634 634 github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= 635 635 github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 h1:5HZfQkwe0mIfyDmc1Em5GqlNRzcdtlv4HTNmdpt7XH0= 636 636 github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11/go.mod h1:Wlo/SzPmxVp6vXpGt/zaXhHH0fn4IxgqZc82aKg6bpQ= 637 - github.com/whyrusleeping/cbor-gen v0.0.0-20230923211252-36a87e1ba72f h1:SBuSxXJL0/ZJMtTxbXZgHZkThl9dNrzyaNhlyaqscRo= 638 - github.com/whyrusleeping/cbor-gen v0.0.0-20230923211252-36a87e1ba72f/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= 637 + github.com/whyrusleeping/cbor-gen v0.0.0-20240104201801-075d1573fac9 h1:973JQTSOMo66VlNZ2+tMQYruE0Yny9DrKvIkr/ybRJg= 638 + github.com/whyrusleeping/cbor-gen v0.0.0-20240104201801-075d1573fac9/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= 639 639 github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= 640 640 github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8= 641 641 github.com/whyrusleeping/go-did v0.0.0-20230824162731-404d1707d5d6 h1:yJ9/LwIGIk/c0CdoavpC9RNSGSruIspSZtxG3Nnldic=
+4
lex/gen.go
··· 1261 1261 cborOmit = ",omitempty" 1262 1262 } 1263 1263 1264 + if name == "LabelDefs_SelfLabels" && k == "values" { 1265 + cborOmit += ",preservenil" 1266 + } 1267 + 1264 1268 if v.Description != "" { 1265 1269 pf("\t// %s: %s\n", k, v.Description) 1266 1270 }
+10 -3
lex/util/cbor_gen_test.go
··· 110 110 if _, err := cw.WriteString(string(v)); err != nil { 111 111 return err 112 112 } 113 + 113 114 } 114 115 115 116 // t.Absent (string) (string) ··· 344 345 345 346 t.Array[i] = string(sval) 346 347 } 348 + 347 349 } 348 350 } 349 - 350 351 // t.Absent (string) (string) 351 352 case "absent": 352 353 ··· 477 478 if _, err := cw.WriteString(string(v)); err != nil { 478 479 return err 479 480 } 481 + 480 482 } 481 483 482 484 // t.Bool (bool) (bool) ··· 617 619 618 620 t.Arr[i] = string(sval) 619 621 } 622 + 620 623 } 621 624 } 622 - 623 625 // t.Bool (bool) (bool) 624 626 case "bool": 625 627 ··· 824 826 if _, err := io.ReadFull(cr, t.B[:]); err != nil { 825 827 return err 826 828 } 829 + 827 830 // t.C (util.LexBlob) (struct) 828 831 case "c": 829 832 ··· 1012 1015 if _, err := cw.WriteString(string(v)); err != nil { 1013 1016 return err 1014 1017 } 1018 + 1015 1019 } 1016 1020 1017 1021 // t.G (util.basicOldSchemaInner) (struct) ··· 1204 1208 1205 1209 t.F[i] = string(sval) 1206 1210 } 1211 + 1207 1212 } 1208 1213 } 1209 - 1210 1214 // t.G (util.basicOldSchemaInner) (struct) 1211 1215 case "g": 1212 1216 ··· 1329 1333 if _, err := cw.WriteString(string(v)); err != nil { 1330 1334 return err 1331 1335 } 1336 + 1332 1337 } 1333 1338 return nil 1334 1339 } ··· 1463 1468 1464 1469 t.K[i] = string(sval) 1465 1470 } 1471 + 1466 1472 } 1467 1473 } 1468 1474 ··· 1525 1531 if _, err := cw.Write(t.B[:]); err != nil { 1526 1532 return err 1527 1533 } 1534 + 1528 1535 return nil 1529 1536 } 1530 1537
+3 -1
mst/cbor_gen.go
··· 53 53 if err := v.MarshalCBOR(cw); err != nil { 54 54 return err 55 55 } 56 + 56 57 } 57 58 58 59 // t.Left (cid.Cid) (struct) ··· 154 155 } 155 156 156 157 } 158 + 157 159 } 158 160 } 159 - 160 161 // t.Left (cid.Cid) (struct) 161 162 case "l": 162 163 ··· 348 349 if _, err := io.ReadFull(cr, t.KeySuffix[:]); err != nil { 349 350 return err 350 351 } 352 + 351 353 // t.PrefixLen (int64) (int64) 352 354 case "p": 353 355 {
+1
repo/cbor_gen.go
··· 252 252 if _, err := io.ReadFull(cr, t.Sig[:]); err != nil { 253 253 return err 254 254 } 255 + 255 256 // t.Data (cid.Cid) (struct) 256 257 case "data": 257 258