From 6e09ad4d8dac347d23b64ab8ec5ba8ee734ba077 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Sat, 10 May 2025 16:44:45 +0000 Subject: [PATCH] lexicons: fix trailing comma in sh.tangled.actor.profile --- api/tangled/actorprofile.go | 2 +- api/tangled/cbor_gen.go | 78 +++++++++++++++++++++++++----------------------------------------------------- appview/ingester.go | 5 +---- appview/state/profile.go | 2 +- lexicons/actor/profile.json | 4 +++- 5 file(s) changed, 31 insertion(s)(+), 60 deletion(s)(-) diff --git a/api/tangled/actorprofile.go b/api/tangled/actorprofile.go --- a/api/tangled/actorprofile.go +++ b/api/tangled/actorprofile.go @@ -19,7 +19,7 @@ // RECORDTYPE: ActorProfile type ActorProfile struct { LexiconTypeID string `json:"$type,const=sh.tangled.actor.profile" cborgen:"$type,const=sh.tangled.actor.profile"` // bluesky: Include link to this account on Bluesky. - Bluesky *bool `json:"bluesky,omitempty" cborgen:"bluesky,omitempty"` + Bluesky bool `json:"bluesky" cborgen:"bluesky"` // description: Free-form profile description text. Description *string `json:"description,omitempty" cborgen:"description,omitempty"` Links []string `json:"links,omitempty" cborgen:"links,omitempty"` diff --git a/api/tangled/cbor_gen.go b/api/tangled/cbor_gen.go --- a/api/tangled/cbor_gen.go +++ b/api/tangled/cbor_gen.go @@ -3398,10 +3398,6 @@ cw := cbg.NewCborWriter(w) fieldCount := 7 - if t.Bluesky == nil { - fieldCount-- - } - if t.Description == nil { fieldCount-- } @@ -3518,28 +3514,19 @@ } } // t.Bluesky (bool) (bool) - if t.Bluesky != nil { + if len("bluesky") > 1000000 { + return xerrors.Errorf("Value in field \"bluesky\" was too long") + } - if len("bluesky") > 1000000 { - return xerrors.Errorf("Value in field \"bluesky\" was too long") - } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("bluesky"))); err != nil { + return err + } + if _, err := cw.WriteString(string("bluesky")); err != nil { + return err + } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("bluesky"))); err != nil { - return err - } - if _, err := cw.WriteString(string("bluesky")); err != nil { - return err - } - - if t.Bluesky == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if err := cbg.WriteBool(w, *t.Bluesky); err != nil { - return err - } - } + if err := cbg.WriteBool(w, t.Bluesky); err != nil { + return err } // t.Location (string) (string) @@ -3779,35 +3766,20 @@ } // t.Bluesky (bool) (bool) case "bluesky": - { - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - if maj != cbg.MajOther { - return fmt.Errorf("booleans must be major type 7") - } - - var val bool - switch extra { - case 20: - val = false - case 21: - val = true - default: - return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) - } - t.Bluesky = &val - } + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajOther { + return fmt.Errorf("booleans must be major type 7") + } + switch extra { + case 20: + t.Bluesky = false + case 21: + t.Bluesky = true + default: + return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) } // t.Location (string) (string) case "location": diff --git a/appview/ingester.go b/appview/ingester.go --- a/appview/ingester.go +++ b/appview/ingester.go @@ -210,10 +210,7 @@ if record.Description != nil { description = *record.Description } - includeBluesky := false - if record.Bluesky != nil { - includeBluesky = *record.Bluesky - } + includeBluesky := record.Bluesky location := "" if record.Location != nil { diff --git a/appview/state/profile.go b/appview/state/profile.go --- a/appview/state/profile.go +++ b/appview/state/profile.go @@ -325,7 +325,7 @@ Repo: user.Did, Rkey: "self", Record: &lexutil.LexiconTypeDecoder{ Val: &tangled.ActorProfile{ - Bluesky: &profile.IncludeBluesky, + Bluesky: profile.IncludeBluesky, Description: &profile.Description, Links: profile.Links[:], Location: &profile.Location, diff --git a/lexicons/actor/profile.json b/lexicons/actor/profile.json --- a/lexicons/actor/profile.json +++ b/lexicons/actor/profile.json @@ -8,7 +8,9 @@ "description": "A declaration of a Tangled account profile.", "key": "literal:self", "record": { "type": "object", - "required": ["bluesky"], + "required": [ + "bluesky" + ], "properties": { "description": { "type": "string", -- tangled.sh