mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
34 lines
2.1 KiB
JavaScript
34 lines
2.1 KiB
JavaScript
/***********************************************************************************************************************************************************************
|
|
* File Name: email_broadcast_recipient.mdl.js
|
|
* Type of Program: Model
|
|
* Description: The outbox — one row per recipient of an email_broadcasts job.
|
|
* `email` is snapshotted at enqueue time so a later change to the
|
|
* user's account email doesn't affect an in-flight broadcast.
|
|
* cron/jobs/dispatch_email_broadcasts.cron.js is the only writer
|
|
* of `status`/`error`/`sent_at` after creation.
|
|
* Author: Kenneth Obsequio (@lash0000)
|
|
* Date Created: Jul. 3, 2026
|
|
***********************************************************************************************************************************************************************/
|
|
const { DataTypes } = require('sequelize');
|
|
const sequelize = require('../../config/db.config');
|
|
const mdl_EmailBroadcast = require('./email_broadcast.mdl');
|
|
|
|
const mdl_EmailBroadcastRecipient = sequelize.define('EmailBroadcastRecipient', {
|
|
email_broadcast_recipient_id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true, label: 'ID', hidden: true, order: 0 },
|
|
email_broadcast_id: { type: DataTypes.BIGINT, allowNull: false, label: 'Broadcast', order: 1 },
|
|
user_id: { type: DataTypes.BIGINT, allowNull: true, label: 'User', order: 2 },
|
|
email: { type: DataTypes.STRING(255), allowNull: false, label: 'Email', order: 3 },
|
|
name: { type: DataTypes.STRING(255), allowNull: true, label: 'Name', order: 4 },
|
|
status: { type: DataTypes.ENUM('pending', 'sent', 'failed'), allowNull: false, defaultValue: 'pending', label: 'Status', order: 5, filterable: true },
|
|
error: { type: DataTypes.TEXT, allowNull: true, label: 'Error', order: 6 },
|
|
sent_at: { type: DataTypes.DATE, allowNull: true, label: 'Sent At', order: 7 },
|
|
}, {
|
|
tableName: 'email_broadcast_recipients',
|
|
timestamps: true,
|
|
paranoid: false,
|
|
});
|
|
|
|
mdl_EmailBroadcastRecipient.belongsTo(mdl_EmailBroadcast, { as: 'broadcast', foreignKey: 'email_broadcast_id' });
|
|
|
|
module.exports = mdl_EmailBroadcastRecipient;
|