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