Monorepo for Tangled
0
fork

Configure Feed

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

lexicons: add vouch lexicon

Signed-off-by: oppiliappan <me@oppi.li>

+308 -1
+245
api/tangled/cbor_gen.go
··· 10810 10810 10811 10811 return nil 10812 10812 } 10813 + func (t *GraphVouch) MarshalCBOR(w io.Writer) error { 10814 + if t == nil { 10815 + _, err := w.Write(cbg.CborNull) 10816 + return err 10817 + } 10818 + 10819 + cw := cbg.NewCborWriter(w) 10820 + fieldCount := 4 10821 + 10822 + if t.Kind == nil { 10823 + fieldCount-- 10824 + } 10825 + 10826 + if t.Reason == nil { 10827 + fieldCount-- 10828 + } 10829 + 10830 + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 10831 + return err 10832 + } 10833 + 10834 + // t.Kind (string) (string) 10835 + if t.Kind != nil { 10836 + 10837 + if len("kind") > 1000000 { 10838 + return xerrors.Errorf("Value in field \"kind\" was too long") 10839 + } 10840 + 10841 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("kind"))); err != nil { 10842 + return err 10843 + } 10844 + if _, err := cw.WriteString(string("kind")); err != nil { 10845 + return err 10846 + } 10847 + 10848 + if t.Kind == nil { 10849 + if _, err := cw.Write(cbg.CborNull); err != nil { 10850 + return err 10851 + } 10852 + } else { 10853 + if len(*t.Kind) > 1000000 { 10854 + return xerrors.Errorf("Value in field t.Kind was too long") 10855 + } 10856 + 10857 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Kind))); err != nil { 10858 + return err 10859 + } 10860 + if _, err := cw.WriteString(string(*t.Kind)); err != nil { 10861 + return err 10862 + } 10863 + } 10864 + } 10865 + 10866 + // t.LexiconTypeID (string) (string) 10867 + if len("$type") > 1000000 { 10868 + return xerrors.Errorf("Value in field \"$type\" was too long") 10869 + } 10870 + 10871 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 10872 + return err 10873 + } 10874 + if _, err := cw.WriteString(string("$type")); err != nil { 10875 + return err 10876 + } 10877 + 10878 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.graph.vouch"))); err != nil { 10879 + return err 10880 + } 10881 + if _, err := cw.WriteString(string("sh.tangled.graph.vouch")); err != nil { 10882 + return err 10883 + } 10884 + 10885 + // t.Reason (string) (string) 10886 + if t.Reason != nil { 10887 + 10888 + if len("reason") > 1000000 { 10889 + return xerrors.Errorf("Value in field \"reason\" was too long") 10890 + } 10891 + 10892 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("reason"))); err != nil { 10893 + return err 10894 + } 10895 + if _, err := cw.WriteString(string("reason")); err != nil { 10896 + return err 10897 + } 10898 + 10899 + if t.Reason == nil { 10900 + if _, err := cw.Write(cbg.CborNull); err != nil { 10901 + return err 10902 + } 10903 + } else { 10904 + if len(*t.Reason) > 1000000 { 10905 + return xerrors.Errorf("Value in field t.Reason was too long") 10906 + } 10907 + 10908 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Reason))); err != nil { 10909 + return err 10910 + } 10911 + if _, err := cw.WriteString(string(*t.Reason)); err != nil { 10912 + return err 10913 + } 10914 + } 10915 + } 10916 + 10917 + // t.CreatedAt (string) (string) 10918 + if len("createdAt") > 1000000 { 10919 + return xerrors.Errorf("Value in field \"createdAt\" was too long") 10920 + } 10921 + 10922 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 10923 + return err 10924 + } 10925 + if _, err := cw.WriteString(string("createdAt")); err != nil { 10926 + return err 10927 + } 10928 + 10929 + if len(t.CreatedAt) > 1000000 { 10930 + return xerrors.Errorf("Value in field t.CreatedAt was too long") 10931 + } 10932 + 10933 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { 10934 + return err 10935 + } 10936 + if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { 10937 + return err 10938 + } 10939 + return nil 10940 + } 10941 + 10942 + func (t *GraphVouch) UnmarshalCBOR(r io.Reader) (err error) { 10943 + *t = GraphVouch{} 10944 + 10945 + cr := cbg.NewCborReader(r) 10946 + 10947 + maj, extra, err := cr.ReadHeader() 10948 + if err != nil { 10949 + return err 10950 + } 10951 + defer func() { 10952 + if err == io.EOF { 10953 + err = io.ErrUnexpectedEOF 10954 + } 10955 + }() 10956 + 10957 + if maj != cbg.MajMap { 10958 + return fmt.Errorf("cbor input should be of type map") 10959 + } 10960 + 10961 + if extra > cbg.MaxLength { 10962 + return fmt.Errorf("GraphVouch: map struct too large (%d)", extra) 10963 + } 10964 + 10965 + n := extra 10966 + 10967 + nameBuf := make([]byte, 9) 10968 + for i := uint64(0); i < n; i++ { 10969 + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 10970 + if err != nil { 10971 + return err 10972 + } 10973 + 10974 + if !ok { 10975 + // Field doesn't exist on this type, so ignore it 10976 + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 10977 + return err 10978 + } 10979 + continue 10980 + } 10981 + 10982 + switch string(nameBuf[:nameLen]) { 10983 + // t.Kind (string) (string) 10984 + case "kind": 10985 + 10986 + { 10987 + b, err := cr.ReadByte() 10988 + if err != nil { 10989 + return err 10990 + } 10991 + if b != cbg.CborNull[0] { 10992 + if err := cr.UnreadByte(); err != nil { 10993 + return err 10994 + } 10995 + 10996 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 10997 + if err != nil { 10998 + return err 10999 + } 11000 + 11001 + t.Kind = (*string)(&sval) 11002 + } 11003 + } 11004 + // t.LexiconTypeID (string) (string) 11005 + case "$type": 11006 + 11007 + { 11008 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 11009 + if err != nil { 11010 + return err 11011 + } 11012 + 11013 + t.LexiconTypeID = string(sval) 11014 + } 11015 + // t.Reason (string) (string) 11016 + case "reason": 11017 + 11018 + { 11019 + b, err := cr.ReadByte() 11020 + if err != nil { 11021 + return err 11022 + } 11023 + if b != cbg.CborNull[0] { 11024 + if err := cr.UnreadByte(); err != nil { 11025 + return err 11026 + } 11027 + 11028 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 11029 + if err != nil { 11030 + return err 11031 + } 11032 + 11033 + t.Reason = (*string)(&sval) 11034 + } 11035 + } 11036 + // t.CreatedAt (string) (string) 11037 + case "createdAt": 11038 + 11039 + { 11040 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 11041 + if err != nil { 11042 + return err 11043 + } 11044 + 11045 + t.CreatedAt = string(sval) 11046 + } 11047 + 11048 + default: 11049 + // Field doesn't exist on this type, so ignore it 11050 + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 11051 + return err 11052 + } 11053 + } 11054 + } 11055 + 11056 + return nil 11057 + }
+26
api/tangled/graphvouch.go
··· 1 + // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 + 3 + package tangled 4 + 5 + // schema: sh.tangled.graph.vouch 6 + 7 + import ( 8 + "github.com/bluesky-social/indigo/lex/util" 9 + ) 10 + 11 + const ( 12 + GraphVouchNSID = "sh.tangled.graph.vouch" 13 + ) 14 + 15 + func init() { 16 + util.RegisterType("sh.tangled.graph.vouch", &GraphVouch{}) 17 + } // 18 + // RECORDTYPE: GraphVouch 19 + type GraphVouch struct { 20 + LexiconTypeID string `json:"$type,const=sh.tangled.graph.vouch" cborgen:"$type,const=sh.tangled.graph.vouch"` 21 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 22 + // kind: Whether this user is being vouched for or denounced 23 + Kind *string `json:"kind,omitempty" cborgen:"kind,omitempty"` 24 + // reason: The reason for this vouch/denouncement 25 + Reason *string `json:"reason,omitempty" cborgen:"reason,omitempty"` 26 + }
+2 -1
cmd/cborgen/cborgen.go
··· 24 24 tangled.GitRefUpdate_LangBreakdown{}, 25 25 tangled.GitRefUpdate_Meta{}, 26 26 tangled.GraphFollow{}, 27 + tangled.GraphVouch{}, 27 28 tangled.Knot{}, 28 29 tangled.KnotMember{}, 29 30 tangled.LabelDefinition{}, ··· 49 50 tangled.RepoIssueState{}, 50 51 tangled.RepoPull{}, 51 52 tangled.RepoPullComment{}, 52 - tangled.RepoPull_Source{}, 53 53 tangled.RepoPull_Round{}, 54 + tangled.RepoPull_Source{}, 54 55 tangled.RepoPullStatus{}, 55 56 tangled.RepoPull_Target{}, 56 57 tangled.Spindle{},
+35
lexicons/graph/vouch.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "sh.tangled.graph.vouch", 4 + "needsCbor": true, 5 + "needsType": true, 6 + "defs": { 7 + "main": { 8 + "type": "record", 9 + "key": "any", 10 + "record": { 11 + "type": "object", 12 + "required": [ 13 + "createdAt" 14 + ], 15 + "properties": { 16 + "kind": { 17 + "type": "string", 18 + "description": "Whether this user is being vouched for or denounced", 19 + "enum": ["vouch", "denounce"], 20 + "default": "vouch" 21 + }, 22 + "reason": { 23 + "type": "string", 24 + "description": "The reason for this vouch/denouncement" 25 + }, 26 + "createdAt": { 27 + "type": "string", 28 + "format": "datetime" 29 + } 30 + } 31 + } 32 + } 33 + } 34 + } 35 +