aecca3a680ec177afe751bc57ad5ff2c9fdcefee
[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 _0x03b2=['stringify','md5','user:%s','emit','user:save','lodash','util','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','email','accountcode','unknown','address','phone','mobile','interface','online','voiceStatus','voiceStatusTime','voiceStatusCallerIdNumber','voiceStatusQueue','onhold','local','state','idle','inuse','statePause','toNumber','fullname','stateTime'];(function(_0x265720,_0x3a25ea){var _0x5b731c=function(_0x10d29e){while(--_0x10d29e){_0x265720['push'](_0x265720['shift']());}};_0x5b731c(++_0x3a25ea);}(_0x03b2,0x1e1));var _0x203b=function(_0x2dd6b1,_0x4485d7){_0x2dd6b1=_0x2dd6b1-0x0;var _0x494306=_0x03b2[_0x2dd6b1];return _0x494306;};'use strict';var _=require(_0x203b('0x0'));var util=require(_0x203b('0x1'));var moment=require('moment');var md5=require('md5');var Redis=require('ioredis');var config=require(_0x203b('0x2'));config[_0x203b('0x3')]=_[_0x203b('0x4')](config['redis'],{'host':_0x203b('0x5'),'port':0x18eb});var io=require(_0x203b('0x6'))(new Redis(config[_0x203b('0x3')]));function Agent(_0x44a6c7){this['id']=_0x44a6c7['id']||0x0;this[_0x203b('0x7')]=_0x44a6c7[_0x203b('0x7')]||'';this[_0x203b('0x8')]=_0x44a6c7[_0x203b('0x8')]||'';this[_0x203b('0x9')]=_0x44a6c7[_0x203b('0x9')]||'';this['fullname']=_0x44a6c7['fullname']||'';this['state']=_0x203b('0xa');this['stateTime']=0x0;this['status']=_0x203b('0xa');this[_0x203b('0xb')]='';this[_0x203b('0xc')]='';this[_0x203b('0xd')]='';this[_0x203b('0xe')]='';this[_0x203b('0xf')]=_0x44a6c7[_0x203b('0xf')]||![];this[_0x203b('0x10')]=_0x203b('0xa');this[_0x203b('0x11')]=0x0;this[_0x203b('0x12')]='';this[_0x203b('0x13')]='';this[_0x203b('0x14')]=![];this[_0x203b('0x15')]=![];this['md5']='';}Agent['prototype']['updateStatusRealtime']=function(_0x4bfece){var _0x5d498c;if(_0x4bfece&&_0x4bfece['state']){_0x5d498c=_0x4bfece[_0x203b('0x16')]['toLowerCase']();switch(_0x5d498c){case'not_inuse':_0x5d498c=_0x203b('0x17');break;case _0x203b('0x18'):_0x5d498c='talking';break;}}if(_0x5d498c&&this[_0x203b('0x10')]!==_0x5d498c||_0x4bfece[_0x203b('0x19')]){this['voiceStatusTime']=_[_0x203b('0x1a')](moment()['format']('x'));}if(_0x5d498c){this[_0x203b('0x10')]=_0x5d498c;}var _0x23669f={'id':this['id'],'name':this[_0x203b('0x7')],'email':this['email'],'accountcode':this[_0x203b('0x9')],'fullname':this[_0x203b('0x1b')],'state':this[_0x203b('0x16')],'stateTime':this[_0x203b('0x1c')],'status':this['status'],'address':this[_0x203b('0xb')],'online':this[_0x203b('0xf')],'voiceStatus':this['voiceStatus'],'voiceStatusTime':this[_0x203b('0x11')],'voiceStatusCallerIdNumber':this['voiceStatusCallerIdNumber'],'voiceStatusQueue':this['voiceStatusQueue'],'interface':this['interface'],'onhold':this['onhold']};var _0x4ac627=md5(JSON[_0x203b('0x1d')](_0x23669f));if(this[_0x203b('0x1e')]!==_0x4ac627){this[_0x203b('0x1e')]=_0x4ac627;io['to'](util['format'](_0x203b('0x1f'),_0x23669f[_0x203b('0x7')]))[_0x203b('0x20')](_0x203b('0x21'),_0x23669f);}};module['exports']=Agent;