30 lines
874 B
JavaScript
30 lines
874 B
JavaScript
const mongoose = require('mongoose')
|
|
|
|
// جلوگیری از نوتیف تکراری برای یک کاربر دربارهی یک پست خاص — سبک و موقت (۳۰ روز TTL)،
|
|
// شبیه نقشی که ExploreInteractionModel برای ردیابی سبک بازی میکنه
|
|
const smartNotificationLogSchema = new mongoose.Schema({
|
|
user_id: {
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
ref: 'User',
|
|
required: true
|
|
},
|
|
post_id: {
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
ref: 'Post',
|
|
required: true
|
|
},
|
|
type: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
createdAt: {
|
|
type: Date,
|
|
default: Date.now,
|
|
expires: 60 * 60 * 24 * 30 // ۳۰ روز
|
|
}
|
|
})
|
|
|
|
smartNotificationLogSchema.index({ user_id: 1, post_id: 1, type: 1 }, { unique: true })
|
|
|
|
module.exports = mongoose.model('SmartNotificationLog', smartNotificationLogSchema)
|