···
// PostEventConsumer consumes post-related events from Jetstream
16
-
// Currently handles only CREATE operations for social.coves.post.record
16
+
// Currently handles only CREATE operations for social.coves.community.post
// UPDATE and DELETE handlers will be added when those features are implemented
18
-
type PostEventConsumer struct {
18
+
type PostEventConsumer struct{
postRepo posts.Repository
communityRepo communities.Repository
userService users.UserService
···
// Only handle post record creation for now
// UPDATE and DELETE will be added when we implement those features
49
-
if commit.Collection == "social.coves.post.record" && commit.Operation == "create" {
49
+
if commit.Collection == "social.coves.community.post" && commit.Operation == "create" {
return c.createPost(ctx, event.Did, commit)
···
// Build AT-URI for this post
76
-
// Format: at://community_did/social.coves.post.record/rkey
77
-
uri := fmt.Sprintf("at://%s/social.coves.post.record/%s", repoDID, commit.RKey)
76
+
// Format: at://community_did/social.coves.community.post/rkey
77
+
uri := fmt.Sprintf("at://%s/social.coves.community.post/%s", repoDID, commit.RKey)
// Parse timestamp from record
createdAt, err := time.Parse(time.RFC3339, postRecord.CreatedAt)
···
122
-
if len(postRecord.ContentLabels) > 0 {
123
-
labelsJSON, marshalErr := json.Marshal(postRecord.ContentLabels)
122
+
if postRecord.Labels != nil {
123
+
labelsJSON, marshalErr := json.Marshal(postRecord.Labels)
labelsStr := string(labelsJSON)
post.ContentLabels = &labelsStr
···
// This prevents users from creating posts that appear to be from communities they don't control
// Example attack prevented:
154
-
// - User creates post in their own repo (at://user_did/social.coves.post.record/xyz)
154
+
// - User creates post in their own repo (at://user_did/social.coves.community.post/xyz)
// - Claims it's for community X (community field = community_did)
// - Without this check, fake post would be indexed
···
// PostRecordFromJetstream represents a post record as received from Jetstream
202
-
// Matches the structure written to PDS via social.coves.post.record
203
-
type PostRecordFromJetstream struct {
202
+
// Matches the structure written to PDS via social.coves.community.post
203
+
type PostRecordFromJetstream struct{
OriginalAuthor interface{} `json:"originalAuthor,omitempty"`
FederatedFrom interface{} `json:"federatedFrom,omitempty"`
Location interface{} `json:"location,omitempty"`
···
Author string `json:"author"`
CreatedAt string `json:"createdAt"`
Facets []interface{} `json:"facets,omitempty"`
215
-
ContentLabels []string `json:"contentLabels,omitempty"`
215
+
Labels *posts.SelfLabels `json:"labels,omitempty"`
// parsePostRecord converts a raw Jetstream record map to a PostRecordFromJetstream