Built motion from commit 7afcba0.|0.0.74
[motion.git] / server / models / user.js
1 'use strict';
2
3 var crypto = require('crypto');
4 var md5 = require('md5');
5 var _ = require('lodash');
6 var moment = require('moment');
7 var VoiceQueue = require('.').VoiceQueue;
8
9 module.exports = function(sequelize, DataTypes) {
10   var User = sequelize.define('User', {
11     name: {
12       type: DataTypes.STRING,
13       unique: true,
14       validate: {
15         notEmpty: true,
16         is: /^[A-Za-z0-9\.\_]+$/i
17       },
18       set: function(name) {
19         this.setDataValue('name', name);
20         this.setDataValue('defaultuser', name);
21       }
22     },
23     fullname: {
24       type: DataTypes.STRING,
25       allowNull: false,
26     },
27     email: {
28       type: DataTypes.STRING,
29       unique: true,
30       isEmail: true,
31       set: function(email) {
32         if (email) {
33           this.setDataValue('email', email.toLowerCase());
34         }
35       },
36       defaultValue: null
37     },
38     role: {
39       type: DataTypes.ENUM('admin', 'user', 'agent', 'telephone')
40     },
41     password: {
42       type: DataTypes.STRING,
43       allowNull: false,
44       validate: {
45         notEmpty: true
46       },
47       set: function(password) {
48         this.salt = this.makeSalt();
49         this.setDataValue('password', this.encryptPassword(password));
50         this.setDataValue('md5secret', this.md5Password(this.name + ':asterisk:' + password));
51       }
52     },
53     provider: {
54       type: DataTypes.STRING,
55       defaultValue: 'local'
56     },
57     internal: {
58       type: DataTypes.INTEGER(11),
59       unique: true,
60       set: function(internal) {
61         this.setDataValue('internal', internal);
62         this.setDataValue('accountcode', internal);
63       }
64     },
65     salt: {
66       type: DataTypes.STRING
67     },
68     phone: {
69       type: DataTypes.STRING
70     },
71     mobile: {
72       type: DataTypes.STRING
73     },
74     address: {
75       type: DataTypes.STRING
76     },
77     zipcode: {
78       type: DataTypes.STRING
79     },
80     userpic: {
81       type: DataTypes.STRING
82     },
83     city: {
84       type: DataTypes.STRING
85     },
86     country: {
87       type: DataTypes.STRING
88     },
89     online: {
90       type: DataTypes.BOOLEAN,
91       defaultValue: false
92     },
93     lastLoginAt: {
94       type: DataTypes.DATE
95     },
96     status: {
97       type: DataTypes.STRING,
98       defaultValue: 'UNKNOWN'
99     },
100     statusAt: {
101       type: DataTypes.DATE
102     },
103     queueStatus: {
104       type: DataTypes.STRING,
105       defaultValue: 'complete'
106     },
107     queueStatusAt: {
108       type: DataTypes.DATE
109     },
110     lastQueue: {
111       type: DataTypes.STRING
112     },
113     voicePause: {
114       type: DataTypes.BOOLEAN,
115       defaultValue: false,
116       set: function(voicePause) {
117         this.setDataValue('voicePause', voicePause);
118         if (voicePause) {
119           this.setDataValue('queueStatus', 'paused');
120           this.setDataValue('queueStatusAt', moment().format("YYYY-MM-DD HH:mm:ss"));
121         } else {
122           this.setDataValue('queueStatus', 'complete');
123           this.setDataValue('queueStatusAt', moment().format("YYYY-MM-DD HH:mm:ss"));
124         }
125       }
126     },
127     chatPause: {
128       type: DataTypes.BOOLEAN,
129       defaultValue: false
130     },
131     mailPause: {
132       type: DataTypes.BOOLEAN,
133       defaultValue: false
134     },
135     faxPause: {
136       type: DataTypes.BOOLEAN,
137       defaultValue: false
138     },
139     smsPause: {
140       type: DataTypes.BOOLEAN,
141       defaultValue: false
142     },
143     pauseType: {
144       type: DataTypes.STRING,
145       defaultValue: 'Default Pause'
146     },
147     lastPauseAt: {
148       type: DataTypes.DATE
149     },
150     chatCapacity: {
151       type: DataTypes.INTEGER,
152       defaultValue: 0
153     },
154     mailCapacity: {
155       type: DataTypes.INTEGER,
156       defaultValue: 0
157     },
158     faxCapacity: {
159       type: DataTypes.INTEGER,
160       defaultValue: 0
161     },
162     smsCapacity: {
163       type: DataTypes.INTEGER,
164       defaultValue: 0
165     },
166     phoneBarAutoAnswer: {
167       type: DataTypes.BOOLEAN,
168       defaultValue: false
169     },
170     phoneBarEnableSettings: {
171       type: DataTypes.BOOLEAN,
172       defaultValue: true
173     },
174     phoneBarUnconditionalNumber: {
175       type: DataTypes.STRING,
176       get: function() {
177         if (this.getDataValue('phoneBarUnconditional')) {
178           return this.getDataValue('phoneBarUnconditionalNumber');
179         }
180         return null;
181       }
182     },
183     phoneBarNoReplyNumber: {
184       type: DataTypes.STRING,
185       get: function() {
186         if (this.getDataValue('phoneBarNoReply')) {
187           return this.getDataValue('phoneBarNoReplyNumber');
188         }
189         return null;
190       }
191     },
192     phoneBarBusyNumber: {
193       type: DataTypes.STRING,
194       get: function() {
195         if (this.getDataValue('phoneBarBusy')) {
196           return this.getDataValue('phoneBarBusyNumber');
197         }
198         return null;
199       }
200     },
201     phoneBarUnconditional: {
202       type: DataTypes.BOOLEAN,
203       defaultValue: false
204     },
205     phoneBarNoReply: {
206       type: DataTypes.BOOLEAN,
207       defaultValue: false
208     },
209     phoneBarBusy: {
210       type: DataTypes.BOOLEAN,
211       defaultValue: false
212     },
213     phoneBarListenPort: {
214       type: DataTypes.INTEGER(5),
215       defaultValue: 5060
216     },
217     phoneBarECTail: {
218       type: DataTypes.INTEGER(5),
219       defaultValue: 200
220     },
221     phoneBarExpires: {
222       type: DataTypes.INTEGER(5),
223       defaultValue: 3600
224     },
225     phoneBarNameServer: {
226       type: DataTypes.STRING,
227       allowNull: true
228     },
229     phoneBarStunServer: {
230       type: DataTypes.STRING,
231       allowNull: true
232     },
233     phoneBarVADEnabled: {
234       type: DataTypes.BOOLEAN,
235       defaultValue: true
236     },
237     phoneBarNoUDP: {
238       type: DataTypes.BOOLEAN,
239       defaultValue: false
240     },
241     phoneBarNoTCP: {
242       type: DataTypes.BOOLEAN,
243       defaultValue: true
244     },
245     phoneBarLogLevel: {
246       type: DataTypes.INTEGER(5),
247       defaultValue: 1
248     },
249     phoneBarPublishEnabled: {
250       type: DataTypes.BOOLEAN,
251       defaultValue: false
252     },
253     chanspy: {
254       type: DataTypes.BOOLEAN,
255       defaultValue: false
256     },
257     description: {
258       type: DataTypes.STRING,
259       allowNull: true,
260     },
261     ipaddr: { //REALTIME ASTERISK
262       type: DataTypes.STRING,
263       allowNull: true,
264     },
265     port: { //REALTIME ASTERISK
266       type: DataTypes.INTEGER(5),
267       allowNull: true,
268     },
269     regseconds: { //REALTIME ASTERISK
270       type: DataTypes.INTEGER(11),
271       allowNull: true,
272     },
273     fullcontact: { //REALTIME ASTERISK
274       type: DataTypes.STRING,
275       allowNull: true,
276     },
277     regserver: { //REALTIME ASTERISK
278       type: DataTypes.STRING,
279       allowNull: true,
280     },
281     useragent: { //REALTIME ASTERISK
282       type: DataTypes.STRING,
283       allowNull: true,
284     },
285     lastms: { //REALTIME ASTERISK
286       type: DataTypes.INTEGER(11),
287       allowNull: true,
288     },
289     type: {
290       type: DataTypes.ENUM('friend', 'user', 'peer'),
291       allowNull: true,
292       defaultValue: 'friend'
293     },
294     context: {
295       type: DataTypes.STRING,
296       allowNull: true,
297       defaultValue: 'from-sip'
298     },
299     callingpres: {
300       type: DataTypes.ENUM('ALLOWED_NOT_SCREENED',
301         'ALLOWED_PASSED_SCREEN', 'ALLOWED_FAILED_SCREEN', 'ALLOWED',
302         'PROHIB_NOT_SCREENED', 'PROHIB_PASSED_SCREEN',
303         'PROHIB_FAILED_SCREEN', 'PROHIB'),
304       allowNull: true,
305     },
306     permit: {
307       type: DataTypes.STRING,
308       allowNull: true,
309     },
310     deny: {
311       type: DataTypes.STRING,
312       allowNull: true,
313     },
314     secret: {
315       type: DataTypes.STRING,
316       allowNull: true,
317     },
318     md5secret: {
319       type: DataTypes.STRING,
320       allowNull: true,
321     },
322     remotesecret: {
323       type: DataTypes.STRING,
324       allowNull: true,
325     },
326     transport: {
327       type: DataTypes.STRING,
328       allowNull: true,
329       defaultValue: 'udp'
330     },
331     dtmfmode: {
332       type: DataTypes.ENUM('rfc2833', 'info', 'shortinfo', 'inband',
333         'auto'),
334       allowNull: true,
335       defaultValue: 'rfc2833'
336     },
337     directmedia: {
338       type: DataTypes.ENUM('yes', 'no', 'nonat', 'update', 'outgoing'),
339       allowNull: true,
340       defaultValue: 'no'
341     },
342     directrtpsetup: {
343       type: DataTypes.ENUM('yes', 'no'),
344       allowNull: true,
345       defaultValue: 'no'
346     },
347     directmediapermit: {
348       type: DataTypes.STRING,
349       allowNull: true,
350     },
351     directmediadeny: {
352       type: DataTypes.STRING,
353       allowNull: true,
354     },
355     nat: {
356       type: DataTypes.STRING,
357       allowNull: true,
358       defaultValue: 'force_rport,comedia'
359     },
360     callgroup: {
361       type: DataTypes.STRING,
362       allowNull: true,
363     },
364     namedcallgroup: { //We are in named call groups engineering,sales,netgroup,protgroup
365       type: DataTypes.STRING,
366       allowNull: true,
367     },
368     pickupgroup: {
369       type: DataTypes.STRING,
370       allowNull: true,
371     },
372     namedpickupgroup: { //We can do call pick-p for named call group sales
373       type: DataTypes.STRING,
374       allowNull: true,
375     },
376     language: {
377       type: DataTypes.STRING,
378       allowNull: true,
379       defaultValue: 'en'
380     },
381     tonezone: {
382       type: DataTypes.STRING,
383       allowNull: true
384     },
385     allow: {
386       type: DataTypes.STRING,
387       allowNull: true,
388       defaultValue: 'alaw;ulaw;gsm'
389     },
390     disallow: {
391       type: DataTypes.STRING,
392       allowNull: true,
393       defaultValue: null
394     },
395     autoframing: {
396       type: DataTypes.ENUM('yes', 'no'),
397       allowNull: true,
398     },
399     insecure: {
400       type: DataTypes.STRING,
401       allowNull: true,
402       defaultValue: 'port,invite'
403     },
404     trustrpid: {
405       type: DataTypes.ENUM('yes', 'no'),
406       allowNull: true,
407       defaultValue: 'no'
408     },
409     trust_id_outbound: {
410       type: DataTypes.ENUM('yes', 'no'),
411       allowNull: true,
412       defaultValue: 'no'
413     },
414     progressinband: {
415       type: DataTypes.ENUM('yes', 'no', 'never'),
416       allowNull: true,
417     },
418     promiscredir: {
419       type: DataTypes.ENUM('yes', 'no'),
420       allowNull: true,
421     },
422     useclientcode: {
423       type: DataTypes.ENUM('yes', 'no'),
424       allowNull: true,
425     },
426     accountcode: {
427       type: DataTypes.INTEGER(11),
428       allowNull: true,
429     },
430     setvar: {
431       type: DataTypes.STRING,
432       allowNull: true,
433     },
434     callerid: {
435       type: DataTypes.STRING,
436       allowNull: true,
437       defaultValue: '"" <>'
438     },
439     amaflags: {
440       type: DataTypes.STRING,
441       allowNull: true,
442     },
443     callcounter: {
444       type: DataTypes.ENUM('yes', 'no'),
445       allowNull: true,
446       defaultValue: 'yes'
447     },
448     busylevel: {
449       type: DataTypes.INTEGER(11),
450       allowNull: true,
451     },
452     allowoverlap: {
453       type: DataTypes.ENUM('yes', 'no'),
454       allowNull: true,
455     },
456     allowsubscribe: {
457       type: DataTypes.ENUM('yes', 'no'),
458       allowNull: true,
459     },
460     allowtransfer: {
461       type: DataTypes.ENUM('yes', 'no'),
462       allowNull: true,
463     },
464     ignoresdpversion: {
465       type: DataTypes.ENUM('yes', 'no'),
466       allowNull: true,
467     },
468     subscribecontext: {
469       type: DataTypes.STRING,
470       allowNull: true,
471     },
472     template: {
473       type: DataTypes.STRING,
474       allowNull: true,
475     },
476     videosupport: {
477       type: DataTypes.ENUM('yes', 'no', 'always'),
478       allowNull: true,
479       defaultValue: 'no'
480     },
481     maxcallbitrate: {
482       type: DataTypes.INTEGER(11),
483       allowNull: true,
484     },
485     rfc2833compensate: {
486       type: DataTypes.ENUM('yes', 'no'),
487       allowNull: true,
488     },
489     mailbox: {
490       type: DataTypes.STRING,
491       allowNull: true,
492     },
493     session_timers: {
494       type: DataTypes.ENUM('accept', 'refuse', 'originate'),
495       allowNull: true,
496     },
497     session_expires: {
498       type: DataTypes.INTEGER(11),
499       allowNull: true,
500     },
501     session_minse: {
502       type: DataTypes.INTEGER(11),
503       allowNull: true,
504     },
505     session_refresher: {
506       type: DataTypes.ENUM('uac', 'uas'),
507       allowNull: true,
508       defaultValue: 'uas'
509     },
510     t38pt_usertpsource: {
511       type: DataTypes.STRING,
512       allowNull: true,
513     },
514     regexten: {
515       type: DataTypes.STRING,
516       allowNull: true,
517     },
518     fromdomain: {
519       type: DataTypes.STRING,
520       allowNull: true,
521     },
522     fromuser: {
523       type: DataTypes.STRING,
524       allowNull: true,
525     },
526     host: {
527       type: DataTypes.STRING,
528       allowNull: true,
529       defaultValue: 'dynamic'
530     },
531     qualify: {
532       type: DataTypes.ENUM('yes', 'no'),
533       allowNull: true,
534       defaultValue: 'yes'
535     },
536     keepalive: {
537       type: DataTypes.INTEGER(11),
538       allowNull: true,
539     },
540     defaultip: {
541       type: DataTypes.STRING,
542       allowNull: true,
543     },
544     defaultuser: {
545       type: DataTypes.STRING,
546       allowNull: true,
547     },
548     rtptimeout: { // Terminate call if 60 seconds of no RTP or RTCP activity on the audio channel  when we're not on hold.
549       type: DataTypes.INTEGER(11),
550       allowNull: true,
551     },
552     rtpholdtimeout: { // Terminate call if 300 seconds of no RTP or RTCP activity on the audio channel when we're on hold (must be > rtptimeout)
553       type: DataTypes.INTEGER(11),
554       allowNull: true,
555     },
556     rtpkeepalive: { // Send keepalives in the RTP stream to keep NAT open (default is off - zero)
557       type: DataTypes.INTEGER(11),
558       allowNull: true,
559     },
560     sendrpid: {
561       type: DataTypes.ENUM('yes', 'no'),
562       allowNull: true,
563       defaultValue: 'no'
564     },
565     outboundproxy: {
566       type: DataTypes.STRING,
567       allowNull: true,
568     },
569     callbackextension: {
570       type: DataTypes.STRING,
571       allowNull: true,
572     },
573     timert1: {
574       type: DataTypes.INTEGER(11),
575       allowNull: true,
576     },
577     timerb: {
578       type: DataTypes.INTEGER(11),
579       allowNull: true,
580     },
581     qualifyfreq: {
582       type: DataTypes.INTEGER(11),
583       allowNull: true,
584     },
585     contactpermit: {
586       type: DataTypes.STRING,
587       allowNull: true,
588     },
589     contactdeny: {
590       type: DataTypes.STRING,
591       allowNull: true,
592     },
593     contactacl: {
594       type: DataTypes.STRING,
595       allowNull: true,
596     },
597     unsolicited_mailbox: {
598       type: DataTypes.STRING,
599       allowNull: true,
600     },
601     use_q850_reason: {
602       type: DataTypes.STRING,
603       allowNull: true,
604     },
605     maxforwards: {
606       type: DataTypes.INTEGER(11),
607       allowNull: true,
608     },
609     encryption: {
610       type: DataTypes.ENUM('yes', 'no'),
611       allowNull: true,
612       defaultValue: 'no'
613     },
614     avpf: {
615       type: DataTypes.ENUM('yes', 'no'),
616       allowNull: true
617     },
618     force_avp: {
619       type: DataTypes.ENUM('yes', 'no'),
620       allowNull: true
621     },
622     icesupport: {
623       type: DataTypes.ENUM('yes', 'no'),
624       allowNull: true
625     },
626     dtlsenable: {
627       type: DataTypes.ENUM('yes', 'no'),
628       allowNull: true
629     },
630     dtlsverify: {
631       type: DataTypes.ENUM('yes', 'no', 'fingerprint', 'certificate'),
632       allowNull: true
633     },
634     dtlsrekey: {
635       type: DataTypes.INTEGER(11),
636       allowNull: true,
637     },
638     dtlscertfile: {
639       type: DataTypes.STRING,
640       allowNull: true,
641     },
642     dtlsprivatekey: {
643       type: DataTypes.STRING,
644       allowNull: true,
645     },
646     dtlscipher: {
647       type: DataTypes.STRING,
648       allowNull: true,
649     },
650     dtlscafile: {
651       type: DataTypes.STRING,
652       allowNull: true,
653     },
654     dtlscapath: {
655       type: DataTypes.STRING,
656       allowNull: true,
657     },
658     dtlssetup: {
659       type: DataTypes.ENUM('active', 'passive', 'actpass'),
660       allowNull: true
661     },
662     dtlsfingerprint: {
663       type: DataTypes.STRING,
664       allowNull: true,
665     },
666     usereqphone: { //This provider requires ";user=phone" on URI
667       type: DataTypes.ENUM('yes', 'no'),
668       allowNull: true,
669       defaultValue: 'no'
670     },
671     recordonfeature: { //Feature to use when INFO with Record: on is received.
672       type: DataTypes.STRING,
673       allowNull: true,
674     },
675     recordofffeature: { //Feature to use when INFO with Record: off is received.
676       type: DataTypes.STRING,
677       allowNull: true,
678     },
679     call_limit: {
680       type: DataTypes.INTEGER(11),
681       allowNull: true,
682       defaultValue: null
683     },
684     registertrying: { //Send a 100 Trying when the device registers.
685       type: DataTypes.ENUM('yes', 'no'),
686       allowNull: true,
687     },
688     subscribemwi: { //Only send notifications if this phone subscribes for mailbox notification
689       type: DataTypes.ENUM('yes', 'no'),
690       allowNull: true,
691     },
692     vmexten: { // dialplan extension to reach mailbox. defaults to global vmexten which defaults to "asterisk"
693       type: DataTypes.STRING,
694       allowNull: true,
695     },
696     mohinterpret: { // This option specifies a preference for which music on hold class this channel should listen to when put on hold
697       type: DataTypes.STRING,
698       allowNull: true,
699     },
700     mohsuggest: { //  This option specifies which music on hold class to suggest to the peer channel when this channel places the peer on hold.
701       type: DataTypes.STRING,
702       allowNull: true,
703     },
704     parkinglot: {
705       type: DataTypes.STRING,
706       allowNull: true,
707     },
708     canreinvite: {
709       type: DataTypes.ENUM('yes', 'no', 'nonat', 'update', 'update,nonat'),
710       allowNull: true,
711       defaultValue: 'no'
712     },
713   }, {
714     tableName: 'users',
715     instanceMethods: {
716       /**
717        * Authenticate - check if the passwords are the same
718        *
719        * @param {String} plainText
720        *        {function} callBack
721        * @api public
722        */
723       authenticate: function(plainText) {
724         return this.encryptPassword(plainText) === this.password;
725       },
726       /**
727        * Make salt
728        *
729        * @return {String}
730        * @api public
731        */
732       makeSalt: function() {
733         return crypto.randomBytes(16).toString('base64');
734       },
735       /**
736        * Encrypt password
737        *
738        * @param {String} password
739        * @return {String}
740        * @api public
741        */
742       encryptPassword: function(password) {
743         if (!password || !this.salt) return '';
744         var salt = new Buffer(this.salt, 'base64');
745         return crypto.pbkdf2Sync(password, salt, 10000, 64).toString(
746           'base64');
747       },
748       /**
749        * md5 password
750        *
751        * @param {String} password
752        * @return {String}
753        * @api public
754        */
755       md5Password: function(password) {
756         if (!password) return '';
757         return md5(password);
758       }
759     },
760     associate: function(models) {
761       // BELOGNS TO MANY
762       User.hasMany(models.ChatMessage);
763       User.hasMany(models.MailMessage);
764       User.hasMany(models.Contact);
765       User.hasMany(models.Action);
766       User.belongsToMany(models.Module, {
767         through: 'user_has_modules'
768       });
769       User.belongsToMany(models.Channel, {
770         through: 'user_has_channels'
771       });
772       User.belongsToMany(models.MailRoom, {
773         through: 'user_has_mail_rooms'
774       });
775       User.belongsToMany(models.Team, {
776         through: models.UserHasTeam
777       });
778       User.belongsToMany(models.ChatRoom, {
779         through: models.UserHasChatRoom
780       });
781       User.belongsToMany(models.MailQueue, {
782         through: models.UserHasMailQueue,
783         required: false
784       });
785       User.belongsToMany(models.FaxQueue, {
786         through: models.UserHasFaxQueue,
787         required: false
788       });
789       User.belongsToMany(models.ChatQueue, {
790         through: models.UserHasChatQueue,
791         required: false
792       });
793       User.belongsToMany(models.VoiceQueue, {
794         through: models.UserHasVoiceQueue,
795         required: false
796       });
797       User.belongsToMany(models.List, {
798         through: models.UserHasList
799       });
800       User.hasMany(models.VoiceExtension, {
801         foreignKey: 'UserId',
802         as: 'UserExtensions',
803         onDelete: 'cascade',
804         hooks: true
805       });
806
807       // SCOPES MANAGEMENT
808       User.addScope('user', {
809         where: {
810           role: {
811             $in: ['admin', 'user']
812           },
813         }
814       });
815       User.addScope('queues', {
816         include: [models.VoiceQueue, models.ChatQueue, models.MailQueue, models.FaxQueue]
817       });
818       User.addScope('telephone', {
819         where: {
820           role: 'telephone'
821         }
822       });
823       User.addScope('checkPauseStatus', function(query) {
824         var scope = {
825           where: {}
826         };
827         if (query.voicePause) {
828           scope.where.voicePause = (query.voicePause === 'true') ? true : false;
829           delete query.voicePause;
830         } else if (query.faxPause) {
831           scope.where.faxPause = (query.faxPause === 'true') ? true : false;
832           delete query.faxPause;
833         } else if (query.chatPause) {
834           scope.where.chatPause = (query.chatPause === 'true') ? true : false;
835           delete query.chatPause;
836         } else if (query.mailPause) {
837           scope.where.mailPause = (query.mailPause === 'true') ? true : false;
838           delete query.mailPause;
839         }
840         return scope;
841       });
842       User.addScope('checkOnlineStatus', function(query) {
843         var scope = {
844           where: {}
845         };
846         if (query.online) {
847           scope.where.online = (query.online === 'true') ? true : false;
848           delete query.online;
849         }
850         return scope;
851       });
852       User.addScope('checkSipStatus', function(query) {
853         var scope = {
854           where: {}
855         };
856         if (query.status) {
857           scope.where.status = query.status;
858           delete query.status;
859         }
860         return scope;
861       });
862       User.addScope('checkQueueStatus', function(query) {
863         var scope = {
864           where: {}
865         };
866         if (query.queueStatus) {
867           scope.where.queueStatus = query.queueStatus;
868           delete query.queueStatus;
869         }
870         return scope;
871       });
872       User.addScope('agent', {
873         where: {
874           role: 'agent'
875         },
876         attributes: ['id',
877           'name',
878           'email',
879           'internal',
880           'fullname',
881           'accountcode',
882           'transport',
883           'host',
884           'nat',
885           'type',
886           'allow',
887           'chatCapacity',
888           'mailCapacity',
889           'faxCapacity',
890           'online',
891           'lastLoginAt',
892           'phoneBarAutoAnswer',
893           'phoneBarEnableSettings',
894           'phoneBarUnconditional',
895           'phoneBarNoReply',
896           'phoneBarBusy',
897           'phoneBarUnconditionalNumber',
898           'phoneBarNoReplyNumber',
899           'phoneBarBusyNumber',
900           'phoneBarListenPort',
901           'chanspy',
902           'voicePause',
903           'mailPause',
904           'faxPause',
905           'chatPause',
906           'pauseType',
907           'lastPauseAt',
908           'status',
909           'statusAt',
910           'queueStatus',
911           'queueStatusAt',
912           'lastQueue',
913           'useragent',
914           'ipaddr',
915           'fullcontact',
916           'port',
917           'lastms',
918           'description'
919         ]
920       });
921     }
922   });
923
924   return User;
925 }