Built motion from commit 00bf23f6.|2.6.16
[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 _0x96ed=['stateTime','stringify','user:save','emit','user:presence','exports','lodash','util','moment','md5','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','email','accountcode','fullname','unknown','status','address','phone','mobile','interface','online','voiceStatusTime','voiceStatusCallerIdNumber','voiceStatusQueue','onhold','updateStatusRealtime','state','toLowerCase','not_inuse','idle','inuse','voiceStatus','statePause','toNumber','format'];(function(_0x1b7679,_0x1b4d16){var _0x53e1d1=function(_0x30f435){while(--_0x30f435){_0x1b7679['push'](_0x1b7679['shift']());}};_0x53e1d1(++_0x1b4d16);}(_0x96ed,0xfc));var _0xd96e=function(_0x15e885,_0x469eb5){_0x15e885=_0x15e885-0x0;var _0x1a7bd5=_0x96ed[_0x15e885];return _0x1a7bd5;};'use strict';var _=require(_0xd96e('0x0'));var util=require(_0xd96e('0x1'));var moment=require(_0xd96e('0x2'));var md5=require(_0xd96e('0x3'));var Redis=require(_0xd96e('0x4'));var config=require(_0xd96e('0x5'));config[_0xd96e('0x6')]=_[_0xd96e('0x7')](config[_0xd96e('0x6')],{'host':_0xd96e('0x8'),'port':0x18eb});var io=require(_0xd96e('0x9'))(new Redis(config[_0xd96e('0x6')]));function Agent(_0x446457){this['id']=_0x446457['id']||0x0;this[_0xd96e('0xa')]=_0x446457[_0xd96e('0xa')]||'';this[_0xd96e('0xb')]=_0x446457['email']||'';this[_0xd96e('0xc')]=_0x446457['accountcode']||'';this['fullname']=_0x446457[_0xd96e('0xd')]||'';this['state']=_0xd96e('0xe');this['stateTime']=0x0;this[_0xd96e('0xf')]='unknown';this[_0xd96e('0x10')]='';this[_0xd96e('0x11')]='';this[_0xd96e('0x12')]='';this[_0xd96e('0x13')]='';this[_0xd96e('0x14')]=_0x446457['online']||![];this['voiceStatus']='unknown';this[_0xd96e('0x15')]=0x0;this[_0xd96e('0x16')]='';this[_0xd96e('0x17')]='';this[_0xd96e('0x18')]=![];this['local']=![];this['md5']='';}Agent['prototype'][_0xd96e('0x19')]=function(_0x4e42e0){var _0x285e53;if(_0x4e42e0&&_0x4e42e0[_0xd96e('0x1a')]){_0x285e53=_0x4e42e0[_0xd96e('0x1a')][_0xd96e('0x1b')]();switch(_0x285e53){case _0xd96e('0x1c'):_0x285e53=_0xd96e('0x1d');break;case _0xd96e('0x1e'):_0x285e53='talking';break;}}if(_0x285e53&&this[_0xd96e('0x1f')]!==_0x285e53||_0x4e42e0[_0xd96e('0x20')]){this[_0xd96e('0x15')]=_[_0xd96e('0x21')](moment()[_0xd96e('0x22')]('x'));}if(_0x285e53){this[_0xd96e('0x1f')]=_0x285e53;}var _0x1232ac={'id':this['id'],'name':this[_0xd96e('0xa')],'email':this[_0xd96e('0xb')],'accountcode':this['accountcode'],'fullname':this[_0xd96e('0xd')],'state':this[_0xd96e('0x1a')],'stateTime':this[_0xd96e('0x23')],'status':this[_0xd96e('0xf')],'address':this[_0xd96e('0x10')],'online':this[_0xd96e('0x14')],'voiceStatus':this[_0xd96e('0x1f')],'voiceStatusTime':this[_0xd96e('0x15')],'voiceStatusCallerIdNumber':this['voiceStatusCallerIdNumber'],'voiceStatusQueue':this[_0xd96e('0x17')],'interface':this[_0xd96e('0x13')],'onhold':this['onhold']};var _0x143a02=md5(JSON[_0xd96e('0x24')](_0x1232ac));if(this[_0xd96e('0x3')]!==_0x143a02){this['md5']=_0x143a02;io['to'](util[_0xd96e('0x22')]('user:%s',_0x1232ac[_0xd96e('0xa')]))['emit'](_0xd96e('0x25'),_0x1232ac);io[_0xd96e('0x26')](_0xd96e('0x27'),_0x1232ac);}};module[_0xd96e('0x28')]=Agent;