Built motion from commit 8271bb6f.|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 _0x0afd=['toNumber','format','interface','onhold','stringify','user:%s','name','emit','user:ami:update','omit','user:presence','lodash','util','moment','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','email','accountcode','fullname','state','unknown','status','address','phone','mobile','online','voiceStatus','voiceStatusTime','voiceStatusCallerIdNumber','voiceStatusQueue','local','md5','prototype','updateStatusRealtime','not_inuse','idle','inuse','talking','statePause'];(function(_0x19ad7b,_0x2ae8fa){var _0x8a0f00=function(_0x56781d){while(--_0x56781d){_0x19ad7b['push'](_0x19ad7b['shift']());}};_0x8a0f00(++_0x2ae8fa);}(_0x0afd,0x138));var _0xd0af=function(_0x2e3df2,_0x583635){_0x2e3df2=_0x2e3df2-0x0;var _0x34c8c9=_0x0afd[_0x2e3df2];return _0x34c8c9;};'use strict';var _=require(_0xd0af('0x0'));var util=require(_0xd0af('0x1'));var moment=require(_0xd0af('0x2'));var md5=require('md5');var Redis=require(_0xd0af('0x3'));var config=require(_0xd0af('0x4'));config[_0xd0af('0x5')]=_[_0xd0af('0x6')](config['redis'],{'host':_0xd0af('0x7'),'port':0x18eb});var io=require(_0xd0af('0x8'))(new Redis(config['redis']));function Agent(_0x461be2){this['id']=_0x461be2['id']||0x0;this['name']=_0x461be2['name']||'';this[_0xd0af('0x9')]=_0x461be2[_0xd0af('0x9')]||'';this[_0xd0af('0xa')]=_0x461be2[_0xd0af('0xa')]||'';this[_0xd0af('0xb')]=_0x461be2['fullname']||'';this[_0xd0af('0xc')]=_0xd0af('0xd');this['stateTime']=0x0;this[_0xd0af('0xe')]=_0xd0af('0xd');this[_0xd0af('0xf')]='';this[_0xd0af('0x10')]='';this[_0xd0af('0x11')]='';this['interface']='';this[_0xd0af('0x12')]=_0x461be2[_0xd0af('0x12')]||![];this[_0xd0af('0x13')]=_0xd0af('0xd');this[_0xd0af('0x14')]=0x0;this[_0xd0af('0x15')]='';this[_0xd0af('0x16')]='';this['onhold']=![];this[_0xd0af('0x17')]=![];this[_0xd0af('0x18')]='';}Agent[_0xd0af('0x19')][_0xd0af('0x1a')]=function(_0x15ff91){var _0x1ee14a;if(_0x15ff91&&_0x15ff91['state']){_0x1ee14a=_0x15ff91['state']['toLowerCase']();switch(_0x1ee14a){case _0xd0af('0x1b'):_0x1ee14a=_0xd0af('0x1c');break;case _0xd0af('0x1d'):_0x1ee14a=_0xd0af('0x1e');break;}}if(_0x1ee14a&&this['voiceStatus']!==_0x1ee14a||_0x15ff91[_0xd0af('0x1f')]){this[_0xd0af('0x14')]=_[_0xd0af('0x20')](moment()[_0xd0af('0x21')]('x'));}if(_0x1ee14a){this[_0xd0af('0x13')]=_0x1ee14a;}var _0x2cefa6={'id':this['id'],'name':this['name'],'email':this['email'],'accountcode':this[_0xd0af('0xa')],'fullname':this[_0xd0af('0xb')],'state':this[_0xd0af('0xc')],'stateTime':this['stateTime'],'status':this[_0xd0af('0xe')],'address':this[_0xd0af('0xf')],'online':this['online'],'voiceStatus':this[_0xd0af('0x13')],'voiceStatusTime':this[_0xd0af('0x14')],'voiceStatusCallerIdNumber':this[_0xd0af('0x15')],'voiceStatusQueue':this['voiceStatusQueue'],'interface':this[_0xd0af('0x22')],'onhold':this[_0xd0af('0x23')]};var _0x1a7c0a=md5(JSON[_0xd0af('0x24')](_0x2cefa6));if(this['md5']!==_0x1a7c0a){this[_0xd0af('0x18')]=_0x1a7c0a;io['to'](util[_0xd0af('0x21')](_0xd0af('0x25'),_0x2cefa6[_0xd0af('0x26')]))[_0xd0af('0x27')](_0xd0af('0x28'),_[_0xd0af('0x29')](_0x2cefa6,[_0xd0af('0x12')]));io[_0xd0af('0x27')](_0xd0af('0x2a'),_0x2cefa6);}};module['exports']=Agent;