A community based topic aggregation platform built on atproto
1package comments
2
3import (
4 "time"
5)
6
7// Comment represents a comment in the AppView database
8// Comments are indexed from the firehose after being written to user repositories
9type Comment struct {
10 ID int64 `json:"id" db:"id"`
11 URI string `json:"uri" db:"uri"`
12 CID string `json:"cid" db:"cid"`
13 RKey string `json:"rkey" db:"rkey"`
14 CommenterDID string `json:"commenterDid" db:"commenter_did"`
15
16 // Threading (reply references)
17 RootURI string `json:"rootUri" db:"root_uri"`
18 RootCID string `json:"rootCid" db:"root_cid"`
19 ParentURI string `json:"parentUri" db:"parent_uri"`
20 ParentCID string `json:"parentCid" db:"parent_cid"`
21
22 // Content
23 Content string `json:"content" db:"content"`
24 ContentFacets *string `json:"contentFacets,omitempty" db:"content_facets"`
25 Embed *string `json:"embed,omitempty" db:"embed"`
26 ContentLabels *string `json:"labels,omitempty" db:"content_labels"`
27 Langs []string `json:"langs,omitempty" db:"langs"`
28
29 // Timestamps
30 CreatedAt time.Time `json:"createdAt" db:"created_at"`
31 IndexedAt time.Time `json:"indexedAt" db:"indexed_at"`
32 DeletedAt *time.Time `json:"deletedAt,omitempty" db:"deleted_at"`
33
34 // Stats (denormalized for performance)
35 UpvoteCount int `json:"upvoteCount" db:"upvote_count"`
36 DownvoteCount int `json:"downvoteCount" db:"downvote_count"`
37 Score int `json:"score" db:"score"`
38 ReplyCount int `json:"replyCount" db:"reply_count"`
39}
40
41// CommentRecord represents the atProto record structure indexed from Jetstream
42// This is the data structure that gets stored in the user's repository
43// Matches social.coves.feed.comment lexicon
44type CommentRecord struct {
45 Type string `json:"$type"`
46 Reply ReplyRef `json:"reply"`
47 Content string `json:"content"`
48 Facets []interface{} `json:"facets,omitempty"`
49 Embed map[string]interface{} `json:"embed,omitempty"`
50 Langs []string `json:"langs,omitempty"`
51 Labels *SelfLabels `json:"labels,omitempty"`
52 CreatedAt string `json:"createdAt"`
53}
54
55// ReplyRef represents the threading structure from the comment lexicon
56// Root always points to the original post, parent points to the immediate parent
57type ReplyRef struct {
58 Root StrongRef `json:"root"`
59 Parent StrongRef `json:"parent"`
60}
61
62// StrongRef represents a strong reference to a record (URI + CID)
63// Matches com.atproto.repo.strongRef
64type StrongRef struct {
65 URI string `json:"uri"`
66 CID string `json:"cid"`
67}
68
69// SelfLabels represents self-applied content labels per com.atproto.label.defs#selfLabels
70// This is the structured format used in atProto for content warnings
71type SelfLabels struct {
72 Values []SelfLabel `json:"values"`
73}
74
75// SelfLabel represents a single label value per com.atproto.label.defs#selfLabel
76// Neg is optional and negates the label when true
77type SelfLabel struct {
78 Val string `json:"val"` // Required: label value (max 128 chars)
79 Neg *bool `json:"neg,omitempty"` // Optional: negates the label if true
80}