diff --git a/lexicons/so/sprk/feed/like.json b/lexicons/so/sprk/feed/like.json index 8723637..c7a3d3a 100644 --- a/lexicons/so/sprk/feed/like.json +++ b/lexicons/so/sprk/feed/like.json @@ -4,7 +4,7 @@ "defs": { "main": { "type": "record", - "description": "Record declaring a 'like' of a piece of subject content.", + "description": "Record declaring a 'like' of a piece of subject content. Duplicate likes from the same author to the same subject will be ignored by the AppView.", "key": "tid", "record": { "type": "object", diff --git a/services/ingester/src/db/models.ts b/services/ingester/src/db/models.ts index 4b84cdc..8495512 100644 --- a/services/ingester/src/db/models.ts +++ b/services/ingester/src/db/models.ts @@ -22,6 +22,9 @@ export const likeSchema = new Schema({ cid: { type: String, required: true }, }) +// Add compound index to prevent duplicate likes +likeSchema.index({ authorDid: 1, subject: 1 }, { unique: true }) + export interface LookDocument extends Document { uri: string subject: string