lexicons,api: add avatar field to profile lexicon #890

open
opened by anirudh.fi targeting master from icy/tolqpt
Changed files
+53 -4
api
lexicons
actor
+2
api/tangled/actorprofile.go
··· 18 18 // RECORDTYPE: ActorProfile 19 19 type ActorProfile struct { 20 20 LexiconTypeID string `json:"$type,const=sh.tangled.actor.profile" cborgen:"$type,const=sh.tangled.actor.profile"` 21 + // avatar: Small image to be displayed next to posts from account. AKA, 'profile picture' 22 + Avatar *util.LexBlob `json:"avatar,omitempty" cborgen:"avatar,omitempty"` 21 23 // bluesky: Include link to this account on Bluesky. 22 24 Bluesky bool `json:"bluesky" cborgen:"bluesky"` 23 25 // description: Free-form profile description text.
+44 -1
api/tangled/cbor_gen.go
··· 26 26 } 27 27 28 28 cw := cbg.NewCborWriter(w) 29 - fieldCount := 8 29 + fieldCount := 9 30 + 31 + if t.Avatar == nil { 32 + fieldCount-- 33 + } 30 34 31 35 if t.Description == nil { 32 36 fieldCount-- ··· 147 151 } 148 152 } 149 153 154 + // t.Avatar (util.LexBlob) (struct) 155 + if t.Avatar != nil { 156 + 157 + if len("avatar") > 1000000 { 158 + return xerrors.Errorf("Value in field \"avatar\" was too long") 159 + } 160 + 161 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("avatar"))); err != nil { 162 + return err 163 + } 164 + if _, err := cw.WriteString(string("avatar")); err != nil { 165 + return err 166 + } 167 + 168 + if err := t.Avatar.MarshalCBOR(cw); err != nil { 169 + return err 170 + } 171 + } 172 + 150 173 // t.Bluesky (bool) (bool) 151 174 if len("bluesky") > 1000000 { 152 175 return xerrors.Errorf("Value in field \"bluesky\" was too long") ··· 429 452 430 453 } 431 454 } 455 + // t.Avatar (util.LexBlob) (struct) 456 + case "avatar": 457 + 458 + { 459 + 460 + b, err := cr.ReadByte() 461 + if err != nil { 462 + return err 463 + } 464 + if b != cbg.CborNull[0] { 465 + if err := cr.UnreadByte(); err != nil { 466 + return err 467 + } 468 + t.Avatar = new(util.LexBlob) 469 + if err := t.Avatar.UnmarshalCBOR(cr); err != nil { 470 + return xerrors.Errorf("unmarshaling t.Avatar pointer: %w", err) 471 + } 472 + } 473 + 474 + } 432 475 // t.Bluesky (bool) (bool) 433 476 case "bluesky": 434 477
+7 -3
lexicons/actor/profile.json
··· 8 8 "key": "literal:self", 9 9 "record": { 10 10 "type": "object", 11 - "required": [ 12 - "bluesky" 13 - ], 11 + "required": ["bluesky"], 14 12 "properties": { 13 + "avatar": { 14 + "type": "blob", 15 + "description": "Small image to be displayed next to posts from account. AKA, 'profile picture'", 16 + "accept": ["image/png", "image/jpeg"], 17 + "maxSize": 1000000 18 + }, 15 19 "description": { 16 20 "type": "string", 17 21 "description": "Free-form profile description text.",