mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-08-29 04:06:58 +00:00
clean up some lexicon usage
This commit is contained in:
@@ -41,6 +41,9 @@ const (
|
||||
// TangledProfileCollection is the collection name for tangled profiles
|
||||
// Stored in hold's embedded PDS (singleton record at rkey "self")
|
||||
TangledProfileCollection = "sh.tangled.actor.profile"
|
||||
|
||||
// BskyPostCollection is the collection name for Bluesky posts
|
||||
BskyPostCollection = "app.bsky.feed.post"
|
||||
|
||||
// SailorProfileCollection is the collection name for user profiles
|
||||
SailorProfileCollection = "io.atcr.sailor.profile"
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"atcr.io/pkg/atproto"
|
||||
bsky "github.com/bluesky-social/indigo/api/bsky"
|
||||
"github.com/distribution/distribution/v3/registry/storage/driver"
|
||||
)
|
||||
@@ -70,7 +71,7 @@ func (p *HoldPDS) CreateManifestPost(
|
||||
|
||||
// Create post struct with facets and embed
|
||||
post := &bsky.FeedPost{
|
||||
LexiconTypeID: "app.bsky.feed.post",
|
||||
LexiconTypeID: atproto.BskyPostCollection,
|
||||
Text: text,
|
||||
Facets: facets,
|
||||
Embed: embed,
|
||||
@@ -82,7 +83,7 @@ func (p *HoldPDS) CreateManifestPost(
|
||||
rkey, recordCID, err := p.repomgr.CreateRecord(
|
||||
ctx,
|
||||
p.uid,
|
||||
"app.bsky.feed.post",
|
||||
atproto.BskyPostCollection,
|
||||
post,
|
||||
)
|
||||
|
||||
@@ -91,7 +92,7 @@ func (p *HoldPDS) CreateManifestPost(
|
||||
}
|
||||
|
||||
// Build ATProto URI for the post
|
||||
postURI := fmt.Sprintf("at://%s/app.bsky.feed.post/%s", p.did, rkey)
|
||||
postURI := fmt.Sprintf("at://%s/%s/%s", p.did, atproto.BskyPostCollection, rkey)
|
||||
|
||||
slog.Info("Created manifest post",
|
||||
"uri", postURI,
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"atcr.io/pkg/atproto"
|
||||
bsky "github.com/bluesky-social/indigo/api/bsky"
|
||||
)
|
||||
|
||||
@@ -196,7 +197,7 @@ func TestSimplifiedPostFormat(t *testing.T) {
|
||||
|
||||
// Verify the complete post structure
|
||||
post := &bsky.FeedPost{
|
||||
LexiconTypeID: "app.bsky.feed.post",
|
||||
LexiconTypeID: atproto.BskyPostCollection,
|
||||
Text: text,
|
||||
Facets: facets,
|
||||
Langs: []string{"en"},
|
||||
@@ -250,7 +251,7 @@ func TestSimplifiedPostFormat_MultiArch(t *testing.T) {
|
||||
|
||||
// Verify the complete post structure
|
||||
post := &bsky.FeedPost{
|
||||
LexiconTypeID: "app.bsky.feed.post",
|
||||
LexiconTypeID: atproto.BskyPostCollection,
|
||||
Text: text,
|
||||
Facets: facets,
|
||||
Langs: []string{"en"},
|
||||
|
||||
@@ -6,14 +6,10 @@ import (
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
"atcr.io/pkg/atproto"
|
||||
bsky "github.com/bluesky-social/indigo/api/bsky"
|
||||
)
|
||||
|
||||
const (
|
||||
// StatusPostCollection is the collection name for Bluesky posts
|
||||
StatusPostCollection = "app.bsky.feed.post"
|
||||
)
|
||||
|
||||
// SetStatus creates a new status post on Bluesky
|
||||
// status should be "online" or "offline"
|
||||
// Each call creates a unique post with a TID-based rkey
|
||||
@@ -40,20 +36,20 @@ func (p *HoldPDS) createStatusPost(ctx context.Context, text string) error {
|
||||
// Create post struct
|
||||
now := time.Now()
|
||||
post := &bsky.FeedPost{
|
||||
LexiconTypeID: "app.bsky.feed.post",
|
||||
LexiconTypeID: atproto.BskyPostCollection,
|
||||
Text: text,
|
||||
CreatedAt: now.Format(time.RFC3339),
|
||||
}
|
||||
|
||||
// Use repomgr.CreateRecord to create the post with auto-generated TID
|
||||
// CreateRecord automatically generates a unique TID using the repo's clock
|
||||
rkey, recordCID, err := p.repomgr.CreateRecord(ctx, p.uid, StatusPostCollection, post)
|
||||
rkey, recordCID, err := p.repomgr.CreateRecord(ctx, p.uid, atproto.BskyPostCollection, post)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create status post: %w", err)
|
||||
}
|
||||
|
||||
slog.Info("Created status post",
|
||||
"collection", StatusPostCollection,
|
||||
"collection", atproto.BskyPostCollection,
|
||||
"rkey", rkey,
|
||||
"cid", recordCID.String(),
|
||||
"text", text)
|
||||
|
||||
@@ -61,7 +61,7 @@ func TestStatusPost(t *testing.T) {
|
||||
listPosts := func() ([]map[string]any, error) {
|
||||
req := makeXRPCGetRequest(atproto.RepoListRecords, map[string]string{
|
||||
"repo": did,
|
||||
"collection": StatusPostCollection,
|
||||
"collection": atproto.BskyPostCollection,
|
||||
"limit": "100",
|
||||
"reverse": "true", // Most recent first
|
||||
})
|
||||
@@ -134,8 +134,8 @@ func TestStatusPost(t *testing.T) {
|
||||
}
|
||||
// URI format: at://did:web:test.example.com/app.bsky.feed.post/3m3c4...
|
||||
// We just check that it contains the collection
|
||||
if !contains(uri, StatusPostCollection) {
|
||||
t.Errorf("Expected URI to contain collection %s, got %s", StatusPostCollection, uri)
|
||||
if !contains(uri, atproto.BskyPostCollection) {
|
||||
t.Errorf("Expected URI to contain collection %s, got %s", atproto.BskyPostCollection, uri)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -226,13 +226,6 @@ func TestStatusPost(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestStatusPostCollection(t *testing.T) {
|
||||
// Verify constant
|
||||
if StatusPostCollection != "app.bsky.feed.post" {
|
||||
t.Errorf("Expected StatusPostCollection 'app.bsky.feed.post', got '%s'", StatusPostCollection)
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to check if a string contains a substring
|
||||
func contains(s, substr string) bool {
|
||||
return len(s) >= len(substr) && (s == substr || len(s) > len(substr) && findSubstring(s, substr))
|
||||
|
||||
@@ -366,7 +366,7 @@ func (h *XRPCHandler) buildProfileResponse(ctx context.Context) map[string]any {
|
||||
repoHandle, err := repo.OpenRepo(ctx, session, head)
|
||||
if err == nil {
|
||||
postCount := 0
|
||||
_ = repoHandle.ForEach(ctx, "app.bsky.feed.post", func(k string, v cid.Cid) error {
|
||||
_ = repoHandle.ForEach(ctx, atproto.BskyPostCollection, func(k string, v cid.Cid) error {
|
||||
postCount++
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user