-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
+'use strict';
module.exports = function(sequelize, DataTypes) {
tech: {
type: DataTypes.ENUM('SIP', 'IAX', 'DADHI', 'KHOMP'),
defaultValue: 'SIP'
- }
+ },
+ fidelity: {
+ type: DataTypes.BOOLEAN,
+ defaultValue: false
+ },
+ timeout: {
+ type: DataTypes.INTEGER,
+ defaultValue: 0
+ },
+ acceptUrl: {
+ type: DataTypes.STRING
+ },
+ rejectUrl: {
+ type: DataTypes.STRING
+ },
+ acceptMethod: {
+ type: DataTypes.ENUM('GET', 'POST')
+ },
+ rejectMethod: {
+ type: DataTypes.ENUM('GET', 'POST')
+ },
+ actions: {
+ type: DataTypes.STRING,
+ get: function() {
+ return this.getDataValue('actions') ? JSON.parse(this.getDataValue('actions')) : [];
+ },
+ set: function(val) {
+ return this.setDataValue('actions', JSON.stringify(val));
+ }
+ },
+ closeUrl: {
+ type: DataTypes.STRING
+ },
+ closeMethod: {
+ type: DataTypes.ENUM('GET', 'POST')
+ },
}, {
tableName: 'fax_accounts',
associate: function(models) {
FaxAccount.belongsTo(models.Trunk);
FaxAccount.hasMany(models.FaxRoom);
FaxAccount.hasMany(models.FaxApplication);
+ FaxAccount.hasMany(models.VoiceExtension, {
+ onDelete: 'cascade',
+ hooks: true
+ });
+ FaxAccount.belongsTo(models.List);
+ FaxAccount.hasMany(models.FaxDisposition);
+
+ // SCOPES
+ FaxAccount.addScope('default', {
+ include: [{
+ model: models.FaxApplication,
+ include: [{
+ model: models.User,
+ attributes: ['id',
+ 'name',
+ 'email',
+ 'internal',
+ 'fullname'
+ ]
+ }, {
+ model: models.FaxQueue
+ }]
+ }]
+ });
}
});