638f9b62a95074992f483d719ecc57fccc525e9d
[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 _0xa11f=['state','toLowerCase','not_inuse','idle','inuse','talking','statePause','format','voiceStatusQueue','stringify','user:save','exports','lodash','util','ioredis','../../../config/environment','redis','defaults','socket.io-emitter','name','email','accountcode','fullname','unknown','stateTime','status','address','phone','mobile','interface','online','voiceStatus','voiceStatusTime','voiceStatusCallerIdNumber','onhold','local','md5','prototype'];(function(_0xc2c591,_0x3bbb61){var _0x303868=function(_0x5ad89f){while(--_0x5ad89f){_0xc2c591['push'](_0xc2c591['shift']());}};_0x303868(++_0x3bbb61);}(_0xa11f,0xa4));var _0xfa11=function(_0xee5d2a,_0x534134){_0xee5d2a=_0xee5d2a-0x0;var _0x346948=_0xa11f[_0xee5d2a];return _0x346948;};'use strict';var _=require(_0xfa11('0x0'));var util=require(_0xfa11('0x1'));var moment=require('moment');var md5=require('md5');var Redis=require(_0xfa11('0x2'));var config=require(_0xfa11('0x3'));config[_0xfa11('0x4')]=_[_0xfa11('0x5')](config[_0xfa11('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0xfa11('0x6'))(new Redis(config[_0xfa11('0x4')]));function Agent(_0x3b828c){this['id']=_0x3b828c['id']||0x0;this[_0xfa11('0x7')]=_0x3b828c['name']||'';this[_0xfa11('0x8')]=_0x3b828c[_0xfa11('0x8')]||'';this[_0xfa11('0x9')]=_0x3b828c[_0xfa11('0x9')]||'';this[_0xfa11('0xa')]=_0x3b828c[_0xfa11('0xa')]||'';this['state']=_0xfa11('0xb');this[_0xfa11('0xc')]=0x0;this[_0xfa11('0xd')]=_0xfa11('0xb');this[_0xfa11('0xe')]='';this[_0xfa11('0xf')]='';this[_0xfa11('0x10')]='';this[_0xfa11('0x11')]='';this[_0xfa11('0x12')]=_0x3b828c['online']||![];this[_0xfa11('0x13')]=_0xfa11('0xb');this[_0xfa11('0x14')]=0x0;this[_0xfa11('0x15')]='';this['voiceStatusQueue']='';this[_0xfa11('0x16')]=![];this[_0xfa11('0x17')]=![];this[_0xfa11('0x18')]='';}Agent[_0xfa11('0x19')]['updateStatusRealtime']=function(_0x1f201a){var _0x16e7fb;if(_0x1f201a&&_0x1f201a[_0xfa11('0x1a')]){_0x16e7fb=_0x1f201a['state'][_0xfa11('0x1b')]();switch(_0x16e7fb){case _0xfa11('0x1c'):_0x16e7fb=_0xfa11('0x1d');break;case _0xfa11('0x1e'):_0x16e7fb=_0xfa11('0x1f');break;}}if(_0x16e7fb&&this[_0xfa11('0x13')]!==_0x16e7fb||_0x1f201a[_0xfa11('0x20')]){this[_0xfa11('0x14')]=_['toNumber'](moment()[_0xfa11('0x21')]('x'));}if(_0x16e7fb){this[_0xfa11('0x13')]=_0x16e7fb;}var _0x18448f={'id':this['id'],'name':this[_0xfa11('0x7')],'email':this[_0xfa11('0x8')],'accountcode':this[_0xfa11('0x9')],'fullname':this['fullname'],'state':this[_0xfa11('0x1a')],'stateTime':this['stateTime'],'status':this[_0xfa11('0xd')],'address':this[_0xfa11('0xe')],'online':this[_0xfa11('0x12')],'voiceStatus':this[_0xfa11('0x13')],'voiceStatusTime':this[_0xfa11('0x14')],'voiceStatusCallerIdNumber':this[_0xfa11('0x15')],'voiceStatusQueue':this[_0xfa11('0x22')],'interface':this[_0xfa11('0x11')],'onhold':this['onhold']};var _0x32c876=md5(JSON[_0xfa11('0x23')](_0x18448f));if(this['md5']!==_0x32c876){this[_0xfa11('0x18')]=_0x32c876;io['to'](util[_0xfa11('0x21')]('user:%s',_0x18448f['name']))['emit'](_0xfa11('0x24'),_0x18448f);}};module[_0xfa11('0x25')]=Agent;