···
"Coves/internal/core/posts"
type postgresPostRepo struct {
···
-
// Convert content labels to PostgreSQL array
-
var labelsArray pq.StringArray
if post.ContentLabels != nil {
-
// Parse JSON array string to []string
-
if err := json.Unmarshal([]byte(*post.ContentLabels), &labels); err == nil {
···
err := r.db.QueryRowContext(
post.URI, post.CID, post.RKey, post.AuthorDID, post.CommunityDID,
-
post.Title, post.Content, facetsJSON, embedJSON, labelsArray,
).Scan(&post.ID, &post.IndexedAt)
···
-
var facetsJSON, embedJSON sql.NullString
-
var contentLabels pq.StringArray
err := r.db.QueryRowContext(ctx, query, uri).Scan(
&post.ID, &post.URI, &post.CID, &post.RKey,
&post.AuthorDID, &post.CommunityDID,
-
&post.Title, &post.Content, &facetsJSON, &embedJSON, &contentLabels,
&post.CreatedAt, &post.EditedAt, &post.IndexedAt, &post.DeletedAt,
&post.UpvoteCount, &post.DownvoteCount, &post.Score, &post.CommentCount,
···
post.Embed = &embedJSON.String
-
if len(contentLabels) > 0 {
-
labelsJSON, marshalErr := json.Marshal(contentLabels)
-
labelsStr := string(labelsJSON)
-
post.ContentLabels = &labelsStr
···
"Coves/internal/core/posts"
type postgresPostRepo struct {
···
+
// Store content labels as JSONB
+
// post.ContentLabels contains com.atproto.label.defs#selfLabels JSON: {"values":[{"val":"nsfw","neg":false}]}
+
// Store the full JSON blob to preserve the 'neg' field and future extensions
+
var labelsJSON sql.NullString
if post.ContentLabels != nil {
+
labelsJSON.String = *post.ContentLabels
+
labelsJSON.Valid = true
···
err := r.db.QueryRowContext(
post.URI, post.CID, post.RKey, post.AuthorDID, post.CommunityDID,
+
post.Title, post.Content, facetsJSON, embedJSON, labelsJSON,
).Scan(&post.ID, &post.IndexedAt)
···
+
var facetsJSON, embedJSON, labelsJSON sql.NullString
err := r.db.QueryRowContext(ctx, query, uri).Scan(
&post.ID, &post.URI, &post.CID, &post.RKey,
&post.AuthorDID, &post.CommunityDID,
+
&post.Title, &post.Content, &facetsJSON, &embedJSON, &labelsJSON,
&post.CreatedAt, &post.EditedAt, &post.IndexedAt, &post.DeletedAt,
&post.UpvoteCount, &post.DownvoteCount, &post.Score, &post.CommentCount,
···
post.Embed = &embedJSON.String
+
// Labels are stored as JSONB containing full com.atproto.label.defs#selfLabels structure
+
post.ContentLabels = &labelsJSON.String