forked from tangled.org/core
Monorepo for Tangled

lexicons,api: add avatar field to profile lexicon

Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>

anirudh.fi 85d99a93 a53d124e

verified
Changed files
+53 -4
api
lexicons
actor
+2
api/tangled/actorprofile.go
··· 18 // RECORDTYPE: ActorProfile 19 type ActorProfile struct { 20 LexiconTypeID string `json:"$type,const=sh.tangled.actor.profile" cborgen:"$type,const=sh.tangled.actor.profile"` 21 // bluesky: Include link to this account on Bluesky. 22 Bluesky bool `json:"bluesky" cborgen:"bluesky"` 23 // description: Free-form profile description text.
··· 18 // RECORDTYPE: ActorProfile 19 type ActorProfile struct { 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"` 23 // bluesky: Include link to this account on Bluesky. 24 Bluesky bool `json:"bluesky" cborgen:"bluesky"` 25 // description: Free-form profile description text.
+44 -1
api/tangled/cbor_gen.go
··· 26 } 27 28 cw := cbg.NewCborWriter(w) 29 - fieldCount := 8 30 31 if t.Description == nil { 32 fieldCount-- ··· 144 return err 145 } 146 147 } 148 } 149 ··· 428 } 429 430 } 431 } 432 // t.Bluesky (bool) (bool) 433 case "bluesky":
··· 26 } 27 28 cw := cbg.NewCborWriter(w) 29 + fieldCount := 9 30 + 31 + if t.Avatar == nil { 32 + fieldCount-- 33 + } 34 35 if t.Description == nil { 36 fieldCount-- ··· 148 return err 149 } 150 151 + } 152 + } 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 ··· 451 } 452 453 } 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 } 475 // t.Bluesky (bool) (bool) 476 case "bluesky":
+7 -3
lexicons/actor/profile.json
··· 8 "key": "literal:self", 9 "record": { 10 "type": "object", 11 - "required": [ 12 - "bluesky" 13 - ], 14 "properties": { 15 "description": { 16 "type": "string", 17 "description": "Free-form profile description text.",
··· 8 "key": "literal:self", 9 "record": { 10 "type": "object", 11 + "required": ["bluesky"], 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 + }, 19 "description": { 20 "type": "string", 21 "description": "Free-form profile description text.",