Built motion from commit (unavailable).|2.4.17
[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 _0x67f0=['exports','util','moment','md5','ioredis','../../../config/environment','redis','defaults','socket.io-emitter','name','email','accountcode','fullname','unknown','status','address','interface','online','voiceStatus','onhold','local','prototype','updateStatusRealtime','state','idle','inuse','talking','statePause','voiceStatusTime','toNumber','voiceStatusCallerIdNumber','voiceStatusQueue','stringify','user:%s','emit','user:save'];(function(_0x334841,_0x2bbc4c){var _0x5beb4b=function(_0x4bea72){while(--_0x4bea72){_0x334841['push'](_0x334841['shift']());}};_0x5beb4b(++_0x2bbc4c);}(_0x67f0,0x6d));var _0x067f=function(_0x3987a1,_0x447793){_0x3987a1=_0x3987a1-0x0;var _0xe2596e=_0x67f0[_0x3987a1];return _0xe2596e;};'use strict';var _=require('lodash');var util=require(_0x067f('0x0'));var moment=require(_0x067f('0x1'));var md5=require(_0x067f('0x2'));var Redis=require(_0x067f('0x3'));var config=require(_0x067f('0x4'));config[_0x067f('0x5')]=_[_0x067f('0x6')](config['redis'],{'host':'localhost','port':0x18eb});var io=require(_0x067f('0x7'))(new Redis(config[_0x067f('0x5')]));function Agent(_0x3edff1){this['id']=_0x3edff1['id']||0x0;this[_0x067f('0x8')]=_0x3edff1[_0x067f('0x8')]||'';this[_0x067f('0x9')]=_0x3edff1[_0x067f('0x9')]||'';this[_0x067f('0xa')]=_0x3edff1['accountcode']||'';this['fullname']=_0x3edff1[_0x067f('0xb')]||'';this['state']=_0x067f('0xc');this['stateTime']=0x0;this[_0x067f('0xd')]=_0x067f('0xc');this[_0x067f('0xe')]='';this['phone']='';this['mobile']='';this[_0x067f('0xf')]='';this['online']=_0x3edff1[_0x067f('0x10')]||![];this[_0x067f('0x11')]=_0x067f('0xc');this['voiceStatusTime']=0x0;this['voiceStatusCallerIdNumber']='';this['voiceStatusQueue']='';this[_0x067f('0x12')]=![];this[_0x067f('0x13')]=![];this[_0x067f('0x2')]='';}Agent[_0x067f('0x14')][_0x067f('0x15')]=function(_0x24f0aa){var _0x2058c1;if(_0x24f0aa&&_0x24f0aa[_0x067f('0x16')]){_0x2058c1=_0x24f0aa['state']['toLowerCase']();switch(_0x2058c1){case'not_inuse':_0x2058c1=_0x067f('0x17');break;case _0x067f('0x18'):_0x2058c1=_0x067f('0x19');break;}}if(_0x2058c1&&this[_0x067f('0x11')]!==_0x2058c1||_0x24f0aa[_0x067f('0x1a')]){this[_0x067f('0x1b')]=_[_0x067f('0x1c')](moment()['format']('x'));}if(_0x2058c1){this[_0x067f('0x11')]=_0x2058c1;}var _0x5e7780={'id':this['id'],'name':this[_0x067f('0x8')],'email':this[_0x067f('0x9')],'accountcode':this[_0x067f('0xa')],'fullname':this[_0x067f('0xb')],'state':this[_0x067f('0x16')],'stateTime':this['stateTime'],'status':this[_0x067f('0xd')],'address':this[_0x067f('0xe')],'online':this[_0x067f('0x10')],'voiceStatus':this[_0x067f('0x11')],'voiceStatusTime':this[_0x067f('0x1b')],'voiceStatusCallerIdNumber':this[_0x067f('0x1d')],'voiceStatusQueue':this[_0x067f('0x1e')],'interface':this[_0x067f('0xf')],'onhold':this[_0x067f('0x12')]};var _0xbfba10=md5(JSON[_0x067f('0x1f')](_0x5e7780));if(this[_0x067f('0x2')]!==_0xbfba10){this[_0x067f('0x2')]=_0xbfba10;io['to'](util['format'](_0x067f('0x20'),_0x5e7780[_0x067f('0x8')]))[_0x067f('0x21')](_0x067f('0x22'),_0x5e7780);}};module[_0x067f('0x23')]=Agent;