diff options
| author | Guillermo Serrahima <dev@vylion.com> | 2026-04-11 07:40:30 +0200 |
|---|---|---|
| committer | Guillermo Serrahima <dev@vylion.com> | 2026-04-11 23:39:19 +0200 |
| commit | 9f0a9a6779f00786e4728ad5c3fad36814a293b0 (patch) | |
| tree | 4b16d535c5d41ef46980608a88b7581be3c2bfd0 /notes/app.bsky.actor.go | |
| parent | f6d60077b7cfc0d589fa7961e2bb59aea9f993a3 (diff) | |
| download | llostre-9f0a9a6779f00786e4728ad5c3fad36814a293b0.tar.xz llostre-9f0a9a6779f00786e4728ad5c3fad36814a293b0.zip | |
project restructure
Diffstat (limited to 'notes/app.bsky.actor.go')
| -rw-r--r-- | notes/app.bsky.actor.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/notes/app.bsky.actor.go b/notes/app.bsky.actor.go new file mode 100644 index 0000000..00a1ff1 --- /dev/null +++ b/notes/app.bsky.actor.go @@ -0,0 +1,58 @@ +package notes + +import ( + "fmt" +) + +type AppBskyActorProfileRecord struct { + DisplayName string `json:"displayName"` + Avatar *struct { + Ref struct { + Link string `json:"$link"` + } `json:"ref"` + } `json:"avatar,omitempty"` + Banner *struct { + Ref struct { + Link string `json:"$link"` + } `json:"ref"` + } `json:"banner,omitempty"` + Pronouns string `json:"pronouns"` + Labels *struct { + Type string `json:"$type"` + Values []struct { + Val string `json:"val"` + } `json:"values"` + } `json:"labels,omitempty"` +} + +func AuthorFromAppBskyActorProfileRecord(record AppBskyActorProfileRecord, did, handle, pds string) (*Author, error) { + var avatarURL, bannerURL string + if record.Avatar != nil { + avatarURL = fmt.Sprintf("%s/xrpc/com.atproto.sync.getBlob?did=%s&cid=%s", pds, did, record.Avatar.Ref.Link) + } + if record.Banner != nil { + bannerURL = fmt.Sprintf("%s/xrpc/com.atproto.sync.getBlob?did=%s&cid=%s", pds, did, record.Banner.Ref.Link) + } + + // check for !no-unauthenticated label + noUnauth := false + if record.Labels != nil && record.Labels.Type == "com.atproto.label.defs#selfLabels" { + for _, label := range record.Labels.Values { + if label.Val == "!no-unauthenticated" { + noUnauth = true + } + } + } + + author := &Author{ + PDS: pds, + Handle: handle, + DisplayName: record.DisplayName, + AvatarURL: avatarURL, + BannerURL: bannerURL, + Pronouns: record.Pronouns, + NoUnauth: noUnauth, + } + + return author, nil +} |
