Built motion from commit c0cdc9d8.|2.6.28
[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 _0xd46b=['ioredis','redis','defaults','localhost','socket.io-emitter','name','email','accountcode','fullname','state','stateTime','status','address','online','voiceStatus','voiceStatusTime','voiceStatusCallerIdNumber','voiceStatusQueue','local','prototype','updateStatusRealtime','toLowerCase','not_inuse','idle','inuse','talking','format','interface','onhold','stringify','user:%s','emit','omit','exports','lodash','util','moment','md5'];(function(_0x3ba527,_0x446a5e){var _0x5ee6ad=function(_0x5978c7){while(--_0x5978c7){_0x3ba527['push'](_0x3ba527['shift']());}};_0x5ee6ad(++_0x446a5e);}(_0xd46b,0x12c));var _0xbd46=function(_0x4a71f5,_0x401424){_0x4a71f5=_0x4a71f5-0x0;var _0x27162f=_0xd46b[_0x4a71f5];return _0x27162f;};'use strict';var _=require(_0xbd46('0x0'));var util=require(_0xbd46('0x1'));var moment=require(_0xbd46('0x2'));var md5=require(_0xbd46('0x3'));var Redis=require(_0xbd46('0x4'));var config=require('../../../config/environment');config[_0xbd46('0x5')]=_[_0xbd46('0x6')](config[_0xbd46('0x5')],{'host':_0xbd46('0x7'),'port':0x18eb});var io=require(_0xbd46('0x8'))(new Redis(config[_0xbd46('0x5')]));function Agent(_0x38edb4){this['id']=_0x38edb4['id']||0x0;this[_0xbd46('0x9')]=_0x38edb4[_0xbd46('0x9')]||'';this[_0xbd46('0xa')]=_0x38edb4[_0xbd46('0xa')]||'';this[_0xbd46('0xb')]=_0x38edb4[_0xbd46('0xb')]||'';this[_0xbd46('0xc')]=_0x38edb4[_0xbd46('0xc')]||'';this[_0xbd46('0xd')]='unknown';this[_0xbd46('0xe')]=0x0;this[_0xbd46('0xf')]='unknown';this[_0xbd46('0x10')]='';this['phone']='';this['mobile']='';this['interface']='';this[_0xbd46('0x11')]=_0x38edb4[_0xbd46('0x11')]||![];this[_0xbd46('0x12')]='unknown';this[_0xbd46('0x13')]=0x0;this[_0xbd46('0x14')]='';this[_0xbd46('0x15')]='';this['onhold']=![];this[_0xbd46('0x16')]=![];this[_0xbd46('0x3')]='';}Agent[_0xbd46('0x17')][_0xbd46('0x18')]=function(_0x5e0b66){var _0x20d128;if(_0x5e0b66&&_0x5e0b66[_0xbd46('0xd')]){_0x20d128=_0x5e0b66[_0xbd46('0xd')][_0xbd46('0x19')]();switch(_0x20d128){case _0xbd46('0x1a'):_0x20d128=_0xbd46('0x1b');break;case _0xbd46('0x1c'):_0x20d128=_0xbd46('0x1d');break;}}if(_0x20d128&&this[_0xbd46('0x12')]!==_0x20d128||_0x5e0b66['statePause']){this[_0xbd46('0x13')]=_['toNumber'](moment()[_0xbd46('0x1e')]('x'));}if(_0x20d128){this['voiceStatus']=_0x20d128;}var _0x69ebda={'id':this['id'],'name':this[_0xbd46('0x9')],'email':this[_0xbd46('0xa')],'accountcode':this['accountcode'],'fullname':this[_0xbd46('0xc')],'state':this[_0xbd46('0xd')],'stateTime':this['stateTime'],'status':this[_0xbd46('0xf')],'address':this[_0xbd46('0x10')],'online':this[_0xbd46('0x11')],'voiceStatus':this['voiceStatus'],'voiceStatusTime':this['voiceStatusTime'],'voiceStatusCallerIdNumber':this[_0xbd46('0x14')],'voiceStatusQueue':this['voiceStatusQueue'],'interface':this[_0xbd46('0x1f')],'onhold':this[_0xbd46('0x20')]};var _0x554fc5=md5(JSON[_0xbd46('0x21')](_0x69ebda));if(this[_0xbd46('0x3')]!==_0x554fc5){this[_0xbd46('0x3')]=_0x554fc5;io['to'](util[_0xbd46('0x1e')](_0xbd46('0x22'),_0x69ebda[_0xbd46('0x9')]))[_0xbd46('0x23')]('user:ami:update',_[_0xbd46('0x24')](_0x69ebda,[_0xbd46('0x11')]));io['emit']('user:presence',_0x69ebda);}};module[_0xbd46('0x25')]=Agent;