aboutsummaryrefslogtreecommitdiff
path: root/backend/notes
diff options
context:
space:
mode:
Diffstat (limited to 'backend/notes')
-rw-r--r--backend/notes/app.bsky.actor.go17
-rw-r--r--backend/notes/app.bsky.feed.go19
-rw-r--r--backend/notes/author.go1
-rw-r--r--backend/notes/note.go20
4 files changed, 39 insertions, 18 deletions
diff --git a/backend/notes/app.bsky.actor.go b/backend/notes/app.bsky.actor.go
index dc5d536..797a8e8 100644
--- a/backend/notes/app.bsky.actor.go
+++ b/backend/notes/app.bsky.actor.go
@@ -17,6 +17,12 @@ type AppBskyActorProfileRecord struct {
} `json:"ref"`
} `json:"banner,omitempty"`
Pronouns string `json:"pronouns"`
+ Labels *struct {
+ Type string `json:"$type"`
+ Values []struct {
+ Val string `json:"val"`
+ } `json:"values"`
+ } `json:"labels,omitempty"`
}
func AuthorFromAppBskyActorProfileRecord(record AppBskyActorProfileRecord, did, handle string) (*Author, error) {
@@ -28,12 +34,23 @@ func AuthorFromAppBskyActorProfileRecord(record AppBskyActorProfileRecord, did,
bannerURL = fmt.Sprintf("https://cdn.bsky.app/img/banner/plain/%s/%s@jpeg", did, record.Banner.Ref.Link)
}
+ // check for !no-unauthenticated label
+ noUnauth := false
+ if record.Labels != nil && record.Labels.Type == "com.atproto.label.defs#selfLabels" {
+ for _, label := range record.Labels.Values {
+ if label.Val == "!no-unauthenticated" {
+ noUnauth = true
+ }
+ }
+ }
+
author := &Author{
Handle: handle,
DisplayName: record.DisplayName,
AvatarURL: avatarURL,
BannerURL: bannerURL,
Pronouns: record.Pronouns,
+ NoUnauth: noUnauth,
}
return author, nil
diff --git a/backend/notes/app.bsky.feed.go b/backend/notes/app.bsky.feed.go
index b5cfd03..961f8d7 100644
--- a/backend/notes/app.bsky.feed.go
+++ b/backend/notes/app.bsky.feed.go
@@ -89,14 +89,15 @@ func NoteFromAppBskyFeedPostRecord(record AppBskyFeedPostRecord, author *Author)
did, _, _, err := general.ParseURI(record.URI)
return &Note{
- URI: record.URI,
- AuthorDID: did,
- AuthorHandle: handle,
- AuthorName: displayName,
- AvatarURL: avatarURL,
- CreatedAt: createdAt,
- Text: record.Value.Text,
- ReplyTo: replyTo,
- Facets: facets,
+ URI: record.URI,
+ AuthorDID: did,
+ AuthorHandle: handle,
+ AuthorName: displayName,
+ AuthorNoUnauth: author.NoUnauth,
+ AvatarURL: avatarURL,
+ CreatedAt: createdAt,
+ Text: record.Value.Text,
+ ReplyTo: replyTo,
+ Facets: facets,
}, nil
}
diff --git a/backend/notes/author.go b/backend/notes/author.go
index 02afabf..644a10c 100644
--- a/backend/notes/author.go
+++ b/backend/notes/author.go
@@ -6,4 +6,5 @@ type Author struct {
AvatarURL string
BannerURL string
Pronouns string
+ NoUnauth bool
}
diff --git a/backend/notes/note.go b/backend/notes/note.go
index 7c8de36..3b32aa1 100644
--- a/backend/notes/note.go
+++ b/backend/notes/note.go
@@ -5,15 +5,17 @@ import (
)
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"`
+ URI string `json:"uri"`
+ AuthorDID string `json:"authorDid"`
+ AuthorHandle string `json:"authorHandle"`
+ AuthorName string `json:"authorName"`
+ AuthorNoUnauth bool `json:"authorNoUnauth"` // author has !no-unauthenticated label
+ AvatarURL string `json:"avatarURL"`
+ Text string `json:"text"`
+ CreatedAt time.Time `json:"createdAt"`
+ ReplyTo *string `json:"replyTo,omitempty"`
+ Facets []Facet `json:"facets,omitempty"`
+ Parents []string `json:"parents,omitempty"`
}
type Facet struct {