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