Built motion from commit 1038d87.|0.0.141
[motion.git] / server / models / fax_account.js
index e0c3907..0c47fad 100644 (file)
@@ -1 +1,131 @@
-var _0xab43=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x53\x54\x52\x49\x4E\x47","\x42\x4F\x4F\x4C\x45\x41\x4E","\x39\x36\x30\x30","\x31\x34\x34\x30\x30","\x33\x33\x36\x30\x30","\x66\x61\x78\x5F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x68\x61\x73\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0xab43[0]);module[_0xab43[1]]=function(_0xf090x2,_0xf090x3){var _0xf090x4=_0xf090x2[_0xab43[10]](_0xab43[2],{description:_0xf090x3[_0xab43[3]],name:_0xf090x3[_0xab43[3]],phone:{type:_0xf090x3[_0xab43[3]],unique:true},ecm:{type:_0xf090x3[_0xab43[4]],defaultValue:false},faxheader:_0xf090x3[_0xab43[3]],localid:_0xf090x3[_0xab43[3]],maxrate:{type:_0xf090x3.ENUM(_0xab43[5],_0xab43[6],_0xab43[7]),defaultValue:_0xab43[7]},minrate:{type:_0xf090x3.ENUM(_0xab43[5],_0xab43[6],_0xab43[7]),defaultValue:_0xab43[5]}},{tableName:_0xab43[8],associate:function(_0xf090x5){_0xf090x4[_0xab43[9]](_0xf090x5.FaxRoom);_0xf090x4[_0xab43[9]](_0xf090x5.FaxApplication)}});return _0xf090x4}
\ No newline at end of file
+'use strict';
+
+module.exports = function(sequelize, DataTypes) {
+
+       var FaxAccount = sequelize.define('FaxAccount', {
+               name: {
+                       type: DataTypes.STRING,
+                       validate: {
+                               notEmpty: true
+                       }
+               },
+               description: DataTypes.STRING,
+               ecm: {
+                       type: DataTypes.ENUM('yes', 'no'),
+                       defaultValue: 'yes'
+               },
+               headerinfo: {
+                       type: DataTypes.STRING,
+                       defaultValue: 'xCALLY Motion Fax'
+               },
+               localstationid: {
+                       type: DataTypes.STRING,
+                       unique: true
+               },
+               minrate: {
+                       type: DataTypes.ENUM('2400', '4800', '7200', '9600', '12000', '14400'),
+                       defaultValue: '4800'
+               },
+               maxrate: {
+                       type: DataTypes.ENUM('2400', '4800', '7200', '9600', '12000', '14400'),
+                       defaultValue: '14400'
+               },
+               modem: {
+                       type: DataTypes.STRING,
+                       defaultValue: 'v17,v27,v29'
+               },
+               gateway: {
+                       type: DataTypes.STRING,
+                       defaultValue: 'no',
+                       validate: {
+                               is: /^(?:yes|no|[0-9]+)$/
+                       }
+               },
+               faxdetect: {
+                       type: DataTypes.STRING,
+                       defaultValue: 'no',
+                       validate: {
+                               is: /^(?:yes|no|t38|cng|[0-9]+)$/
+                       }
+               },
+               t38timeout: {
+                       type: DataTypes.INTEGER,
+                       defaultValue: 5000,
+                       validate: {
+                               min: 1000
+                       }
+               },
+               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
+                                       }]
+                               }]
+                       });
+               }
+       });
+
+       return FaxAccount;
+};