4e5f87b17a0abda120fd90d820cbe8fa1efe85f2
[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 _0x8d3b=['status','interface','stringify','emit','user:save','exports','util','moment','md5','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','email','accountcode','fullname','state','stateTime','unknown','address','phone','mobile','online','voiceStatus','voiceStatusCallerIdNumber','voiceStatusQueue','onhold','local','prototype','updateStatusRealtime','not_inuse','idle','inuse','talking','voiceStatusTime','format'];(function(_0x4243a3,_0x447337){var _0x1b2a33=function(_0x6a8200){while(--_0x6a8200){_0x4243a3['push'](_0x4243a3['shift']());}};_0x1b2a33(++_0x447337);}(_0x8d3b,0x1f4));var _0xb8d3=function(_0x35c1c9,_0x3dbb6f){_0x35c1c9=_0x35c1c9-0x0;var _0x42bdfc=_0x8d3b[_0x35c1c9];return _0x42bdfc;};'use strict';var _=require('lodash');var util=require(_0xb8d3('0x0'));var moment=require(_0xb8d3('0x1'));var md5=require(_0xb8d3('0x2'));var Redis=require('ioredis');var config=require(_0xb8d3('0x3'));config[_0xb8d3('0x4')]=_[_0xb8d3('0x5')](config[_0xb8d3('0x4')],{'host':_0xb8d3('0x6'),'port':0x18eb});var io=require(_0xb8d3('0x7'))(new Redis(config['redis']));function Agent(_0x3b11e6){this['id']=_0x3b11e6['id']||0x0;this[_0xb8d3('0x8')]=_0x3b11e6[_0xb8d3('0x8')]||'';this[_0xb8d3('0x9')]=_0x3b11e6[_0xb8d3('0x9')]||'';this[_0xb8d3('0xa')]=_0x3b11e6['accountcode']||'';this[_0xb8d3('0xb')]=_0x3b11e6[_0xb8d3('0xb')]||'';this[_0xb8d3('0xc')]='unknown';this[_0xb8d3('0xd')]=0x0;this['status']=_0xb8d3('0xe');this[_0xb8d3('0xf')]='';this[_0xb8d3('0x10')]='';this[_0xb8d3('0x11')]='';this['interface']='';this['online']=_0x3b11e6[_0xb8d3('0x12')]||![];this[_0xb8d3('0x13')]='unknown';this['voiceStatusTime']=0x0;this[_0xb8d3('0x14')]='';this[_0xb8d3('0x15')]='';this[_0xb8d3('0x16')]=![];this[_0xb8d3('0x17')]=![];this[_0xb8d3('0x2')]='';}Agent[_0xb8d3('0x18')][_0xb8d3('0x19')]=function(_0x16ab1a){var _0x35c207;if(_0x16ab1a&&_0x16ab1a[_0xb8d3('0xc')]){_0x35c207=_0x16ab1a['state']['toLowerCase']();switch(_0x35c207){case _0xb8d3('0x1a'):_0x35c207=_0xb8d3('0x1b');break;case _0xb8d3('0x1c'):_0x35c207=_0xb8d3('0x1d');break;}}if(_0x35c207&&this[_0xb8d3('0x13')]!==_0x35c207||_0x16ab1a['statePause']){this[_0xb8d3('0x1e')]=_['toNumber'](moment()[_0xb8d3('0x1f')]('x'));}if(_0x35c207){this[_0xb8d3('0x13')]=_0x35c207;}var _0xddc278={'id':this['id'],'name':this['name'],'email':this[_0xb8d3('0x9')],'accountcode':this[_0xb8d3('0xa')],'fullname':this['fullname'],'state':this[_0xb8d3('0xc')],'stateTime':this[_0xb8d3('0xd')],'status':this[_0xb8d3('0x20')],'address':this[_0xb8d3('0xf')],'online':this[_0xb8d3('0x12')],'voiceStatus':this[_0xb8d3('0x13')],'voiceStatusTime':this['voiceStatusTime'],'voiceStatusCallerIdNumber':this['voiceStatusCallerIdNumber'],'voiceStatusQueue':this[_0xb8d3('0x15')],'interface':this[_0xb8d3('0x21')],'onhold':this[_0xb8d3('0x16')]};var _0x23d3a4=md5(JSON[_0xb8d3('0x22')](_0xddc278));if(this['md5']!==_0x23d3a4){this['md5']=_0x23d3a4;io['to'](util[_0xb8d3('0x1f')]('user:%s',_0xddc278[_0xb8d3('0x8')]))[_0xb8d3('0x23')](_0xb8d3('0x24'),_0xddc278);}};module[_0xb8d3('0x25')]=Agent;