2c5281ec815056e3675606c710653ff8a067f1d5
[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 _0x532b=['voiceStatusTime','voiceStatusCallerIdNumber','onhold','local','prototype','toLowerCase','not_inuse','idle','talking','statePause','toNumber','format','stringify','user:%s','emit','exports','lodash','util','md5','redis','localhost','socket.io-emitter','name','email','accountcode','fullname','state','stateTime','status','unknown','address','phone','mobile','interface','online','voiceStatus'];(function(_0x2763f2,_0x416af8){var _0x3ef471=function(_0x288aa2){while(--_0x288aa2){_0x2763f2['push'](_0x2763f2['shift']());}};_0x3ef471(++_0x416af8);}(_0x532b,0x1e4));var _0xb532=function(_0x4529b3,_0x390ebb){_0x4529b3=_0x4529b3-0x0;var _0x21e907=_0x532b[_0x4529b3];return _0x21e907;};'use strict';var _=require(_0xb532('0x0'));var util=require(_0xb532('0x1'));var moment=require('moment');var md5=require(_0xb532('0x2'));var Redis=require('ioredis');var config=require('../../../config/environment');config[_0xb532('0x3')]=_['defaults'](config[_0xb532('0x3')],{'host':_0xb532('0x4'),'port':0x18eb});var io=require(_0xb532('0x5'))(new Redis(config['redis']));function Agent(_0x4600aa){this['id']=_0x4600aa['id']||0x0;this[_0xb532('0x6')]=_0x4600aa[_0xb532('0x6')]||'';this[_0xb532('0x7')]=_0x4600aa[_0xb532('0x7')]||'';this[_0xb532('0x8')]=_0x4600aa[_0xb532('0x8')]||'';this[_0xb532('0x9')]=_0x4600aa[_0xb532('0x9')]||'';this[_0xb532('0xa')]='unknown';this[_0xb532('0xb')]=0x0;this[_0xb532('0xc')]=_0xb532('0xd');this[_0xb532('0xe')]='';this[_0xb532('0xf')]='';this[_0xb532('0x10')]='';this[_0xb532('0x11')]='';this[_0xb532('0x12')]=_0x4600aa[_0xb532('0x12')]||![];this[_0xb532('0x13')]=_0xb532('0xd');this[_0xb532('0x14')]=0x0;this[_0xb532('0x15')]='';this['voiceStatusQueue']='';this[_0xb532('0x16')]=![];this[_0xb532('0x17')]=![];this[_0xb532('0x2')]='';}Agent[_0xb532('0x18')]['updateStatusRealtime']=function(_0x55c354){var _0x3a3524;if(_0x55c354&&_0x55c354[_0xb532('0xa')]){_0x3a3524=_0x55c354[_0xb532('0xa')][_0xb532('0x19')]();switch(_0x3a3524){case _0xb532('0x1a'):_0x3a3524=_0xb532('0x1b');break;case'inuse':_0x3a3524=_0xb532('0x1c');break;}}if(_0x3a3524&&this['voiceStatus']!==_0x3a3524||_0x55c354[_0xb532('0x1d')]){this['voiceStatusTime']=_[_0xb532('0x1e')](moment()[_0xb532('0x1f')]('x'));}if(_0x3a3524){this[_0xb532('0x13')]=_0x3a3524;}var _0x791b26={'id':this['id'],'name':this[_0xb532('0x6')],'email':this[_0xb532('0x7')],'accountcode':this[_0xb532('0x8')],'fullname':this[_0xb532('0x9')],'state':this[_0xb532('0xa')],'stateTime':this[_0xb532('0xb')],'status':this[_0xb532('0xc')],'address':this[_0xb532('0xe')],'online':this[_0xb532('0x12')],'voiceStatus':this[_0xb532('0x13')],'voiceStatusTime':this[_0xb532('0x14')],'voiceStatusCallerIdNumber':this['voiceStatusCallerIdNumber'],'voiceStatusQueue':this['voiceStatusQueue'],'interface':this[_0xb532('0x11')],'onhold':this['onhold']};var _0xb212ef=md5(JSON[_0xb532('0x20')](_0x791b26));if(this['md5']!==_0xb212ef){this[_0xb532('0x2')]=_0xb212ef;io['to'](util[_0xb532('0x1f')](_0xb532('0x21'),_0x791b26[_0xb532('0x6')]))[_0xb532('0x22')]('user:save',_0x791b26);}};module[_0xb532('0x23')]=Agent;