From 85d99a93e0e608e6e90c1ff99a53326c812ad019 Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Fri, 12 Dec 2025 11:28:28 +0200 Subject: [PATCH] lexicons,api: add avatar field to profile lexicon Change-Id: xrmrrzslmsynvsnktsoxlospxyxyouwk Signed-off-by: Anirudh Oppiliappan --- api/tangled/actorprofile.go | 2 ++ api/tangled/cbor_gen.go | 45 ++++++++++++++++++++++++++++++++++++- lexicons/actor/profile.json | 10 ++++++--- 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/api/tangled/actorprofile.go b/api/tangled/actorprofile.go index 919d7665..ee5ee864 100644 --- a/api/tangled/actorprofile.go +++ b/api/tangled/actorprofile.go @@ -18,6 +18,8 @@ func init() { // RECORDTYPE: ActorProfile type ActorProfile struct { LexiconTypeID string `json:"$type,const=sh.tangled.actor.profile" cborgen:"$type,const=sh.tangled.actor.profile"` + // avatar: Small image to be displayed next to posts from account. AKA, 'profile picture' + Avatar *util.LexBlob `json:"avatar,omitempty" cborgen:"avatar,omitempty"` // bluesky: Include link to this account on Bluesky. Bluesky bool `json:"bluesky" cborgen:"bluesky"` // description: Free-form profile description text. diff --git a/api/tangled/cbor_gen.go b/api/tangled/cbor_gen.go index 93c51a29..32e31293 100644 --- a/api/tangled/cbor_gen.go +++ b/api/tangled/cbor_gen.go @@ -26,7 +26,11 @@ func (t *ActorProfile) MarshalCBOR(w io.Writer) error { } cw := cbg.NewCborWriter(w) - fieldCount := 8 + fieldCount := 9 + + if t.Avatar == nil { + fieldCount-- + } if t.Description == nil { fieldCount-- @@ -147,6 +151,25 @@ func (t *ActorProfile) MarshalCBOR(w io.Writer) error { } } + // t.Avatar (util.LexBlob) (struct) + if t.Avatar != nil { + + if len("avatar") > 1000000 { + return xerrors.Errorf("Value in field \"avatar\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("avatar"))); err != nil { + return err + } + if _, err := cw.WriteString(string("avatar")); err != nil { + return err + } + + if err := t.Avatar.MarshalCBOR(cw); err != nil { + return err + } + } + // t.Bluesky (bool) (bool) if len("bluesky") > 1000000 { return xerrors.Errorf("Value in field \"bluesky\" was too long") @@ -429,6 +452,26 @@ func (t *ActorProfile) UnmarshalCBOR(r io.Reader) (err error) { } } + // t.Avatar (util.LexBlob) (struct) + case "avatar": + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Avatar = new(util.LexBlob) + if err := t.Avatar.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Avatar pointer: %w", err) + } + } + + } // t.Bluesky (bool) (bool) case "bluesky": diff --git a/lexicons/actor/profile.json b/lexicons/actor/profile.json index fdd43674..fd36641f 100644 --- a/lexicons/actor/profile.json +++ b/lexicons/actor/profile.json @@ -8,10 +8,14 @@ "key": "literal:self", "record": { "type": "object", - "required": [ - "bluesky" - ], + "required": ["bluesky"], "properties": { + "avatar": { + "type": "blob", + "description": "Small image to be displayed next to posts from account. AKA, 'profile picture'", + "accept": ["image/png", "image/jpeg"], + "maxSize": 1000000 + }, "description": { "type": "string", "description": "Free-form profile description text.", -- 2.43.0