A community based topic aggregation platform built on atproto
1package posts
2
3import (
4 "time"
5)
6
7// Post represents a post in the AppView database
8// Posts are indexed from the firehose after being written to community repositories
9type Post struct {
10 CreatedAt time.Time `json:"createdAt" db:"created_at"`
11 IndexedAt time.Time `json:"indexedAt" db:"indexed_at"`
12 EditedAt *time.Time `json:"editedAt,omitempty" db:"edited_at"`
13 Embed *string `json:"embed,omitempty" db:"embed"`
14 DeletedAt *time.Time `json:"deletedAt,omitempty" db:"deleted_at"`
15 ContentLabels *string `json:"contentLabels,omitempty" db:"content_labels"`
16 Title *string `json:"title,omitempty" db:"title"`
17 Content *string `json:"content,omitempty" db:"content"`
18 ContentFacets *string `json:"contentFacets,omitempty" db:"content_facets"`
19 CID string `json:"cid" db:"cid"`
20 CommunityDID string `json:"communityDid" db:"community_did"`
21 RKey string `json:"rkey" db:"rkey"`
22 URI string `json:"uri" db:"uri"`
23 AuthorDID string `json:"authorDid" db:"author_did"`
24 ID int64 `json:"id" db:"id"`
25 UpvoteCount int `json:"upvoteCount" db:"upvote_count"`
26 DownvoteCount int `json:"downvoteCount" db:"downvote_count"`
27 Score int `json:"score" db:"score"`
28 CommentCount int `json:"commentCount" db:"comment_count"`
29}
30
31// CreatePostRequest represents input for creating a new post
32// Matches social.coves.post.create lexicon input schema
33type CreatePostRequest struct {
34 OriginalAuthor interface{} `json:"originalAuthor,omitempty"`
35 FederatedFrom interface{} `json:"federatedFrom,omitempty"`
36 Location interface{} `json:"location,omitempty"`
37 Title *string `json:"title,omitempty"`
38 Content *string `json:"content,omitempty"`
39 Embed map[string]interface{} `json:"embed,omitempty"`
40 Community string `json:"community"`
41 AuthorDID string `json:"authorDid"`
42 Facets []interface{} `json:"facets,omitempty"`
43 ContentLabels []string `json:"contentLabels,omitempty"`
44}
45
46// CreatePostResponse represents the response from creating a post
47// Matches social.coves.post.create lexicon output schema
48type CreatePostResponse struct {
49 URI string `json:"uri"` // AT-URI of created post
50 CID string `json:"cid"` // CID of created post
51}
52
53// PostRecord represents the actual atProto record structure written to PDS
54// This is the data structure that gets stored in the community's repository
55type PostRecord struct {
56 OriginalAuthor interface{} `json:"originalAuthor,omitempty"`
57 FederatedFrom interface{} `json:"federatedFrom,omitempty"`
58 Location interface{} `json:"location,omitempty"`
59 Title *string `json:"title,omitempty"`
60 Content *string `json:"content,omitempty"`
61 Embed map[string]interface{} `json:"embed,omitempty"`
62 Type string `json:"$type"`
63 Community string `json:"community"`
64 Author string `json:"author"`
65 CreatedAt string `json:"createdAt"`
66 Facets []interface{} `json:"facets,omitempty"`
67 ContentLabels []string `json:"contentLabels,omitempty"`
68}
69
70// PostView represents the full view of a post with all metadata
71// Matches social.coves.post.get#postView lexicon
72// Used in feeds and get endpoints
73type PostView struct {
74 IndexedAt time.Time `json:"indexedAt"`
75 CreatedAt time.Time `json:"createdAt"`
76 Record interface{} `json:"record,omitempty"`
77 Embed interface{} `json:"embed,omitempty"`
78 Language *string `json:"language,omitempty"`
79 EditedAt *time.Time `json:"editedAt,omitempty"`
80 Title *string `json:"title,omitempty"`
81 Text *string `json:"text,omitempty"`
82 Viewer *ViewerState `json:"viewer,omitempty"`
83 Author *AuthorView `json:"author"`
84 Stats *PostStats `json:"stats,omitempty"`
85 Community *CommunityRef `json:"community"`
86 RKey string `json:"rkey"`
87 CID string `json:"cid"`
88 URI string `json:"uri"`
89 TextFacets []interface{} `json:"textFacets,omitempty"`
90 UpvoteCount int `json:"-"`
91 DownvoteCount int `json:"-"`
92 Score int `json:"-"`
93 CommentCount int `json:"-"`
94}
95
96// AuthorView represents author information in post views
97type AuthorView struct {
98 DisplayName *string `json:"displayName,omitempty"`
99 Avatar *string `json:"avatar,omitempty"`
100 Reputation *int `json:"reputation,omitempty"`
101 DID string `json:"did"`
102 Handle string `json:"handle"`
103}
104
105// CommunityRef represents minimal community info in post views
106type CommunityRef struct {
107 Avatar *string `json:"avatar,omitempty"`
108 DID string `json:"did"`
109 Name string `json:"name"`
110}
111
112// PostStats represents aggregated statistics
113type PostStats struct {
114 TagCounts map[string]int `json:"tagCounts,omitempty"`
115 Upvotes int `json:"upvotes"`
116 Downvotes int `json:"downvotes"`
117 Score int `json:"score"`
118 CommentCount int `json:"commentCount"`
119 ShareCount int `json:"shareCount,omitempty"`
120}
121
122// ViewerState represents the viewer's relationship with the post
123type ViewerState struct {
124 Vote *string `json:"vote,omitempty"`
125 VoteURI *string `json:"voteUri,omitempty"`
126 SavedURI *string `json:"savedUri,omitempty"`
127 Tags []string `json:"tags,omitempty"`
128 Saved bool `json:"saved"`
129}