0c45efdbcc787caed1ec845090ff3cee0947aba6
[motion2.git] / server / services / ami / model / agent.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x7b44=['unknown','address','phone','mobile','interface','online','voiceStatusTime','onhold','md5','updateStatusRealtime','toLowerCase','not_inuse','idle','talking','voiceStatus','format','stateTime','status','voiceStatusCallerIdNumber','voiceStatusQueue','stringify','user:%s','emit','exports','lodash','util','ioredis','../../../config/environment','redis','defaults','localhost','name','email','accountcode','fullname','state'];(function(_0x11de10,_0x3f7597){var _0x492991=function(_0x262282){while(--_0x262282){_0x11de10['push'](_0x11de10['shift']());}};_0x492991(++_0x3f7597);}(_0x7b44,0x1c8));var _0x47b4=function(_0x3c0c76,_0x10018a){_0x3c0c76=_0x3c0c76-0x0;var _0x137ea7=_0x7b44[_0x3c0c76];return _0x137ea7;};'use strict';var _=require(_0x47b4('0x0'));var util=require(_0x47b4('0x1'));var moment=require('moment');var md5=require('md5');var Redis=require(_0x47b4('0x2'));var config=require(_0x47b4('0x3'));config[_0x47b4('0x4')]=_[_0x47b4('0x5')](config[_0x47b4('0x4')],{'host':_0x47b4('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x47b4('0x4')]));function Agent(_0x41c285){this['id']=_0x41c285['id']||0x0;this[_0x47b4('0x7')]=_0x41c285[_0x47b4('0x7')]||'';this['email']=_0x41c285[_0x47b4('0x8')]||'';this[_0x47b4('0x9')]=_0x41c285[_0x47b4('0x9')]||'';this[_0x47b4('0xa')]=_0x41c285[_0x47b4('0xa')]||'';this[_0x47b4('0xb')]='unknown';this['stateTime']=0x0;this['status']=_0x47b4('0xc');this[_0x47b4('0xd')]='';this[_0x47b4('0xe')]='';this[_0x47b4('0xf')]='';this[_0x47b4('0x10')]='';this[_0x47b4('0x11')]=_0x41c285[_0x47b4('0x11')]||![];this['voiceStatus']=_0x47b4('0xc');this[_0x47b4('0x12')]=0x0;this['voiceStatusCallerIdNumber']='';this['voiceStatusQueue']='';this[_0x47b4('0x13')]=![];this['local']=![];this[_0x47b4('0x14')]='';}Agent['prototype'][_0x47b4('0x15')]=function(_0x14a323){var _0x21729e;if(_0x14a323&&_0x14a323[_0x47b4('0xb')]){_0x21729e=_0x14a323[_0x47b4('0xb')][_0x47b4('0x16')]();switch(_0x21729e){case _0x47b4('0x17'):_0x21729e=_0x47b4('0x18');break;case'inuse':_0x21729e=_0x47b4('0x19');break;}}if(_0x21729e&&this[_0x47b4('0x1a')]!==_0x21729e||_0x14a323['statePause']){this[_0x47b4('0x12')]=_['toNumber'](moment()[_0x47b4('0x1b')]('x'));}if(_0x21729e){this['voiceStatus']=_0x21729e;}var _0x4283fe={'id':this['id'],'name':this[_0x47b4('0x7')],'email':this['email'],'accountcode':this['accountcode'],'fullname':this[_0x47b4('0xa')],'state':this['state'],'stateTime':this[_0x47b4('0x1c')],'status':this[_0x47b4('0x1d')],'address':this[_0x47b4('0xd')],'online':this[_0x47b4('0x11')],'voiceStatus':this[_0x47b4('0x1a')],'voiceStatusTime':this[_0x47b4('0x12')],'voiceStatusCallerIdNumber':this[_0x47b4('0x1e')],'voiceStatusQueue':this[_0x47b4('0x1f')],'interface':this[_0x47b4('0x10')],'onhold':this[_0x47b4('0x13')]};var _0x2f44fa=md5(JSON[_0x47b4('0x20')](_0x4283fe));if(this[_0x47b4('0x14')]!==_0x2f44fa){this[_0x47b4('0x14')]=_0x2f44fa;io['to'](util[_0x47b4('0x1b')](_0x47b4('0x21'),_0x4283fe[_0x47b4('0x7')]))[_0x47b4('0x22')]('user:save',_0x4283fe);}};module[_0x47b4('0x23')]=Agent;