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