0fd39c6261c33c618e9bc75fe7976dc65c5c5e86
[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 _0xce19=['voiceStatus','voiceStatusTime','voiceStatusCallerIdNumber','voiceStatusQueue','onhold','local','md5','updateStatusRealtime','toLowerCase','not_inuse','idle','inuse','talking','statePause','toNumber','format','stringify','user:%s','emit','user:save','user:presence','exports','lodash','util','moment','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','email','accountcode','fullname','state','stateTime','status','unknown','address','interface','online'];(function(_0x31c0e3,_0x3c5cd6){var _0xf34e31=function(_0x312d15){while(--_0x312d15){_0x31c0e3['push'](_0x31c0e3['shift']());}};_0xf34e31(++_0x3c5cd6);}(_0xce19,0x6a));var _0x9ce1=function(_0x3f09fe,_0x42171d){_0x3f09fe=_0x3f09fe-0x0;var _0x29092b=_0xce19[_0x3f09fe];return _0x29092b;};'use strict';var _=require(_0x9ce1('0x0'));var util=require(_0x9ce1('0x1'));var moment=require(_0x9ce1('0x2'));var md5=require('md5');var Redis=require(_0x9ce1('0x3'));var config=require(_0x9ce1('0x4'));config[_0x9ce1('0x5')]=_[_0x9ce1('0x6')](config[_0x9ce1('0x5')],{'host':_0x9ce1('0x7'),'port':0x18eb});var io=require(_0x9ce1('0x8'))(new Redis(config[_0x9ce1('0x5')]));function Agent(_0x3f3a11){this['id']=_0x3f3a11['id']||0x0;this[_0x9ce1('0x9')]=_0x3f3a11[_0x9ce1('0x9')]||'';this[_0x9ce1('0xa')]=_0x3f3a11['email']||'';this[_0x9ce1('0xb')]=_0x3f3a11['accountcode']||'';this[_0x9ce1('0xc')]=_0x3f3a11[_0x9ce1('0xc')]||'';this[_0x9ce1('0xd')]='unknown';this[_0x9ce1('0xe')]=0x0;this[_0x9ce1('0xf')]=_0x9ce1('0x10');this[_0x9ce1('0x11')]='';this['phone']='';this['mobile']='';this[_0x9ce1('0x12')]='';this[_0x9ce1('0x13')]=_0x3f3a11['online']||![];this[_0x9ce1('0x14')]=_0x9ce1('0x10');this[_0x9ce1('0x15')]=0x0;this[_0x9ce1('0x16')]='';this[_0x9ce1('0x17')]='';this[_0x9ce1('0x18')]=![];this[_0x9ce1('0x19')]=![];this[_0x9ce1('0x1a')]='';}Agent['prototype'][_0x9ce1('0x1b')]=function(_0x23cea3){var _0x2325a9;if(_0x23cea3&&_0x23cea3[_0x9ce1('0xd')]){_0x2325a9=_0x23cea3['state'][_0x9ce1('0x1c')]();switch(_0x2325a9){case _0x9ce1('0x1d'):_0x2325a9=_0x9ce1('0x1e');break;case _0x9ce1('0x1f'):_0x2325a9=_0x9ce1('0x20');break;}}if(_0x2325a9&&this[_0x9ce1('0x14')]!==_0x2325a9||_0x23cea3[_0x9ce1('0x21')]){this[_0x9ce1('0x15')]=_[_0x9ce1('0x22')](moment()[_0x9ce1('0x23')]('x'));}if(_0x2325a9){this[_0x9ce1('0x14')]=_0x2325a9;}var _0x14d04b={'id':this['id'],'name':this[_0x9ce1('0x9')],'email':this[_0x9ce1('0xa')],'accountcode':this[_0x9ce1('0xb')],'fullname':this[_0x9ce1('0xc')],'state':this[_0x9ce1('0xd')],'stateTime':this['stateTime'],'status':this['status'],'address':this['address'],'online':this['online'],'voiceStatus':this[_0x9ce1('0x14')],'voiceStatusTime':this[_0x9ce1('0x15')],'voiceStatusCallerIdNumber':this[_0x9ce1('0x16')],'voiceStatusQueue':this[_0x9ce1('0x17')],'interface':this[_0x9ce1('0x12')],'onhold':this[_0x9ce1('0x18')]};var _0x3f331c=md5(JSON[_0x9ce1('0x24')](_0x14d04b));if(this[_0x9ce1('0x1a')]!==_0x3f331c){this[_0x9ce1('0x1a')]=_0x3f331c;io['to'](util[_0x9ce1('0x23')](_0x9ce1('0x25'),_0x14d04b[_0x9ce1('0x9')]))[_0x9ce1('0x26')](_0x9ce1('0x27'),_0x14d04b);io[_0x9ce1('0x26')](_0x9ce1('0x28'),_0x14d04b);}};module[_0x9ce1('0x29')]=Agent;