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