Initial commit: teaching institution management API.
Express/MongoDB backend with JWT auth, RBAC, S3 uploads, notifications, and scheduled jobs.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
// /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);
|
||||
Reference in New Issue
Block a user