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