Signed-off-by: Seongmin Lee git@boltless.me
+416
api/tangled/cbor_gen.go
+416
api/tangled/cbor_gen.go
···
604
604
605
605
return nil
606
606
}
607
+
func (t *Comment) MarshalCBOR(w io.Writer) error {
608
+
if t == nil {
609
+
_, err := w.Write(cbg.CborNull)
610
+
return err
611
+
}
612
+
613
+
cw := cbg.NewCborWriter(w)
614
+
fieldCount := 7
615
+
616
+
if t.Mentions == nil {
617
+
fieldCount--
618
+
}
619
+
620
+
if t.References == nil {
621
+
fieldCount--
622
+
}
623
+
624
+
if t.ReplyTo == nil {
625
+
fieldCount--
626
+
}
627
+
628
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
629
+
return err
630
+
}
631
+
632
+
// t.Body (string) (string)
633
+
if len("body") > 1000000 {
634
+
return xerrors.Errorf("Value in field \"body\" was too long")
635
+
}
636
+
637
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil {
638
+
return err
639
+
}
640
+
if _, err := cw.WriteString(string("body")); err != nil {
641
+
return err
642
+
}
643
+
644
+
if len(t.Body) > 1000000 {
645
+
return xerrors.Errorf("Value in field t.Body was too long")
646
+
}
647
+
648
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Body))); err != nil {
649
+
return err
650
+
}
651
+
if _, err := cw.WriteString(string(t.Body)); err != nil {
652
+
return err
653
+
}
654
+
655
+
// t.LexiconTypeID (string) (string)
656
+
if len("$type") > 1000000 {
657
+
return xerrors.Errorf("Value in field \"$type\" was too long")
658
+
}
659
+
660
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
661
+
return err
662
+
}
663
+
if _, err := cw.WriteString(string("$type")); err != nil {
664
+
return err
665
+
}
666
+
667
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.comment"))); err != nil {
668
+
return err
669
+
}
670
+
if _, err := cw.WriteString(string("sh.tangled.comment")); err != nil {
671
+
return err
672
+
}
673
+
674
+
// t.ReplyTo (string) (string)
675
+
if t.ReplyTo != nil {
676
+
677
+
if len("replyTo") > 1000000 {
678
+
return xerrors.Errorf("Value in field \"replyTo\" was too long")
679
+
}
680
+
681
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("replyTo"))); err != nil {
682
+
return err
683
+
}
684
+
if _, err := cw.WriteString(string("replyTo")); err != nil {
685
+
return err
686
+
}
687
+
688
+
if t.ReplyTo == nil {
689
+
if _, err := cw.Write(cbg.CborNull); err != nil {
690
+
return err
691
+
}
692
+
} else {
693
+
if len(*t.ReplyTo) > 1000000 {
694
+
return xerrors.Errorf("Value in field t.ReplyTo was too long")
695
+
}
696
+
697
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.ReplyTo))); err != nil {
698
+
return err
699
+
}
700
+
if _, err := cw.WriteString(string(*t.ReplyTo)); err != nil {
701
+
return err
702
+
}
703
+
}
704
+
}
705
+
706
+
// t.Subject (string) (string)
707
+
if len("subject") > 1000000 {
708
+
return xerrors.Errorf("Value in field \"subject\" was too long")
709
+
}
710
+
711
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil {
712
+
return err
713
+
}
714
+
if _, err := cw.WriteString(string("subject")); err != nil {
715
+
return err
716
+
}
717
+
718
+
if len(t.Subject) > 1000000 {
719
+
return xerrors.Errorf("Value in field t.Subject was too long")
720
+
}
721
+
722
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Subject))); err != nil {
723
+
return err
724
+
}
725
+
if _, err := cw.WriteString(string(t.Subject)); err != nil {
726
+
return err
727
+
}
728
+
729
+
// t.Mentions ([]string) (slice)
730
+
if t.Mentions != nil {
731
+
732
+
if len("mentions") > 1000000 {
733
+
return xerrors.Errorf("Value in field \"mentions\" was too long")
734
+
}
735
+
736
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("mentions"))); err != nil {
737
+
return err
738
+
}
739
+
if _, err := cw.WriteString(string("mentions")); err != nil {
740
+
return err
741
+
}
742
+
743
+
if len(t.Mentions) > 8192 {
744
+
return xerrors.Errorf("Slice value in field t.Mentions was too long")
745
+
}
746
+
747
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Mentions))); err != nil {
748
+
return err
749
+
}
750
+
for _, v := range t.Mentions {
751
+
if len(v) > 1000000 {
752
+
return xerrors.Errorf("Value in field v was too long")
753
+
}
754
+
755
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
756
+
return err
757
+
}
758
+
if _, err := cw.WriteString(string(v)); err != nil {
759
+
return err
760
+
}
761
+
762
+
}
763
+
}
764
+
765
+
// t.CreatedAt (string) (string)
766
+
if len("createdAt") > 1000000 {
767
+
return xerrors.Errorf("Value in field \"createdAt\" was too long")
768
+
}
769
+
770
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
771
+
return err
772
+
}
773
+
if _, err := cw.WriteString(string("createdAt")); err != nil {
774
+
return err
775
+
}
776
+
777
+
if len(t.CreatedAt) > 1000000 {
778
+
return xerrors.Errorf("Value in field t.CreatedAt was too long")
779
+
}
780
+
781
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
782
+
return err
783
+
}
784
+
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
785
+
return err
786
+
}
787
+
788
+
// t.References ([]string) (slice)
789
+
if t.References != nil {
790
+
791
+
if len("references") > 1000000 {
792
+
return xerrors.Errorf("Value in field \"references\" was too long")
793
+
}
794
+
795
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("references"))); err != nil {
796
+
return err
797
+
}
798
+
if _, err := cw.WriteString(string("references")); err != nil {
799
+
return err
800
+
}
801
+
802
+
if len(t.References) > 8192 {
803
+
return xerrors.Errorf("Slice value in field t.References was too long")
804
+
}
805
+
806
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.References))); err != nil {
807
+
return err
808
+
}
809
+
for _, v := range t.References {
810
+
if len(v) > 1000000 {
811
+
return xerrors.Errorf("Value in field v was too long")
812
+
}
813
+
814
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
815
+
return err
816
+
}
817
+
if _, err := cw.WriteString(string(v)); err != nil {
818
+
return err
819
+
}
820
+
821
+
}
822
+
}
823
+
return nil
824
+
}
825
+
826
+
func (t *Comment) UnmarshalCBOR(r io.Reader) (err error) {
827
+
*t = Comment{}
828
+
829
+
cr := cbg.NewCborReader(r)
830
+
831
+
maj, extra, err := cr.ReadHeader()
832
+
if err != nil {
833
+
return err
834
+
}
835
+
defer func() {
836
+
if err == io.EOF {
837
+
err = io.ErrUnexpectedEOF
838
+
}
839
+
}()
840
+
841
+
if maj != cbg.MajMap {
842
+
return fmt.Errorf("cbor input should be of type map")
843
+
}
844
+
845
+
if extra > cbg.MaxLength {
846
+
return fmt.Errorf("Comment: map struct too large (%d)", extra)
847
+
}
848
+
849
+
n := extra
850
+
851
+
nameBuf := make([]byte, 10)
852
+
for i := uint64(0); i < n; i++ {
853
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
854
+
if err != nil {
855
+
return err
856
+
}
857
+
858
+
if !ok {
859
+
// Field doesn't exist on this type, so ignore it
860
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
861
+
return err
862
+
}
863
+
continue
864
+
}
865
+
866
+
switch string(nameBuf[:nameLen]) {
867
+
// t.Body (string) (string)
868
+
case "body":
869
+
870
+
{
871
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
872
+
if err != nil {
873
+
return err
874
+
}
875
+
876
+
t.Body = string(sval)
877
+
}
878
+
// t.LexiconTypeID (string) (string)
879
+
case "$type":
880
+
881
+
{
882
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
883
+
if err != nil {
884
+
return err
885
+
}
886
+
887
+
t.LexiconTypeID = string(sval)
888
+
}
889
+
// t.ReplyTo (string) (string)
890
+
case "replyTo":
891
+
892
+
{
893
+
b, err := cr.ReadByte()
894
+
if err != nil {
895
+
return err
896
+
}
897
+
if b != cbg.CborNull[0] {
898
+
if err := cr.UnreadByte(); err != nil {
899
+
return err
900
+
}
901
+
902
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
903
+
if err != nil {
904
+
return err
905
+
}
906
+
907
+
t.ReplyTo = (*string)(&sval)
908
+
}
909
+
}
910
+
// t.Subject (string) (string)
911
+
case "subject":
912
+
913
+
{
914
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
915
+
if err != nil {
916
+
return err
917
+
}
918
+
919
+
t.Subject = string(sval)
920
+
}
921
+
// t.Mentions ([]string) (slice)
922
+
case "mentions":
923
+
924
+
maj, extra, err = cr.ReadHeader()
925
+
if err != nil {
926
+
return err
927
+
}
928
+
929
+
if extra > 8192 {
930
+
return fmt.Errorf("t.Mentions: array too large (%d)", extra)
931
+
}
932
+
933
+
if maj != cbg.MajArray {
934
+
return fmt.Errorf("expected cbor array")
935
+
}
936
+
937
+
if extra > 0 {
938
+
t.Mentions = make([]string, extra)
939
+
}
940
+
941
+
for i := 0; i < int(extra); i++ {
942
+
{
943
+
var maj byte
944
+
var extra uint64
945
+
var err error
946
+
_ = maj
947
+
_ = extra
948
+
_ = err
949
+
950
+
{
951
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
952
+
if err != nil {
953
+
return err
954
+
}
955
+
956
+
t.Mentions[i] = string(sval)
957
+
}
958
+
959
+
}
960
+
}
961
+
// t.CreatedAt (string) (string)
962
+
case "createdAt":
963
+
964
+
{
965
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
966
+
if err != nil {
967
+
return err
968
+
}
969
+
970
+
t.CreatedAt = string(sval)
971
+
}
972
+
// t.References ([]string) (slice)
973
+
case "references":
974
+
975
+
maj, extra, err = cr.ReadHeader()
976
+
if err != nil {
977
+
return err
978
+
}
979
+
980
+
if extra > 8192 {
981
+
return fmt.Errorf("t.References: array too large (%d)", extra)
982
+
}
983
+
984
+
if maj != cbg.MajArray {
985
+
return fmt.Errorf("expected cbor array")
986
+
}
987
+
988
+
if extra > 0 {
989
+
t.References = make([]string, extra)
990
+
}
991
+
992
+
for i := 0; i < int(extra); i++ {
993
+
{
994
+
var maj byte
995
+
var extra uint64
996
+
var err error
997
+
_ = maj
998
+
_ = extra
999
+
_ = err
1000
+
1001
+
{
1002
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
1003
+
if err != nil {
1004
+
return err
1005
+
}
1006
+
1007
+
t.References[i] = string(sval)
1008
+
}
1009
+
1010
+
}
1011
+
}
1012
+
1013
+
default:
1014
+
// Field doesn't exist on this type, so ignore it
1015
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
1016
+
return err
1017
+
}
1018
+
}
1019
+
}
1020
+
1021
+
return nil
1022
+
}
607
1023
func (t *FeedReaction) MarshalCBOR(w io.Writer) error {
608
1024
if t == nil {
609
1025
_, err := w.Write(cbg.CborNull)
+27
api/tangled/tangledcomment.go
+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
+
}
+1
cmd/cborgen/cborgen.go
+1
cmd/cborgen/cborgen.go
+51
lexicons/comment/comment.json
+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
+
}
History
8 rounds
0 comments
boltless.me
submitted
#7
1 commit
expand
collapse
lexicons: add general
sh.tangled.comment lexicon
Signed-off-by: Seongmin Lee <git@boltless.me>
2/3 timeout, 1/3 success
expand
collapse
no conflicts, ready to merge
expand 0 comments
boltless.me
submitted
#6
1 commit
expand
collapse
lexicons: add general
sh.tangled.comment lexicon
Signed-off-by: Seongmin Lee <git@boltless.me>
2/3 failed, 1/3 success
expand
collapse
expand 0 comments
boltless.me
submitted
#5
1 commit
expand
collapse
lexicons: add general
sh.tangled.comment lexicon
Signed-off-by: Seongmin Lee <git@boltless.me>
3/3 success
expand
collapse
expand 0 comments
boltless.me
submitted
#4
1 commit
expand
collapse
lexicons: add general
sh.tangled.comment lexicon
Signed-off-by: Seongmin Lee <git@boltless.me>
3/3 success
expand
collapse
expand 0 comments
boltless.me
submitted
#3
1 commit
expand
collapse
lexicons: add general
sh.tangled.comment lexicon
Signed-off-by: Seongmin Lee <git@boltless.me>
3/3 success
expand
collapse
expand 0 comments
boltless.me
submitted
#2
1 commit
expand
collapse
lexicons: add general
sh.tangled.comment lexicon
Signed-off-by: Seongmin Lee <git@boltless.me>
3/3 success
expand
collapse
expand 0 comments
boltless.me
submitted
#1
1 commit
expand
collapse
lexicons: add general
sh.tangled.comment lexicon
Signed-off-by: Seongmin Lee <git@boltless.me>
3/3 success
expand
collapse
expand 0 comments
boltless.me
submitted
#0
1 commit
expand
collapse
lexicons: add general
sh.tangled.comment lexicon
Signed-off-by: Seongmin Lee <git@boltless.me>