Monorepo for Tangled tangled.org
854
fork

Configure Feed

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

lexicons: `com.atproto.repo.strongRef` and `sh.tangled.markup.markdown`

use `com.atproto.repo.strongRef` for more explicit reference &
`markup.markdown` type to give clear semantic meaning in markdown

Close: <https://tangled.org/tangled.org/core/issues/383>
Signed-off-by: Seongmin Lee <git@boltless.me>

+577 -270
+364 -191
api/tangled/cbor_gen.go
··· 8 8 "math" 9 9 "sort" 10 10 11 + atproto "github.com/bluesky-social/indigo/api/atproto" 11 12 util "github.com/bluesky-social/indigo/lex/util" 12 13 cid "github.com/ipfs/go-cid" 13 14 cbg "github.com/whyrusleeping/cbor-gen" ··· 661 662 662 663 return nil 663 664 } 664 - func (t *Comment) MarshalCBOR(w io.Writer) error { 665 + func (t *FeedComment) MarshalCBOR(w io.Writer) error { 665 666 if t == nil { 666 667 _, err := w.Write(cbg.CborNull) 667 668 return err 668 669 } 669 670 670 671 cw := cbg.NewCborWriter(w) 671 - fieldCount := 7 672 + fieldCount := 6 672 673 673 - if t.Mentions == nil { 674 - fieldCount-- 675 - } 676 - 677 - if t.References == nil { 674 + if t.PullRoundIdx == nil { 678 675 fieldCount-- 679 676 } 680 677 ··· 686 683 return err 687 684 } 688 685 689 - // t.Body (string) (string) 686 + // t.Body (tangled.FeedComment_Body) (struct) 690 687 if len("body") > 1000000 { 691 688 return xerrors.Errorf("Value in field \"body\" was too long") 692 689 } ··· 698 695 return err 699 696 } 700 697 701 - if len(t.Body) > 1000000 { 702 - return xerrors.Errorf("Value in field t.Body was too long") 703 - } 704 - 705 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Body))); err != nil { 706 - return err 707 - } 708 - if _, err := cw.WriteString(string(t.Body)); err != nil { 698 + if err := t.Body.MarshalCBOR(cw); err != nil { 709 699 return err 710 700 } 711 701 ··· 721 711 return err 722 712 } 723 713 724 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.comment"))); err != nil { 714 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.feed.comment"))); err != nil { 725 715 return err 726 716 } 727 - if _, err := cw.WriteString(string("sh.tangled.comment")); err != nil { 717 + if _, err := cw.WriteString(string("sh.tangled.feed.comment")); err != nil { 728 718 return err 729 719 } 730 720 731 - // t.ReplyTo (string) (string) 721 + // t.ReplyTo (atproto.RepoStrongRef) (struct) 732 722 if t.ReplyTo != nil { 733 723 734 724 if len("replyTo") > 1000000 { ··· 742 732 return err 743 733 } 744 734 745 - if t.ReplyTo == nil { 746 - if _, err := cw.Write(cbg.CborNull); err != nil { 747 - return err 748 - } 749 - } else { 750 - if len(*t.ReplyTo) > 1000000 { 751 - return xerrors.Errorf("Value in field t.ReplyTo was too long") 752 - } 753 - 754 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.ReplyTo))); err != nil { 755 - return err 756 - } 757 - if _, err := cw.WriteString(string(*t.ReplyTo)); err != nil { 758 - return err 759 - } 735 + if err := t.ReplyTo.MarshalCBOR(cw); err != nil { 736 + return err 760 737 } 761 738 } 762 739 763 - // t.Subject (string) (string) 740 + // t.Subject (atproto.RepoStrongRef) (struct) 764 741 if len("subject") > 1000000 { 765 742 return xerrors.Errorf("Value in field \"subject\" was too long") 766 743 } ··· 772 749 return err 773 750 } 774 751 775 - if len(t.Subject) > 1000000 { 776 - return xerrors.Errorf("Value in field t.Subject was too long") 777 - } 778 - 779 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Subject))); err != nil { 780 - return err 781 - } 782 - if _, err := cw.WriteString(string(t.Subject)); err != nil { 752 + if err := t.Subject.MarshalCBOR(cw); err != nil { 783 753 return err 784 754 } 785 755 786 - // t.Mentions ([]string) (slice) 787 - if t.Mentions != nil { 788 - 789 - if len("mentions") > 1000000 { 790 - return xerrors.Errorf("Value in field \"mentions\" was too long") 791 - } 792 - 793 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("mentions"))); err != nil { 794 - return err 795 - } 796 - if _, err := cw.WriteString(string("mentions")); err != nil { 797 - return err 798 - } 799 - 800 - if len(t.Mentions) > 8192 { 801 - return xerrors.Errorf("Slice value in field t.Mentions was too long") 802 - } 803 - 804 - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Mentions))); err != nil { 805 - return err 806 - } 807 - for _, v := range t.Mentions { 808 - if len(v) > 1000000 { 809 - return xerrors.Errorf("Value in field v was too long") 810 - } 811 - 812 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { 813 - return err 814 - } 815 - if _, err := cw.WriteString(string(v)); err != nil { 816 - return err 817 - } 818 - 819 - } 820 - } 821 - 822 756 // t.CreatedAt (string) (string) 823 757 if len("createdAt") > 1000000 { 824 758 return xerrors.Errorf("Value in field \"createdAt\" was too long") ··· 842 776 return err 843 777 } 844 778 845 - // t.References ([]string) (slice) 846 - if t.References != nil { 779 + // t.PullRoundIdx (int64) (int64) 780 + if t.PullRoundIdx != nil { 847 781 848 - if len("references") > 1000000 { 849 - return xerrors.Errorf("Value in field \"references\" was too long") 782 + if len("pullRoundIdx") > 1000000 { 783 + return xerrors.Errorf("Value in field \"pullRoundIdx\" was too long") 850 784 } 851 785 852 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("references"))); err != nil { 786 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pullRoundIdx"))); err != nil { 853 787 return err 854 788 } 855 - if _, err := cw.WriteString(string("references")); err != nil { 789 + if _, err := cw.WriteString(string("pullRoundIdx")); err != nil { 856 790 return err 857 791 } 858 792 859 - if len(t.References) > 8192 { 860 - return xerrors.Errorf("Slice value in field t.References was too long") 861 - } 862 - 863 - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.References))); err != nil { 864 - return err 865 - } 866 - for _, v := range t.References { 867 - if len(v) > 1000000 { 868 - return xerrors.Errorf("Value in field v was too long") 869 - } 870 - 871 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { 793 + if t.PullRoundIdx == nil { 794 + if _, err := cw.Write(cbg.CborNull); err != nil { 872 795 return err 873 796 } 874 - if _, err := cw.WriteString(string(v)); err != nil { 875 - return err 797 + } else { 798 + if *t.PullRoundIdx >= 0 { 799 + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(*t.PullRoundIdx)); err != nil { 800 + return err 801 + } 802 + } else { 803 + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-*t.PullRoundIdx-1)); err != nil { 804 + return err 805 + } 876 806 } 807 + } 877 808 878 - } 879 809 } 880 810 return nil 881 811 } 882 812 883 - func (t *Comment) UnmarshalCBOR(r io.Reader) (err error) { 884 - *t = Comment{} 813 + func (t *FeedComment) UnmarshalCBOR(r io.Reader) (err error) { 814 + *t = FeedComment{} 885 815 886 816 cr := cbg.NewCborReader(r) 887 817 ··· 900 830 } 901 831 902 832 if extra > cbg.MaxLength { 903 - return fmt.Errorf("Comment: map struct too large (%d)", extra) 833 + return fmt.Errorf("FeedComment: map struct too large (%d)", extra) 904 834 } 905 835 906 836 n := extra 907 837 908 - nameBuf := make([]byte, 10) 838 + nameBuf := make([]byte, 12) 909 839 for i := uint64(0); i < n; i++ { 910 840 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 911 841 if err != nil { ··· 921 851 } 922 852 923 853 switch string(nameBuf[:nameLen]) { 924 - // t.Body (string) (string) 854 + // t.Body (tangled.FeedComment_Body) (struct) 925 855 case "body": 926 856 927 857 { 928 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 858 + 859 + b, err := cr.ReadByte() 929 860 if err != nil { 930 861 return err 931 862 } 863 + if b != cbg.CborNull[0] { 864 + if err := cr.UnreadByte(); err != nil { 865 + return err 866 + } 867 + t.Body = new(FeedComment_Body) 868 + if err := t.Body.UnmarshalCBOR(cr); err != nil { 869 + return xerrors.Errorf("unmarshaling t.Body pointer: %w", err) 870 + } 871 + } 932 872 933 - t.Body = string(sval) 934 873 } 935 874 // t.LexiconTypeID (string) (string) 936 875 case "$type": ··· 943 882 944 883 t.LexiconTypeID = string(sval) 945 884 } 946 - // t.ReplyTo (string) (string) 885 + // t.ReplyTo (atproto.RepoStrongRef) (struct) 947 886 case "replyTo": 948 887 949 888 { 889 + 950 890 b, err := cr.ReadByte() 951 891 if err != nil { 952 892 return err ··· 955 895 if err := cr.UnreadByte(); err != nil { 956 896 return err 957 897 } 958 - 959 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 960 - if err != nil { 961 - return err 898 + t.ReplyTo = new(atproto.RepoStrongRef) 899 + if err := t.ReplyTo.UnmarshalCBOR(cr); err != nil { 900 + return xerrors.Errorf("unmarshaling t.ReplyTo pointer: %w", err) 962 901 } 902 + } 963 903 964 - t.ReplyTo = (*string)(&sval) 965 - } 966 904 } 967 - // t.Subject (string) (string) 905 + // t.Subject (atproto.RepoStrongRef) (struct) 968 906 case "subject": 969 907 970 908 { 971 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 909 + 910 + b, err := cr.ReadByte() 972 911 if err != nil { 973 912 return err 974 913 } 975 - 976 - t.Subject = string(sval) 977 - } 978 - // t.Mentions ([]string) (slice) 979 - case "mentions": 980 - 981 - maj, extra, err = cr.ReadHeader() 982 - if err != nil { 983 - return err 984 - } 985 - 986 - if extra > 8192 { 987 - return fmt.Errorf("t.Mentions: array too large (%d)", extra) 988 - } 989 - 990 - if maj != cbg.MajArray { 991 - return fmt.Errorf("expected cbor array") 992 - } 993 - 994 - if extra > 0 { 995 - t.Mentions = make([]string, extra) 996 - } 997 - 998 - for i := 0; i < int(extra); i++ { 999 - { 1000 - var maj byte 1001 - var extra uint64 1002 - var err error 1003 - _ = maj 1004 - _ = extra 1005 - _ = err 1006 - 1007 - { 1008 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 1009 - if err != nil { 1010 - return err 1011 - } 1012 - 1013 - t.Mentions[i] = string(sval) 914 + if b != cbg.CborNull[0] { 915 + if err := cr.UnreadByte(); err != nil { 916 + return err 1014 917 } 918 + t.Subject = new(atproto.RepoStrongRef) 919 + if err := t.Subject.UnmarshalCBOR(cr); err != nil { 920 + return xerrors.Errorf("unmarshaling t.Subject pointer: %w", err) 921 + } 922 + } 1015 923 1016 - } 1017 924 } 1018 925 // t.CreatedAt (string) (string) 1019 926 case "createdAt": ··· 1026 933 1027 934 t.CreatedAt = string(sval) 1028 935 } 1029 - // t.References ([]string) (slice) 1030 - case "references": 936 + // t.PullRoundIdx (int64) (int64) 937 + case "pullRoundIdx": 938 + { 1031 939 1032 - maj, extra, err = cr.ReadHeader() 1033 - if err != nil { 1034 - return err 1035 - } 1036 - 1037 - if extra > 8192 { 1038 - return fmt.Errorf("t.References: array too large (%d)", extra) 1039 - } 1040 - 1041 - if maj != cbg.MajArray { 1042 - return fmt.Errorf("expected cbor array") 1043 - } 1044 - 1045 - if extra > 0 { 1046 - t.References = make([]string, extra) 1047 - } 1048 - 1049 - for i := 0; i < int(extra); i++ { 1050 - { 1051 - var maj byte 1052 - var extra uint64 1053 - var err error 1054 - _ = maj 1055 - _ = extra 1056 - _ = err 1057 - 1058 - { 1059 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 1060 - if err != nil { 1061 - return err 940 + b, err := cr.ReadByte() 941 + if err != nil { 942 + return err 943 + } 944 + if b != cbg.CborNull[0] { 945 + if err := cr.UnreadByte(); err != nil { 946 + return err 947 + } 948 + maj, extra, err := cr.ReadHeader() 949 + if err != nil { 950 + return err 951 + } 952 + var extraI int64 953 + switch maj { 954 + case cbg.MajUnsignedInt: 955 + extraI = int64(extra) 956 + if extraI < 0 { 957 + return fmt.Errorf("int64 positive overflow") 958 + } 959 + case cbg.MajNegativeInt: 960 + extraI = int64(extra) 961 + if extraI < 0 { 962 + return fmt.Errorf("int64 negative overflow") 1062 963 } 1063 - 1064 - t.References[i] = string(sval) 964 + extraI = -1 - extraI 965 + default: 966 + return fmt.Errorf("wrong type for int64 field: %d", maj) 1065 967 } 1066 968 969 + t.PullRoundIdx = (*int64)(&extraI) 1067 970 } 1068 971 } 1069 972 ··· 4550 4453 } 4551 4454 4552 4455 t.Value = string(sval) 4456 + } 4457 + 4458 + default: 4459 + // Field doesn't exist on this type, so ignore it 4460 + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 4461 + return err 4462 + } 4463 + } 4464 + } 4465 + 4466 + return nil 4467 + } 4468 + func (t *MarkupMarkdown) MarshalCBOR(w io.Writer) error { 4469 + if t == nil { 4470 + _, err := w.Write(cbg.CborNull) 4471 + return err 4472 + } 4473 + 4474 + cw := cbg.NewCborWriter(w) 4475 + fieldCount := 4 4476 + 4477 + if t.Blobs == nil { 4478 + fieldCount-- 4479 + } 4480 + 4481 + if t.Original == nil { 4482 + fieldCount-- 4483 + } 4484 + 4485 + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 4486 + return err 4487 + } 4488 + 4489 + // t.Text (string) (string) 4490 + if len("text") > 1000000 { 4491 + return xerrors.Errorf("Value in field \"text\" was too long") 4492 + } 4493 + 4494 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("text"))); err != nil { 4495 + return err 4496 + } 4497 + if _, err := cw.WriteString(string("text")); err != nil { 4498 + return err 4499 + } 4500 + 4501 + if len(t.Text) > 1000000 { 4502 + return xerrors.Errorf("Value in field t.Text was too long") 4503 + } 4504 + 4505 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Text))); err != nil { 4506 + return err 4507 + } 4508 + if _, err := cw.WriteString(string(t.Text)); err != nil { 4509 + return err 4510 + } 4511 + 4512 + // t.LexiconTypeID (string) (string) 4513 + if len("$type") > 1000000 { 4514 + return xerrors.Errorf("Value in field \"$type\" was too long") 4515 + } 4516 + 4517 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 4518 + return err 4519 + } 4520 + if _, err := cw.WriteString(string("$type")); err != nil { 4521 + return err 4522 + } 4523 + 4524 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.markup.markdown"))); err != nil { 4525 + return err 4526 + } 4527 + if _, err := cw.WriteString(string("sh.tangled.markup.markdown")); err != nil { 4528 + return err 4529 + } 4530 + 4531 + // t.Blobs ([]*util.LexBlob) (slice) 4532 + if t.Blobs != nil { 4533 + 4534 + if len("blobs") > 1000000 { 4535 + return xerrors.Errorf("Value in field \"blobs\" was too long") 4536 + } 4537 + 4538 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("blobs"))); err != nil { 4539 + return err 4540 + } 4541 + if _, err := cw.WriteString(string("blobs")); err != nil { 4542 + return err 4543 + } 4544 + 4545 + if len(t.Blobs) > 8192 { 4546 + return xerrors.Errorf("Slice value in field t.Blobs was too long") 4547 + } 4548 + 4549 + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Blobs))); err != nil { 4550 + return err 4551 + } 4552 + for _, v := range t.Blobs { 4553 + if err := v.MarshalCBOR(cw); err != nil { 4554 + return err 4555 + } 4556 + 4557 + } 4558 + } 4559 + 4560 + // t.Original (string) (string) 4561 + if t.Original != nil { 4562 + 4563 + if len("original") > 1000000 { 4564 + return xerrors.Errorf("Value in field \"original\" was too long") 4565 + } 4566 + 4567 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("original"))); err != nil { 4568 + return err 4569 + } 4570 + if _, err := cw.WriteString(string("original")); err != nil { 4571 + return err 4572 + } 4573 + 4574 + if t.Original == nil { 4575 + if _, err := cw.Write(cbg.CborNull); err != nil { 4576 + return err 4577 + } 4578 + } else { 4579 + if len(*t.Original) > 1000000 { 4580 + return xerrors.Errorf("Value in field t.Original was too long") 4581 + } 4582 + 4583 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Original))); err != nil { 4584 + return err 4585 + } 4586 + if _, err := cw.WriteString(string(*t.Original)); err != nil { 4587 + return err 4588 + } 4589 + } 4590 + } 4591 + return nil 4592 + } 4593 + 4594 + func (t *MarkupMarkdown) UnmarshalCBOR(r io.Reader) (err error) { 4595 + *t = MarkupMarkdown{} 4596 + 4597 + cr := cbg.NewCborReader(r) 4598 + 4599 + maj, extra, err := cr.ReadHeader() 4600 + if err != nil { 4601 + return err 4602 + } 4603 + defer func() { 4604 + if err == io.EOF { 4605 + err = io.ErrUnexpectedEOF 4606 + } 4607 + }() 4608 + 4609 + if maj != cbg.MajMap { 4610 + return fmt.Errorf("cbor input should be of type map") 4611 + } 4612 + 4613 + if extra > cbg.MaxLength { 4614 + return fmt.Errorf("MarkupMarkdown: map struct too large (%d)", extra) 4615 + } 4616 + 4617 + n := extra 4618 + 4619 + nameBuf := make([]byte, 8) 4620 + for i := uint64(0); i < n; i++ { 4621 + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 4622 + if err != nil { 4623 + return err 4624 + } 4625 + 4626 + if !ok { 4627 + // Field doesn't exist on this type, so ignore it 4628 + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 4629 + return err 4630 + } 4631 + continue 4632 + } 4633 + 4634 + switch string(nameBuf[:nameLen]) { 4635 + // t.Text (string) (string) 4636 + case "text": 4637 + 4638 + { 4639 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 4640 + if err != nil { 4641 + return err 4642 + } 4643 + 4644 + t.Text = string(sval) 4645 + } 4646 + // t.LexiconTypeID (string) (string) 4647 + case "$type": 4648 + 4649 + { 4650 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 4651 + if err != nil { 4652 + return err 4653 + } 4654 + 4655 + t.LexiconTypeID = string(sval) 4656 + } 4657 + // t.Blobs ([]*util.LexBlob) (slice) 4658 + case "blobs": 4659 + 4660 + maj, extra, err = cr.ReadHeader() 4661 + if err != nil { 4662 + return err 4663 + } 4664 + 4665 + if extra > 8192 { 4666 + return fmt.Errorf("t.Blobs: array too large (%d)", extra) 4667 + } 4668 + 4669 + if maj != cbg.MajArray { 4670 + return fmt.Errorf("expected cbor array") 4671 + } 4672 + 4673 + if extra > 0 { 4674 + t.Blobs = make([]*util.LexBlob, extra) 4675 + } 4676 + 4677 + for i := 0; i < int(extra); i++ { 4678 + { 4679 + var maj byte 4680 + var extra uint64 4681 + var err error 4682 + _ = maj 4683 + _ = extra 4684 + _ = err 4685 + 4686 + { 4687 + 4688 + b, err := cr.ReadByte() 4689 + if err != nil { 4690 + return err 4691 + } 4692 + if b != cbg.CborNull[0] { 4693 + if err := cr.UnreadByte(); err != nil { 4694 + return err 4695 + } 4696 + t.Blobs[i] = new(util.LexBlob) 4697 + if err := t.Blobs[i].UnmarshalCBOR(cr); err != nil { 4698 + return xerrors.Errorf("unmarshaling t.Blobs[i] pointer: %w", err) 4699 + } 4700 + } 4701 + 4702 + } 4703 + 4704 + } 4705 + } 4706 + // t.Original (string) (string) 4707 + case "original": 4708 + 4709 + { 4710 + b, err := cr.ReadByte() 4711 + if err != nil { 4712 + return err 4713 + } 4714 + if b != cbg.CborNull[0] { 4715 + if err := cr.UnreadByte(); err != nil { 4716 + return err 4717 + } 4718 + 4719 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 4720 + if err != nil { 4721 + return err 4722 + } 4723 + 4724 + t.Original = (*string)(&sval) 4725 + } 4553 4726 } 4554 4727 4555 4728 default:
+88
api/tangled/feedcomment.go
··· 1 + // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 + 3 + package tangled 4 + 5 + // schema: sh.tangled.feed.comment 6 + 7 + import ( 8 + "bytes" 9 + "encoding/json" 10 + "fmt" 11 + "io" 12 + 13 + comatprototypes "github.com/bluesky-social/indigo/api/atproto" 14 + "github.com/bluesky-social/indigo/lex/util" 15 + cbg "github.com/whyrusleeping/cbor-gen" 16 + ) 17 + 18 + const ( 19 + FeedCommentNSID = "sh.tangled.feed.comment" 20 + ) 21 + 22 + func init() { 23 + util.RegisterType("sh.tangled.feed.comment", &FeedComment{}) 24 + } // 25 + // RECORDTYPE: FeedComment 26 + type FeedComment struct { 27 + LexiconTypeID string `json:"$type,const=sh.tangled.feed.comment" cborgen:"$type,const=sh.tangled.feed.comment"` 28 + Body *FeedComment_Body `json:"body" cborgen:"body"` 29 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 30 + // pullRoundIdx: optional pull submission round index. required when subject is sh.tangled.repo.pull 31 + PullRoundIdx *int64 `json:"pullRoundIdx,omitempty" cborgen:"pullRoundIdx,omitempty"` 32 + ReplyTo *comatprototypes.RepoStrongRef `json:"replyTo,omitempty" cborgen:"replyTo,omitempty"` 33 + Subject *comatprototypes.RepoStrongRef `json:"subject" cborgen:"subject"` 34 + } 35 + 36 + type FeedComment_Body struct { 37 + MarkupMarkdown *MarkupMarkdown 38 + } 39 + 40 + func (t *FeedComment_Body) MarshalJSON() ([]byte, error) { 41 + if t.MarkupMarkdown != nil { 42 + t.MarkupMarkdown.LexiconTypeID = "sh.tangled.markup.markdown" 43 + return json.Marshal(t.MarkupMarkdown) 44 + } 45 + return nil, fmt.Errorf("cannot marshal empty enum") 46 + } 47 + func (t *FeedComment_Body) UnmarshalJSON(b []byte) error { 48 + typ, err := util.TypeExtract(b) 49 + if err != nil { 50 + return err 51 + } 52 + 53 + switch typ { 54 + case "sh.tangled.markup.markdown": 55 + t.MarkupMarkdown = new(MarkupMarkdown) 56 + return json.Unmarshal(b, t.MarkupMarkdown) 57 + 58 + default: 59 + return nil 60 + } 61 + } 62 + 63 + func (t *FeedComment_Body) MarshalCBOR(w io.Writer) error { 64 + 65 + if t == nil { 66 + _, err := w.Write(cbg.CborNull) 67 + return err 68 + } 69 + if t.MarkupMarkdown != nil { 70 + return t.MarkupMarkdown.MarshalCBOR(w) 71 + } 72 + return fmt.Errorf("cannot cbor marshal empty enum") 73 + } 74 + func (t *FeedComment_Body) UnmarshalCBOR(r io.Reader) error { 75 + typ, b, err := util.CborTypeExtractReader(r) 76 + if err != nil { 77 + return err 78 + } 79 + 80 + switch typ { 81 + case "sh.tangled.markup.markdown": 82 + t.MarkupMarkdown = new(MarkupMarkdown) 83 + return t.MarkupMarkdown.UnmarshalCBOR(bytes.NewReader(b)) 84 + 85 + default: 86 + return nil 87 + } 88 + }
+29
api/tangled/markupmarkdown.go
··· 1 + // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 + 3 + package tangled 4 + 5 + // schema: sh.tangled.markup.markdown 6 + 7 + import ( 8 + "github.com/bluesky-social/indigo/lex/util" 9 + ) 10 + 11 + const ( 12 + MarkupMarkdownNSID = "sh.tangled.markup.markdown" 13 + ) 14 + 15 + func init() { 16 + util.RegisterType("sh.tangled.markup.markdown#main", &MarkupMarkdown{}) 17 + } // MarkupMarkdown is a "main" in the sh.tangled.markup.markdown schema. 18 + // Tangled Flavored Markdown format text 19 + // 20 + // RECORDTYPE: MarkupMarkdown 21 + type MarkupMarkdown struct { 22 + LexiconTypeID string `json:"$type,const=sh.tangled.markup.markdown" cborgen:"$type,const=sh.tangled.markup.markdown"` 23 + // blobs: list of blobs referenced in markdown 24 + Blobs []*util.LexBlob `json:"blobs,omitempty" cborgen:"blobs,omitempty"` 25 + // original: Original Markdown before post-processing. Used to restore original input on edit. 26 + Original *string `json:"original,omitempty" cborgen:"original,omitempty"` 27 + // text: Final post-processed markdown content that will be rendered 28 + Text string `json:"text" cborgen:"text"` 29 + }
-27
api/tangled/tangledcomment.go
··· 1 - // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 - 3 - package tangled 4 - 5 - // schema: sh.tangled.comment 6 - 7 - import ( 8 - "github.com/bluesky-social/indigo/lex/util" 9 - ) 10 - 11 - const ( 12 - CommentNSID = "sh.tangled.comment" 13 - ) 14 - 15 - func init() { 16 - util.RegisterType("sh.tangled.comment", &Comment{}) 17 - } // 18 - // RECORDTYPE: Comment 19 - type Comment struct { 20 - LexiconTypeID string `json:"$type,const=sh.tangled.comment" cborgen:"$type,const=sh.tangled.comment"` 21 - Body string `json:"body" cborgen:"body"` 22 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 23 - Mentions []string `json:"mentions,omitempty" cborgen:"mentions,omitempty"` 24 - References []string `json:"references,omitempty" cborgen:"references,omitempty"` 25 - ReplyTo *string `json:"replyTo,omitempty" cborgen:"replyTo,omitempty"` 26 - Subject string `json:"subject" cborgen:"subject"` 27 - }
+2 -1
cmd/cborgen/cborgen.go
··· 15 15 "api/tangled/cbor_gen.go", 16 16 "tangled", 17 17 tangled.ActorProfile{}, 18 - tangled.Comment{}, 18 + tangled.FeedComment{}, 19 19 tangled.FeedReaction{}, 20 20 tangled.FeedStar{}, 21 21 tangled.GitRefUpdate{}, ··· 32 32 tangled.LabelDefinition_ValueType{}, 33 33 tangled.LabelOp{}, 34 34 tangled.LabelOp_Operand{}, 35 + tangled.MarkupMarkdown{}, 35 36 tangled.Pipeline{}, 36 37 tangled.Pipeline_CloneOpts{}, 37 38 tangled.Pipeline_ManualTriggerData{},
+6
lexicon-build-config.json
··· 1 1 [ 2 2 { 3 + "package": "atproto", 4 + "prefix": "com.atproto", 5 + "outdir": "/tmp/atproto", 6 + "import": "github.com/bluesky-social/indigo/api/atproto" 7 + }, 8 + { 3 9 "package": "tangled", 4 10 "prefix": "sh.tangled", 5 11 "outdir": "api/tangled",
+15
lexicons/com/atproto/repo/strongRef.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "com.atproto.repo.strongRef", 4 + "description": "A URI with a content-hash fingerprint.", 5 + "defs": { 6 + "main": { 7 + "type": "object", 8 + "required": ["uri", "cid"], 9 + "properties": { 10 + "uri": { "type": "string", "format": "at-uri" }, 11 + "cid": { "type": "string", "format": "cid" } 12 + } 13 + } 14 + } 15 + }
-51
lexicons/comment/comment.json
··· 1 - { 2 - "lexicon": 1, 3 - "id": "sh.tangled.comment", 4 - "needsCbor": true, 5 - "needsType": true, 6 - "defs": { 7 - "main": { 8 - "type": "record", 9 - "key": "tid", 10 - "record": { 11 - "type": "object", 12 - "required": [ 13 - "subject", 14 - "body", 15 - "createdAt" 16 - ], 17 - "properties": { 18 - "subject": { 19 - "type": "string", 20 - "format": "at-uri" 21 - }, 22 - "body": { 23 - "type": "string" 24 - }, 25 - "createdAt": { 26 - "type": "string", 27 - "format": "datetime" 28 - }, 29 - "replyTo": { 30 - "type": "string", 31 - "format": "at-uri" 32 - }, 33 - "mentions": { 34 - "type": "array", 35 - "items": { 36 - "type": "string", 37 - "format": "did" 38 - } 39 - }, 40 - "references": { 41 - "type": "array", 42 - "items": { 43 - "type": "string", 44 - "format": "at-uri" 45 - } 46 - } 47 - } 48 - } 49 - } 50 - } 51 - }
+43
lexicons/feed/comment.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "sh.tangled.feed.comment", 4 + "needsCbor": true, 5 + "needsType": true, 6 + "defs": { 7 + "main": { 8 + "type": "record", 9 + "key": "tid", 10 + "record": { 11 + "type": "object", 12 + "required": [ 13 + "subject", 14 + "body", 15 + "createdAt" 16 + ], 17 + "properties": { 18 + "subject": { 19 + "type": "ref", 20 + "ref": "com.atproto.repo.strongRef" 21 + }, 22 + "body": { 23 + "type": "union", 24 + "refs": ["sh.tangled.markup.markdown"] 25 + }, 26 + "createdAt": { 27 + "type": "string", 28 + "format": "datetime" 29 + }, 30 + "replyTo": { 31 + "type": "ref", 32 + "ref": "com.atproto.repo.strongRef" 33 + }, 34 + "pullRoundIdx": { 35 + "type": "integer", 36 + "minimum": 0, 37 + "description": "optional pull submission round index. required when subject is sh.tangled.repo.pull" 38 + } 39 + } 40 + } 41 + } 42 + } 43 + }
+30
lexicons/markup/markdown.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "sh.tangled.markup.markdown", 4 + "defs": { 5 + "main": { 6 + "type": "object", 7 + "required": ["text"], 8 + "description": "Tangled Flavored Markdown format text", 9 + "properties": { 10 + "text": { 11 + "type": "string", 12 + "description": "Final post-processed markdown content that will be rendered" 13 + }, 14 + "original": { 15 + "type": "string", 16 + "description": "Original Markdown before post-processing. Used to restore original input on edit." 17 + }, 18 + "blobs": { 19 + "type": "array", 20 + "items": { 21 + "type": "blob", 22 + "accept": ["image/*"], 23 + "maxSize": 1000000 24 + }, 25 + "description": "list of blobs referenced in markdown" 26 + } 27 + } 28 + } 29 + } 30 + }