1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
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"`
}
func AuthorFromAppBskyActorProfileRecord(record AppBskyActorProfileRecord, did, handle string) (*Author, error) {
var avatarURL, bannerURL string
if record.Avatar != nil {
avatarURL = fmt.Sprintf("https://cdn.bsky.app/img/avatar/plain/%s/%s@jpeg", did, record.Avatar.Ref.Link)
}
if record.Banner != nil {
bannerURL = fmt.Sprintf("https://cdn.bsky.app/img/banner/plain/%s/%s@jpeg", did, record.Banner.Ref.Link)
}
author := &Author{
Handle: handle,
DisplayName: record.DisplayName,
AvatarURL: avatarURL,
BannerURL: bannerURL,
Pronouns: record.Pronouns,
}
return author, nil
}
|