25 lines
1.1 KiB
JavaScript
25 lines
1.1 KiB
JavaScript
const mongoose = require('mongoose')
|
|
const timestamp = require('mongoose-timestamp')
|
|
|
|
const autoDirectRuleSchema = new mongoose.Schema({
|
|
user_id: {
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
ref: 'User',
|
|
required: true
|
|
},
|
|
trigger_text: { type: String, required: true, trim: true },
|
|
direct_message: { type: String, required: true, trim: true },
|
|
reply_caption: { type: String, required: true, trim: true },
|
|
is_active: { type: Boolean, default: true },
|
|
// هر بار این قانون واقعاً اجرا بشه (دایرکت ارسال + کامنتِ پاسخ ثبت بشه) یکی زیاد میشه —
|
|
// برای نمایشِ «تعداد کامنتهای ارسالی» توی لیستِ AutoDirectScreen.tsx
|
|
sent_count: { type: Number, default: 0 }
|
|
})
|
|
|
|
// autoDirectTrigger.js هر کامنتِ تازه رو در برابرِ همهی قانونهای فعالِ صاحبِ پست چک میکنه
|
|
autoDirectRuleSchema.index({ user_id: 1, is_active: 1 })
|
|
|
|
autoDirectRuleSchema.plugin(timestamp)
|
|
const AutoDirectRuleModel = mongoose.model('AutoDirectRule', autoDirectRuleSchema)
|
|
module.exports = AutoDirectRuleModel
|