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