Built motion from commit c2984ba.|0.0.114
[motion.git] / server / models / tools_trunk.js
1 'use strict';
2
3 var crypto = require('crypto');
4 var md5 = require('md5');
5 var _ = require('lodash');
6
7 module.exports = function(sequelize, DataTypes) {
8   var Trunk = sequelize.define('Trunk', {
9     name: {
10       type: DataTypes.STRING,
11       primaryKey: true,
12       validate: {
13         notEmpty: true,
14         is: /^[A-Za-z0-9\.\_]+$/i
15       }
16     },
17     type: {
18       type: DataTypes.ENUM('friend', 'user', 'peer'),
19       allowNull: true,
20       defaultValue: 'friend'
21     },
22     context: {
23       type: DataTypes.STRING,
24       defaultValue: 'from-voip-provider'
25     },
26     callingpres: {
27       type: DataTypes.ENUM('ALLOWED_NOT_SCREENED',
28         'ALLOWED_PASSED_SCREEN', 'ALLOWED_FAILED_SCREEN', 'ALLOWED',
29         'PROHIB_NOT_SCREENED', 'PROHIB_PASSED_SCREEN',
30         'PROHIB_FAILED_SCREEN', 'PROHIB'),
31       allowNull: true,
32     },
33     permit: {
34       type: DataTypes.STRING,
35       allowNull: true,
36     },
37     deny: {
38       type: DataTypes.STRING,
39       allowNull: true,
40     },
41     secret: {
42       type: DataTypes.STRING,
43       allowNull: true,
44     },
45     md5secret: {
46       type: DataTypes.STRING,
47       allowNull: true,
48     },
49     remotesecret: {
50       type: DataTypes.STRING,
51       allowNull: true,
52     },
53     transport: {
54       type: DataTypes.STRING,
55       allowNull: true,
56       defaultValue: 'udp'
57     },
58     dtmfmode: {
59       type: DataTypes.ENUM('rfc2833', 'info', 'shortinfo', 'inband',
60         'auto'),
61       allowNull: true,
62       defaultValue: 'rfc2833'
63     },
64     directmedia: {
65       type: DataTypes.ENUM('yes', 'no', 'nonat', 'update', 'outgoing'),
66       allowNull: true,
67       defaultValue: 'no'
68     },
69     directrtpsetup: {
70       type: DataTypes.ENUM('yes', 'no'),
71       allowNull: true,
72       defaultValue: 'no'
73     },
74     directmediapermit: {
75       type: DataTypes.STRING,
76       allowNull: true,
77     },
78     directmediadeny: {
79       type: DataTypes.STRING,
80       allowNull: true,
81     },
82     nat: {
83       type: DataTypes.STRING,
84       allowNull: true,
85       defaultValue: 'force_rport,comedia'
86     },
87     callgroup: {
88       type: DataTypes.STRING,
89       allowNull: true,
90     },
91     namedcallgroup: { //We are in named call groups engineering,sales,netgroup,protgroup
92       type: DataTypes.STRING,
93       allowNull: true,
94     },
95     pickupgroup: {
96       type: DataTypes.STRING,
97       allowNull: true,
98     },
99     namedpickupgroup: { //We can do call pick-p for named call group sales
100       type: DataTypes.STRING,
101       allowNull: true,
102     },
103     language: {
104       type: DataTypes.STRING,
105       allowNull: true,
106       defaultValue: 'en'
107     },
108     tonezone: {
109       type: DataTypes.STRING,
110       allowNull: true
111     },
112     disallow: {
113       type: DataTypes.STRING,
114       allowNull: true,
115       defaultValue: 'all'
116     },
117     allow: {
118       type: DataTypes.STRING,
119       allowNull: false,
120       defaultValue: 'alaw;ulaw;gsm'
121     },
122     autoframing: {
123       type: DataTypes.ENUM('yes', 'no'),
124       allowNull: true,
125     },
126     insecure: {
127       type: DataTypes.STRING,
128       allowNull: true,
129       defaultValue: 'port,invite'
130     },
131     trustrpid: {
132       type: DataTypes.ENUM('yes', 'no'),
133       allowNull: true,
134       defaultValue: 'no'
135     },
136     trust_id_outbound: {
137       type: DataTypes.ENUM('yes', 'no'),
138       allowNull: true,
139       defaultValue: 'no'
140     },
141     progressinband: {
142       type: DataTypes.ENUM('yes', 'no', 'never'),
143       allowNull: true,
144     },
145     promiscredir: {
146       type: DataTypes.ENUM('yes', 'no'),
147       allowNull: true,
148     },
149     useclientcode: {
150       type: DataTypes.ENUM('yes', 'no'),
151       allowNull: true,
152     },
153     accountcode: {
154       type: DataTypes.INTEGER(11),
155       allowNull: true,
156     },
157     setvar: {
158       type: DataTypes.STRING,
159       allowNull: true,
160     },
161     callerid: {
162       type: DataTypes.STRING,
163       allowNull: true,
164       defaultValue: '"" <>'
165     },
166     amaflags: {
167       type: DataTypes.STRING,
168       allowNull: true,
169     },
170     callcounter: {
171       type: DataTypes.ENUM('yes', 'no'),
172       allowNull: true,
173       defaultValue: 'yes'
174     },
175     busylevel: {
176       type: DataTypes.INTEGER(11),
177       allowNull: true,
178     },
179     allowoverlap: {
180       type: DataTypes.ENUM('yes', 'no'),
181       allowNull: true,
182     },
183     allowsubscribe: {
184       type: DataTypes.ENUM('yes', 'no'),
185       allowNull: true,
186     },
187     allowtransfer: {
188       type: DataTypes.ENUM('yes', 'no'),
189       allowNull: true,
190     },
191     ignoresdpversion: {
192       type: DataTypes.ENUM('yes', 'no'),
193       allowNull: true,
194     },
195     subscribecontext: {
196       type: DataTypes.STRING,
197       allowNull: true,
198     },
199     template: {
200       type: DataTypes.STRING,
201       allowNull: true,
202     },
203     videosupport: {
204       type: DataTypes.ENUM('yes', 'no', 'always'),
205       allowNull: true,
206       defaultValue: 'no'
207     },
208     maxcallbitrate: {
209       type: DataTypes.INTEGER(11),
210       allowNull: true,
211     },
212     rfc2833compensate: {
213       type: DataTypes.ENUM('yes', 'no'),
214       allowNull: true,
215     },
216     mailbox: {
217       type: DataTypes.STRING,
218       allowNull: true,
219     },
220     session_timers: {
221       type: DataTypes.ENUM('accept', 'refuse', 'originate'),
222       allowNull: true,
223     },
224     session_expires: {
225       type: DataTypes.INTEGER(11),
226       allowNull: true,
227     },
228     session_minse: {
229       type: DataTypes.INTEGER(11),
230       allowNull: true,
231     },
232     session_refresher: {
233       type: DataTypes.ENUM('uac', 'uas'),
234       allowNull: true,
235       defaultValue: 'uas'
236     },
237     t38pt_usertpsource: {
238       type: DataTypes.STRING,
239       allowNull: true,
240     },
241     regexten: {
242       type: DataTypes.STRING,
243       allowNull: true,
244     },
245     fromdomain: {
246       type: DataTypes.STRING,
247       allowNull: true,
248     },
249     fromuser: {
250       type: DataTypes.STRING,
251       allowNull: true,
252     },
253     host: {
254       type: DataTypes.STRING,
255       allowNull: true,
256       defaultValue: 'dynamic'
257     },
258     port: {
259       type: DataTypes.INTEGER(5),
260       allowNull: true,
261     },
262     qualify: {
263       type: DataTypes.ENUM('yes', 'no'),
264       allowNull: true,
265       defaultValue: 'yes'
266     },
267     keepalive: {
268       type: DataTypes.INTEGER(11),
269       allowNull: true,
270     },
271     defaultip: {
272       type: DataTypes.STRING,
273       allowNull: true,
274     },
275     defaultuser: {
276       type: DataTypes.STRING,
277       allowNull: true,
278     },
279     rtptimeout: { // Terminate call if 60 seconds of no RTP or RTCP activity on the audio channel  when we're not on hold.
280       type: DataTypes.INTEGER(11),
281       allowNull: true,
282     },
283     rtpholdtimeout: { // Terminate call if 300 seconds of no RTP or RTCP activity on the audio channel when we're on hold (must be > rtptimeout)
284       type: DataTypes.INTEGER(11),
285       allowNull: true,
286     },
287     rtpkeepalive: { // Send keepalives in the RTP stream to keep NAT open (default is off - zero)
288       type: DataTypes.INTEGER(11),
289       allowNull: true,
290     },
291     sendrpid: {
292       type: DataTypes.ENUM('yes', 'no'),
293       allowNull: true,
294       defaultValue: 'no'
295     },
296     outboundproxy: {
297       type: DataTypes.STRING,
298       allowNull: true,
299     },
300     callbackextension: {
301       type: DataTypes.STRING,
302       allowNull: true,
303     },
304     timert1: {
305       type: DataTypes.INTEGER(11),
306       allowNull: true,
307     },
308     timerb: {
309       type: DataTypes.INTEGER(11),
310       allowNull: true,
311     },
312     qualifyfreq: {
313       type: DataTypes.INTEGER(11),
314       allowNull: true,
315     },
316     contactpermit: {
317       type: DataTypes.STRING,
318       allowNull: true,
319     },
320     contactdeny: {
321       type: DataTypes.STRING,
322       allowNull: true,
323     },
324     contactacl: {
325       type: DataTypes.STRING,
326       allowNull: true,
327     },
328     unsolicited_mailbox: {
329       type: DataTypes.STRING,
330       allowNull: true,
331     },
332     use_q850_reason: {
333       type: DataTypes.STRING,
334       allowNull: true,
335     },
336     maxforwards: {
337       type: DataTypes.INTEGER(11),
338       allowNull: true,
339     },
340     encryption: {
341       type: DataTypes.ENUM('yes', 'no'),
342       allowNull: true,
343       defaultValue: 'no'
344     },
345     avpf: {
346       type: DataTypes.ENUM('yes', 'no'),
347       allowNull: true
348     },
349     force_avp: {
350       type: DataTypes.ENUM('yes', 'no'),
351       allowNull: true
352     },
353     icesupport: {
354       type: DataTypes.ENUM('yes', 'no'),
355       allowNull: true
356     },
357     dtlsenable: {
358       type: DataTypes.ENUM('yes', 'no'),
359       allowNull: true
360     },
361     dtlsverify: {
362       type: DataTypes.ENUM('yes', 'no', 'fingerprint', 'certificate'),
363       allowNull: true
364     },
365     dtlsrekey: {
366       type: DataTypes.INTEGER(11),
367       allowNull: true,
368     },
369     dtlscertfile: {
370       type: DataTypes.STRING,
371       allowNull: true,
372     },
373     dtlsprivatekey: {
374       type: DataTypes.STRING,
375       allowNull: true,
376     },
377     dtlscipher: {
378       type: DataTypes.STRING,
379       allowNull: true,
380     },
381     dtlscafile: {
382       type: DataTypes.STRING,
383       allowNull: true,
384     },
385     dtlscapath: {
386       type: DataTypes.STRING,
387       allowNull: true,
388     },
389     dtlssetup: {
390       type: DataTypes.ENUM('active', 'passive', 'actpass'),
391       allowNull: true
392     },
393     dtlsfingerprint: {
394       type: DataTypes.STRING,
395       allowNull: true,
396     },
397     usereqphone: { //This provider requires ";user=phone" on URI
398       type: DataTypes.ENUM('yes', 'no'),
399       allowNull: true,
400       defaultValue: 'no'
401     },
402     recordonfeature: { //Feature to use when INFO with Record: on is received.
403       type: DataTypes.STRING,
404       allowNull: true,
405     },
406     recordofffeature: { //Feature to use when INFO with Record: off is received.
407       type: DataTypes.STRING,
408       allowNull: true,
409     },
410     call_limit: {
411       type: DataTypes.INTEGER(11),
412       allowNull: true,
413       defaultValue: null
414     },
415     registertrying: { //Send a 100 Trying when the device registers.
416       type: DataTypes.ENUM('yes', 'no'),
417       allowNull: true,
418     },
419     subscribemwi: { //Only send notifications if this phone subscribes for mailbox notification
420       type: DataTypes.ENUM('yes', 'no'),
421       allowNull: true,
422     },
423     vmexten: { // dialplan extension to reach mailbox. defaults to global vmexten which defaults to "asterisk"
424       type: DataTypes.STRING,
425       allowNull: true,
426     },
427     mohinterpret: { // This option specifies a preference for which music on hold class this channel should listen to when put on hold
428       type: DataTypes.STRING,
429       allowNull: true,
430     },
431     mohsuggest: { //  This option specifies which music on hold class to suggest to the peer channel when this channel places the peer on hold.
432       type: DataTypes.STRING,
433       allowNull: true,
434     },
435     parkinglot: {
436       type: DataTypes.STRING,
437       allowNull: true,
438     },
439     description: {
440       type: DataTypes.STRING,
441       allowNull: true,
442     },
443     canreinvite: {
444       type: DataTypes.ENUM('yes', 'no', 'nonat', 'update', 'update,nonat'),
445       allowNull: true,
446       defaultValue: 'no'
447     },
448     registry: {
449       type: DataTypes.STRING,
450       allowNull: true,
451     },
452     otherFields: {
453       type: DataTypes.STRING,
454       allowNull: true,
455     },
456     active: {
457       type: DataTypes.BOOLEAN,
458       defaultValue: true
459     },
460     status: {
461       type: DataTypes.STRING
462     },
463     peerstatus: {
464       type: DataTypes.STRING
465     }
466   }, {
467     tableName: 'tools_trunks'
468   });
469
470   Trunk.beforeUpdate(function(doc) {
471     if (doc.changed('name')) {
472       throw new Error("You can't modify a trunk name");
473     }
474   });
475
476   return Trunk;
477 }