diff options
| author | Guillermo Serrahima <dev@vylion.com> | 2026-06-02 03:15:03 +0200 |
|---|---|---|
| committer | Guillermo Serrahima <dev@vylion.com> | 2026-07-14 23:11:05 +0200 |
| commit | 10e54b1bb7979dc21911afce0d20cffc4a2d038a (patch) | |
| tree | a0513d16a7896031efff51db61f04a50b95f719e /notes | |
| parent | 9f0a9a6779f00786e4728ad5c3fad36814a293b0 (diff) | |
| download | llostre-10e54b1bb7979dc21911afce0d20cffc4a2d038a.tar.xz llostre-10e54b1bb7979dc21911afce0d20cffc4a2d038a.zip | |
added images
Diffstat (limited to 'notes')
| -rw-r--r-- | notes/app.bsky.feed.go | 12 | ||||
| -rw-r--r-- | notes/author.go | 8 | ||||
| -rw-r--r-- | notes/note.go | 2 |
3 files changed, 16 insertions, 6 deletions
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{}, } } |
