Built motion from commit 1020cd7.|0.0.107
[motion.git] / server / models / fax_account.js
1 /**
2  * Chat Website Model
3  */
4
5 var crypto = require('crypto');
6
7 module.exports = function(sequelize, DataTypes) {
8
9         var FaxAccount = sequelize.define('FaxAccount', {
10                 name: {
11                         type: DataTypes.STRING,
12                         validate: {
13                                 notEmpty: true
14                         }
15                 },
16                 description: DataTypes.STRING,
17                 ecm: {
18                         type: DataTypes.ENUM('yes', 'no'),
19                         defaultValue: 'yes'
20                 },
21                 headerinfo: {
22                         type: DataTypes.STRING,
23                         defaultValue: 'xCALLY Motion Fax'
24                 },
25                 localstationid: {
26                         type: DataTypes.STRING,
27                         unique: true
28                 },
29                 minrate: {
30                         type: DataTypes.ENUM('2400', '4800', '7200', '9600', '12000', '14400'),
31                         defaultValue: '4800'
32                 },
33                 maxrate: {
34                         type: DataTypes.ENUM('2400', '4800', '7200', '9600', '12000', '14400'),
35                         defaultValue: '14400'
36                 },
37                 modem: {
38                         type: DataTypes.STRING,
39                         defaultValue: 'v17,v27,v29'
40                 },
41                 gateway: {
42                         type: DataTypes.STRING,
43                         defaultValue: 'no',
44                         validate: {
45                                 is: /^(?:yes|no|[0-9]+)$/
46                         }
47                 },
48                 faxdetect: {
49                         type: DataTypes.STRING,
50                         defaultValue: 'no',
51                         validate: {
52                                 is: /^(?:yes|no|t38|cng|[0-9]+)$/
53                         }
54                 },
55                 t38timeout: {
56                         type: DataTypes.INTEGER,
57                         defaultValue: 5000,
58                         validate: {
59                                 min: 1000
60                         }
61                 },
62                 tech: {
63                         type: DataTypes.ENUM('SIP', 'IAX', 'DADHI', 'KHOMP'),
64                         defaultValue: 'SIP'
65                 },
66                 fidelity: {
67                         type: DataTypes.BOOLEAN,
68                         defaultValue: false
69                 },
70                 timeout: {
71                         type: DataTypes.INTEGER,
72                         defaultValue: 0
73                 }
74         }, {
75                 tableName: 'fax_accounts',
76                 associate: function(models) {
77                         FaxAccount.belongsTo(models.Trunk);
78                         FaxAccount.hasMany(models.FaxRoom);
79                         FaxAccount.hasMany(models.FaxApplication);
80                         FaxAccount.hasMany(models.VoiceExtension, {
81                                 onDelete: 'cascade',
82                                 hooks: true
83                         });
84                         FaxAccount.belongsTo(models.List);
85                         FaxAccount.hasMany(models.FaxDisposition);
86
87                         // SCOPES
88                         FaxAccount.addScope('default', {
89                                 include: [{
90                                         model: models.FaxApplication,
91                                         include: [{
92                                                 model: models.User,
93                                                 attributes: ['id',
94                                                         'name',
95                                                         'email',
96                                                         'internal',
97                                                         'fullname'
98                                                 ]
99                                         }, {
100                                                 model: models.FaxQueue
101                                         }]
102                                 }]
103                         });
104
105                 }
106         });
107
108         return FaxAccount;
109 };