diff options
| author | Guillermo Serrahima <dev@vylion.com> | 2026-03-18 22:02:13 +0100 |
|---|---|---|
| committer | Guillermo Serrahima <dev@vylion.com> | 2026-03-20 00:50:46 +0100 |
| commit | 59545c874d8635c39ccdbecf84f953686dd5c03c (patch) | |
| tree | 2c0e682acd56925c2a65dcf2c96a22c95202e550 /backend/notes | |
| parent | 9181a6e454e3b294004923b2036b9852212cce7f (diff) | |
| download | llostre-59545c874d8635c39ccdbecf84f953686dd5c03c.tar.xz llostre-59545c874d8635c39ccdbecf84f953686dd5c03c.zip | |
more naming refactors
Diffstat (limited to 'backend/notes')
| -rw-r--r-- | backend/notes/app.bsky.actor.go | 40 | ||||
| -rw-r--r-- | backend/notes/app.bsky.feed.go (renamed from backend/notes/app.bsky.feed.post.go) | 10 | ||||
| -rw-r--r-- | backend/notes/author.go | 9 |
3 files changed, 54 insertions, 5 deletions
diff --git a/backend/notes/app.bsky.actor.go b/backend/notes/app.bsky.actor.go new file mode 100644 index 0000000..dc5d536 --- /dev/null +++ b/backend/notes/app.bsky.actor.go @@ -0,0 +1,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 +} diff --git a/backend/notes/app.bsky.feed.post.go b/backend/notes/app.bsky.feed.go index 451633e..b5cfd03 100644 --- a/backend/notes/app.bsky.feed.post.go +++ b/backend/notes/app.bsky.feed.go @@ -31,7 +31,7 @@ type AppBskyFeedPostRecord struct { } `json:"value"` } -func NoteFromAppBskyFeedPostRecord(record AppBskyFeedPostRecord, profile *general.Profile) (*Note, error) { +func NoteFromAppBskyFeedPostRecord(record AppBskyFeedPostRecord, author *Author) (*Note, error) { if record.URI == "" { return nil, fmt.Errorf("missing required field: uri") } @@ -76,10 +76,10 @@ func NoteFromAppBskyFeedPostRecord(record AppBskyFeedPostRecord, profile *genera } var handle, displayName, avatarURL string - if profile != nil { - handle = profile.Handle - displayName = profile.DisplayName - avatarURL = profile.AvatarURL + if author != nil { + handle = author.Handle + displayName = author.DisplayName + avatarURL = author.AvatarURL } else { handle = "handle.invalid" displayName = "" diff --git a/backend/notes/author.go b/backend/notes/author.go new file mode 100644 index 0000000..02afabf --- /dev/null +++ b/backend/notes/author.go @@ -0,0 +1,9 @@ +package notes + +type Author struct { + Handle string + DisplayName string + AvatarURL string + BannerURL string + Pronouns string +} |
