this repo has no description
0
fork

Configure Feed

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

lex: fix LexBlob marshaling

+7 -7
+7 -7
lex/util/lex_types.go
··· 140 140 // refactor) blob. size=-1 indicates that this is (and should be serialized as) 141 141 // a legacy blob (string CID, no size, etc). 142 142 type LexBlob struct { 143 - Ref LexLink `json:"ref" cborgen:"ref"` 144 - MimeType string `json:"mimeType" cborgen:"mimeType"` 145 - Size int64 `json:"size" cborgen:"size"` 143 + Ref LexLink 144 + MimeType string 145 + Size int64 146 146 } 147 147 148 148 type LegacyBlob struct { ··· 151 151 } 152 152 153 153 type BlobSchema struct { 154 - LexiconTypeID string `json:"$type,omitempty" cborgen:"$type"` 154 + LexiconTypeID string `json:"$type,const=blob" cborgen:"$type,const=blob"` 155 155 Ref LexLink `json:"ref" cborgen:"ref"` 156 156 MimeType string `json:"mimeType" cborgen:"mimeType"` 157 157 Size int64 `json:"size" cborgen:"size"` 158 158 } 159 159 160 - func (b *LexBlob) MarshalJSON() ([]byte, error) { 160 + func (b LexBlob) MarshalJSON() ([]byte, error) { 161 161 if b.Size < 0 { 162 162 lb := LegacyBlob{ 163 163 Cid: b.Ref.String(), ··· 194 194 return xerrors.Errorf("parsing blob: negative size: %d", bs.Size) 195 195 } 196 196 } else { 197 - var legacy *LegacyBlob 198 - err := json.Unmarshal(raw, legacy) 197 + var legacy LegacyBlob 198 + err := json.Unmarshal(raw, &legacy) 199 199 if err != nil { 200 200 return xerrors.Errorf("parsing legacy blob: %v", err) 201 201 }