Built motion from commit a679711e.|2.6.15
[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 _0x248f=['voiceStatusCallerIdNumber','onhold','local','prototype','updateStatusRealtime','not_inuse','idle','inuse','talking','statePause','voiceStatusQueue','stringify','md5','format','user:%s','emit','user:presence','exports','lodash','util','moment','ioredis','../../../config/environment','redis','defaults','localhost','name','email','accountcode','fullname','state','unknown','stateTime','status','address','phone','mobile','interface','online','voiceStatus','voiceStatusTime'];(function(_0x55e3d8,_0x4a6134){var _0x4f645d=function(_0x585ef9){while(--_0x585ef9){_0x55e3d8['push'](_0x55e3d8['shift']());}};_0x4f645d(++_0x4a6134);}(_0x248f,0x108));var _0xf248=function(_0x4b1b9e,_0x503a70){_0x4b1b9e=_0x4b1b9e-0x0;var _0x8137ff=_0x248f[_0x4b1b9e];return _0x8137ff;};'use strict';var _=require(_0xf248('0x0'));var util=require(_0xf248('0x1'));var moment=require(_0xf248('0x2'));var md5=require('md5');var Redis=require(_0xf248('0x3'));var config=require(_0xf248('0x4'));config[_0xf248('0x5')]=_[_0xf248('0x6')](config[_0xf248('0x5')],{'host':_0xf248('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xf248('0x5')]));function Agent(_0x368e26){this['id']=_0x368e26['id']||0x0;this[_0xf248('0x8')]=_0x368e26['name']||'';this[_0xf248('0x9')]=_0x368e26['email']||'';this[_0xf248('0xa')]=_0x368e26['accountcode']||'';this[_0xf248('0xb')]=_0x368e26['fullname']||'';this[_0xf248('0xc')]=_0xf248('0xd');this[_0xf248('0xe')]=0x0;this[_0xf248('0xf')]='unknown';this[_0xf248('0x10')]='';this[_0xf248('0x11')]='';this[_0xf248('0x12')]='';this[_0xf248('0x13')]='';this[_0xf248('0x14')]=_0x368e26[_0xf248('0x14')]||![];this[_0xf248('0x15')]='unknown';this[_0xf248('0x16')]=0x0;this[_0xf248('0x17')]='';this['voiceStatusQueue']='';this[_0xf248('0x18')]=![];this[_0xf248('0x19')]=![];this['md5']='';}Agent[_0xf248('0x1a')][_0xf248('0x1b')]=function(_0x1ac3b8){var _0x36e852;if(_0x1ac3b8&&_0x1ac3b8[_0xf248('0xc')]){_0x36e852=_0x1ac3b8[_0xf248('0xc')]['toLowerCase']();switch(_0x36e852){case _0xf248('0x1c'):_0x36e852=_0xf248('0x1d');break;case _0xf248('0x1e'):_0x36e852=_0xf248('0x1f');break;}}if(_0x36e852&&this[_0xf248('0x15')]!==_0x36e852||_0x1ac3b8[_0xf248('0x20')]){this[_0xf248('0x16')]=_['toNumber'](moment()['format']('x'));}if(_0x36e852){this['voiceStatus']=_0x36e852;}var _0x1d4317={'id':this['id'],'name':this[_0xf248('0x8')],'email':this['email'],'accountcode':this[_0xf248('0xa')],'fullname':this['fullname'],'state':this[_0xf248('0xc')],'stateTime':this[_0xf248('0xe')],'status':this[_0xf248('0xf')],'address':this['address'],'online':this['online'],'voiceStatus':this['voiceStatus'],'voiceStatusTime':this['voiceStatusTime'],'voiceStatusCallerIdNumber':this[_0xf248('0x17')],'voiceStatusQueue':this[_0xf248('0x21')],'interface':this[_0xf248('0x13')],'onhold':this['onhold']};var _0x148cd7=md5(JSON[_0xf248('0x22')](_0x1d4317));if(this['md5']!==_0x148cd7){this[_0xf248('0x23')]=_0x148cd7;io['to'](util[_0xf248('0x24')](_0xf248('0x25'),_0x1d4317[_0xf248('0x8')]))[_0xf248('0x26')]('user:save',_0x1d4317);io['emit'](_0xf248('0x27'),_0x1d4317);}};module[_0xf248('0x28')]=Agent;