From 10e54b1bb7979dc21911afce0d20cffc4a2d038a Mon Sep 17 00:00:00 2001 From: Guillermo Serrahima Date: Tue, 2 Jun 2026 03:15:03 +0200 Subject: added images --- notes/app.bsky.feed.go | 12 +++++++----- notes/author.go | 8 ++++++++ notes/note.go | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) (limited to 'notes') diff --git a/notes/app.bsky.feed.go b/notes/app.bsky.feed.go index 21b94f9..1ee3cca 100644 --- a/notes/app.bsky.feed.go +++ b/notes/app.bsky.feed.go @@ -9,7 +9,9 @@ import ( type EmbedImage struct { Alt string `json:"alt"` Image struct { - CID string `json:"$link"` + Ref struct { + CID string `json:"$link"` + } `json:"ref"` } `json:"image"` AspectRatio *struct { Width int `json:"width"` @@ -54,7 +56,7 @@ type AppBskyFeedPostRecord struct { } `json:"value"` } -func extractImages(embed *AppBskyFeedPostEmbed, did, pdsURL string) []Media { +func extractImages(embed *AppBskyFeedPostEmbed, did string) []Media { if embed == nil { return nil } @@ -65,7 +67,7 @@ func extractImages(embed *AppBskyFeedPostEmbed, did, pdsURL string) []Media { var media []Media for _, img := range images { m := Media{ - URL: fmt.Sprintf("%s/xrpc/com.atproto.sync.getBlob?did=%s&cid=%s", pdsURL, did, img.Image.CID), + URL: fmt.Sprintf("/api/blob/%s/%s", did, img.Image.Ref.CID), Alt: img.Alt, } if img.AspectRatio != nil { @@ -77,7 +79,7 @@ func extractImages(embed *AppBskyFeedPostEmbed, did, pdsURL string) []Media { return media } -func NoteFromAppBskyFeedPostRecord(record AppBskyFeedPostRecord, author *Author) (*Note, error) { +func NoteFromAppBskyFeedPostRecord(record AppBskyFeedPostRecord, author *Author, porxieURL string) (*Note, error) { if record.URI == "" { return nil, fmt.Errorf("missing required field: uri") } @@ -145,6 +147,6 @@ func NoteFromAppBskyFeedPostRecord(record AppBskyFeedPostRecord, author *Author) Text: record.Value.Text, ReplyTo: replyTo, Facets: facets, - Media: extractImages(record.Value.Embed, did, author.PDS), + Media: extractImages(record.Value.Embed, did), }, nil } diff --git a/notes/author.go b/notes/author.go index faf4f7b..74201c1 100644 --- a/notes/author.go +++ b/notes/author.go @@ -9,3 +9,11 @@ type Author struct { Pronouns string NoUnauth bool } + +func IsPublic(author *Author) bool { + if author == nil { + return false + } + + return !author.NoUnauth +} diff --git a/notes/note.go b/notes/note.go index 15f6f67..f6b8bf3 100644 --- a/notes/note.go +++ b/notes/note.go @@ -37,7 +37,7 @@ func MissingNote(uri string) *Note { return &Note{ URI: uri, AuthorDID: "MISSING", - Text: "This post could not be fetched. It may have been deleted.", + Text: "This post is unavailable. It may have been deleted.", CreatedAt: time.Time{}, } } -- cgit v1.2.3