aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillermo Serrahima <dev@vylion.com>2026-03-12 17:18:37 +0100
committerGuillermo Serrahima <dev@vylion.com>2026-03-12 17:18:37 +0100
commit5c5028eff2681946fe1c3b330a89c65de6f134b5 (patch)
treee661aeaa2e3c35682506113f74e274434ab3a166
parente757316366f9308718566feda5f9570a3b4a7f5f (diff)
downloadllostre-5c5028eff2681946fe1c3b330a89c65de6f134b5.tar.xz
llostre-5c5028eff2681946fe1c3b330a89c65de6f134b5.zip
Note struct refactor
-rw-r--r--backend/fetchers/app.bsky.go4
-rw-r--r--backend/notes/app.bsky.feed.post.go43
-rw-r--r--backend/notes/note.go23
3 files changed, 21 insertions, 49 deletions
diff --git a/backend/fetchers/app.bsky.go b/backend/fetchers/app.bsky.go
index b6bb939..b6a133b 100644
--- a/backend/fetchers/app.bsky.go
+++ b/backend/fetchers/app.bsky.go
@@ -12,7 +12,7 @@ type ListRecordsResponse struct {
Records []notes.AppBskyFeedPostRecord `json:"records"`
}
-func FetchAppBskyFeedPosts(did, pdsURL, accessToken string, keypair *auth.DPoPKeyPair) ([]notes.AppBskyFeedPostNote, error) {
+func FetchAppBskyFeedPosts(did, pdsURL, accessToken string, keypair *auth.DPoPKeyPair) ([]notes.Note, error) {
url := fmt.Sprintf("%s/xrpc/com.atproto.repo.listRecords?repo=%s&collection=app.bsky.feed.post", pdsURL, did)
fmt.Printf("Generating DPoP proof for: %s\n", url)
@@ -48,7 +48,7 @@ func FetchAppBskyFeedPosts(did, pdsURL, accessToken string, keypair *auth.DPoPKe
fmt.Printf("Fetched profile: %+v\n", profile)
}
- var posts []notes.AppBskyFeedPostNote
+ var posts []notes.Note
for _, record := range response.Records {
bp, err := notes.AppBskyFeedPostFromRecord(record, profile)
if err != nil {
diff --git a/backend/notes/app.bsky.feed.post.go b/backend/notes/app.bsky.feed.post.go
index 17ff5ee..1c11733 100644
--- a/backend/notes/app.bsky.feed.post.go
+++ b/backend/notes/app.bsky.feed.post.go
@@ -7,25 +7,6 @@ import (
"time"
)
-type AppBskyFeedPostNote struct {
- URI string `json:"uri"`
- AuthorDID string `json:"authorDid"`
- AuthorHandle string `json:"authorHandle"`
- AuthorName string `json:"authorName"`
- AvatarURL string `json:"avatarURL"`
- Text string `json:"text"`
- CreatedAt time.Time `json:"createdAt"`
- ReplyTo *string `json:"replyTo,omitempty"`
- Facets []Facet `json:"facets,omitempty"`
-}
-
-type Facet struct {
- ByteStart int `json:"byteStart"`
- ByteEnd int `json:"byteEnd"`
- Type string `json:"type"`
- Value string `json:"value"` // the link destination, whether url, profile or tag
-}
-
type AppBskyFeedPostRecord struct {
URI string `json:"uri"`
Value struct {
@@ -51,27 +32,7 @@ type AppBskyFeedPostRecord struct {
} `json:"value"`
}
-func (bp *AppBskyFeedPostNote) GetID() string {
- return bp.URI
-}
-
-func (bp *AppBskyFeedPostNote) GetAuthorDID() string {
- return bp.AuthorDID
-}
-
-func (bp *AppBskyFeedPostNote) GetAuthorHandle() string {
- return bp.AuthorHandle
-}
-
-func (bp *AppBskyFeedPostNote) GetTimestamp() time.Time {
- return bp.CreatedAt
-}
-
-func (bp *AppBskyFeedPostNote) GetReplyTo() *string {
- return bp.ReplyTo
-}
-
-func AppBskyFeedPostFromRecord(record AppBskyFeedPostRecord, profile *general.Profile) (*AppBskyFeedPostNote, error) {
+func AppBskyFeedPostFromRecord(record AppBskyFeedPostRecord, profile *general.Profile) (*Note, error) {
if record.URI == "" {
return nil, fmt.Errorf("missing required field: uri")
}
@@ -129,7 +90,7 @@ func AppBskyFeedPostFromRecord(record AppBskyFeedPostRecord, profile *general.Pr
avatarURL = ""
}
- return &AppBskyFeedPostNote{
+ return &Note{
URI: record.URI,
AuthorDID: did,
AuthorHandle: handle,
diff --git a/backend/notes/note.go b/backend/notes/note.go
index 1d92948..7c8de36 100644
--- a/backend/notes/note.go
+++ b/backend/notes/note.go
@@ -4,10 +4,21 @@ import (
"time"
)
-type Note interface {
- GetID() string
- GetAuthorDID() string
- GetAuthorHandle() string
- GetTimestamp() time.Time
- GetReplyTo() *string
+type Note struct {
+ URI string `json:"uri"`
+ AuthorDID string `json:"authorDid"`
+ AuthorHandle string `json:"authorHandle"`
+ AuthorName string `json:"authorName"`
+ AvatarURL string `json:"avatarURL"`
+ Text string `json:"text"`
+ CreatedAt time.Time `json:"createdAt"`
+ ReplyTo *string `json:"replyTo,omitempty"`
+ Facets []Facet `json:"facets,omitempty"`
+}
+
+type Facet struct {
+ ByteStart int `json:"byteStart"`
+ ByteEnd int `json:"byteEnd"`
+ Type string `json:"type"`
+ Value string `json:"value"` // the link destination, whether url, profile or tag
}