// /components/notifications/notificationModel.js const mongoose = require('mongoose'); const notificationSchema = new mongoose.Schema({ user: { type: mongoose.Schema.Types.ObjectId, ref: 'User', index: true }, channel: { type: String, enum: ['email', 'sms', 'baleBot'], required: true }, subject: { type: String, trim: true }, body: { type: String, required: true, trim: true }, status: { type: String, enum: ['pending', 'sent', 'delivered', 'failed', 'retrying'], default: 'pending', index: true }, retryCount: { type: Number, default: 0 }, maxRetries: { type: Number, default: 3 }, lastError: { type: String, trim: true }, sentAt: { type: Date }, deliveredAt: { type: Date }, relatedEvent: { type: String, trim: true } }, { timestamps: true }); module.exports = mongoose.model('Notification', notificationSchema);