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