full
This commit is contained in:
29
models/SmartNotificationLogModel.js
Normal file
29
models/SmartNotificationLogModel.js
Normal file
@@ -0,0 +1,29 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user