2023-03-15 23:42:35 +01:00
|
|
|
const { DataTypes, Model } = require('sequelize')
|
|
|
|
|
|
|
|
module.exports = (sequelize) => {
|
|
|
|
class Notification extends Model { }
|
|
|
|
|
|
|
|
Notification.init({
|
|
|
|
id: {
|
|
|
|
type: DataTypes.UUID,
|
|
|
|
defaultValue: DataTypes.UUIDV4,
|
|
|
|
primaryKey: true
|
|
|
|
},
|
|
|
|
eventName: DataTypes.STRING,
|
2023-03-18 22:56:57 +01:00
|
|
|
urls: DataTypes.JSON, // JSON array of urls
|
2023-03-15 23:42:35 +01:00
|
|
|
titleTemplate: DataTypes.STRING(1000),
|
|
|
|
bodyTemplate: DataTypes.TEXT,
|
|
|
|
type: DataTypes.STRING,
|
|
|
|
lastFiredAt: DataTypes.DATE,
|
|
|
|
lastAttemptFailed: DataTypes.BOOLEAN,
|
|
|
|
numConsecutiveFailedAttempts: DataTypes.INTEGER,
|
|
|
|
numTimesFired: DataTypes.INTEGER,
|
2023-03-18 22:56:57 +01:00
|
|
|
enabled: DataTypes.BOOLEAN,
|
|
|
|
extraData: DataTypes.JSON
|
2023-03-15 23:42:35 +01:00
|
|
|
}, {
|
|
|
|
sequelize,
|
|
|
|
modelName: 'Notification'
|
|
|
|
})
|
|
|
|
|
|
|
|
return Notification
|
|
|
|
}
|