Signed-off-by: Seongmin Lee git@boltless.me
+495
Diff
round #9
+416
api/tangled/cbor_gen.go
+416
api/tangled/cbor_gen.go
···
661
661
662
662
return nil
663
663
}
664
+
func (t *Comment) MarshalCBOR(w io.Writer) error {
665
+
if t == nil {
666
+
_, err := w.Write(cbg.CborNull)
667
+
return err
668
+
}
669
+
670
+
cw := cbg.NewCborWriter(w)
671
+
fieldCount := 7
672
+
673
+
if t.Mentions == nil {
674
+
fieldCount--
675
+
}
676
+
677
+
if t.References == nil {
678
+
fieldCount--
679
+
}
680
+
681
+
if t.ReplyTo == nil {
682
+
fieldCount--
683
+
}
684
+
685
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
686
+
return err
687
+
}
688
+
689
+
// t.Body (string) (string)
690
+
if len("body") > 1000000 {
691
+
return xerrors.Errorf("Value in field \"body\" was too long")
692
+
}
693
+
694
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil {
695
+
return err
696
+
}
697
+
if _, err := cw.WriteString(string("body")); err != nil {
698
+
return err
699
+
}
700
+
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 {
709
+
return err
710
+
}
711
+
712
+
// t.LexiconTypeID (string) (string)
713
+
if len("$type") > 1000000 {
714
+
return xerrors.Errorf("Value in field \"$type\" was too long")
715
+
}
716
+
717
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
718
+
return err
719
+
}
720
+
if _, err := cw.WriteString(string("$type")); err != nil {
721
+
return err
722
+
}
723
+
724
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.comment"))); err != nil {
725
+
return err
726
+
}
727
+
if _, err := cw.WriteString(string("sh.tangled.comment")); err != nil {
728
+
return err
729
+
}
730
+
731
+
// t.ReplyTo (string) (string)
732
+
if t.ReplyTo != nil {
733
+
734
+
if len("replyTo") > 1000000 {
735
+
return xerrors.Errorf("Value in field \"replyTo\" was too long")
736
+
}
737
+
738
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("replyTo"))); err != nil {
739
+
return err
740
+
}
741
+
if _, err := cw.WriteString(string("replyTo")); err != nil {
742
+
return err
743
+
}
744
+
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
+
}
760
+
}
761
+
}
762
+
763
+
// t.Subject (string) (string)
764
+
if len("subject") > 1000000 {
765
+
return xerrors.Errorf("Value in field \"subject\" was too long")
766
+
}
767
+
768
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil {
769
+
return err
770
+
}
771
+
if _, err := cw.WriteString(string("subject")); err != nil {
772
+
return err
773
+
}
774
+
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 {
783
+
return err
784
+
}
785
+
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
+
// t.CreatedAt (string) (string)
823
+
if len("createdAt") > 1000000 {
824
+
return xerrors.Errorf("Value in field \"createdAt\" was too long")
825
+
}
826
+
827
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
828
+
return err
829
+
}
830
+
if _, err := cw.WriteString(string("createdAt")); err != nil {
831
+
return err
832
+
}
833
+
834
+
if len(t.CreatedAt) > 1000000 {
835
+
return xerrors.Errorf("Value in field t.CreatedAt was too long")
836
+
}
837
+
838
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
839
+
return err
840
+
}
841
+
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
842
+
return err
843
+
}
844
+
845
+
// t.References ([]string) (slice)
846
+
if t.References != nil {
847
+
848
+
if len("references") > 1000000 {
849
+
return xerrors.Errorf("Value in field \"references\" was too long")
850
+
}
851
+
852
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("references"))); err != nil {
853
+
return err
854
+
}
855
+
if _, err := cw.WriteString(string("references")); err != nil {
856
+
return err
857
+
}
858
+
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 {
872
+
return err
873
+
}
874
+
if _, err := cw.WriteString(string(v)); err != nil {
875
+
return err
876
+
}
877
+
878
+
}
879
+
}
880
+
return nil
881
+
}
882
+
883
+
func (t *Comment) UnmarshalCBOR(r io.Reader) (err error) {
884
+
*t = Comment{}
885
+
886
+
cr := cbg.NewCborReader(r)
887
+
888
+
maj, extra, err := cr.ReadHeader()
889
+
if err != nil {
890
+
return err
891
+
}
892
+
defer func() {
893
+
if err == io.EOF {
894
+
err = io.ErrUnexpectedEOF
895
+
}
896
+
}()
897
+
898
+
if maj != cbg.MajMap {
899
+
return fmt.Errorf("cbor input should be of type map")
900
+
}
901
+
902
+
if extra > cbg.MaxLength {
903
+
return fmt.Errorf("Comment: map struct too large (%d)", extra)
904
+
}
905
+
906
+
n := extra
907
+
908
+
nameBuf := make([]byte, 10)
909
+
for i := uint64(0); i < n; i++ {
910
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
911
+
if err != nil {
912
+
return err
913
+
}
914
+
915
+
if !ok {
916
+
// Field doesn't exist on this type, so ignore it
917
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
918
+
return err
919
+
}
920
+
continue
921
+
}
922
+
923
+
switch string(nameBuf[:nameLen]) {
924
+
// t.Body (string) (string)
925
+
case "body":
926
+
927
+
{
928
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
929
+
if err != nil {
930
+
return err
931
+
}
932
+
933
+
t.Body = string(sval)
934
+
}
935
+
// t.LexiconTypeID (string) (string)
936
+
case "$type":
937
+
938
+
{
939
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
940
+
if err != nil {
941
+
return err
942
+
}
943
+
944
+
t.LexiconTypeID = string(sval)
945
+
}
946
+
// t.ReplyTo (string) (string)
947
+
case "replyTo":
948
+
949
+
{
950
+
b, err := cr.ReadByte()
951
+
if err != nil {
952
+
return err
953
+
}
954
+
if b != cbg.CborNull[0] {
955
+
if err := cr.UnreadByte(); err != nil {
956
+
return err
957
+
}
958
+
959
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
960
+
if err != nil {
961
+
return err
962
+
}
963
+
964
+
t.ReplyTo = (*string)(&sval)
965
+
}
966
+
}
967
+
// t.Subject (string) (string)
968
+
case "subject":
969
+
970
+
{
971
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
972
+
if err != nil {
973
+
return err
974
+
}
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)
1014
+
}
1015
+
1016
+
}
1017
+
}
1018
+
// t.CreatedAt (string) (string)
1019
+
case "createdAt":
1020
+
1021
+
{
1022
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
1023
+
if err != nil {
1024
+
return err
1025
+
}
1026
+
1027
+
t.CreatedAt = string(sval)
1028
+
}
1029
+
// t.References ([]string) (slice)
1030
+
case "references":
1031
+
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
1062
+
}
1063
+
1064
+
t.References[i] = string(sval)
1065
+
}
1066
+
1067
+
}
1068
+
}
1069
+
1070
+
default:
1071
+
// Field doesn't exist on this type, so ignore it
1072
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
1073
+
return err
1074
+
}
1075
+
}
1076
+
}
1077
+
1078
+
return nil
1079
+
}
664
1080
func (t *FeedReaction) MarshalCBOR(w io.Writer) error {
665
1081
if t == nil {
666
1082
_, 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
10 rounds
0 comments
boltless.me
submitted
#9
1 commit
expand
collapse
lexicons: add general
sh.tangled.comment lexicon
Signed-off-by: Seongmin Lee <git@boltless.me>
3/3 failed
expand
collapse
no conflicts, ready to merge
expand 0 comments
boltless.me
submitted
#8
1 commit
expand
collapse
lexicons: add general
sh.tangled.comment lexicon
Signed-off-by: Seongmin Lee <git@boltless.me>
3/3 failed
expand
collapse
expand 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>
3/3 failed
expand
collapse
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>
3/3 failed
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 failed
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 failed
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 failed
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 failed
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 failed
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>