A community based topic aggregation platform built on atproto
1package posts
2
3import (
4 "context"
5)
6
7// Service constructor accepts optional blobs.Service and unfurl.Service for embed enhancement.
8// When unfurlService is provided, external embeds will be automatically enriched with metadata.
9// When blobService is provided, thumbnails from unfurled URLs will be uploaded as blobs.
10
11// Service defines the business logic interface for posts
12// Coordinates between Repository, community service, and PDS
13type Service interface {
14 // CreatePost creates a new post in a community
15 // Flow: Validate -> Fetch community -> Ensure fresh token -> Write to PDS -> Return URI/CID
16 // AppView indexing happens asynchronously via Jetstream consumer
17 CreatePost(ctx context.Context, req CreatePostRequest) (*CreatePostResponse, error)
18
19 // Future methods (Beta):
20 // GetPost(ctx context.Context, uri string, viewerDID *string) (*Post, error)
21 // UpdatePost(ctx context.Context, req UpdatePostRequest) (*Post, error)
22 // DeletePost(ctx context.Context, uri string, userDID string) error
23 // ListCommunityPosts(ctx context.Context, communityDID string, limit, offset int) ([]*Post, error)
24}
25
26// Repository defines the data access interface for posts
27// Used by Jetstream consumer to index posts from firehose
28type Repository interface {
29 // Create inserts a new post into the AppView database
30 // Called by Jetstream consumer after post is created on PDS
31 Create(ctx context.Context, post *Post) error
32
33 // GetByURI retrieves a post by its AT-URI
34 // Used for E2E test verification and future GET endpoint
35 GetByURI(ctx context.Context, uri string) (*Post, error)
36
37 // Future methods (Beta):
38 // Update(ctx context.Context, post *Post) error
39 // Delete(ctx context.Context, uri string) error
40 // List(ctx context.Context, communityDID string, limit, offset int) ([]*Post, int, error)
41}