ecbf281796e79fccdbc338c4622722f2f7d7f19c
[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 _0xccb4=['md5','ioredis','redis','localhost','socket.io-emitter','name','email','accountcode','fullname','state','unknown','status','address','phone','mobile','interface','online','voiceStatus','voiceStatusCallerIdNumber','voiceStatusQueue','onhold','updateStatusRealtime','toLowerCase','idle','inuse','talking','statePause','voiceStatusTime','toNumber','format','user:%s','emit','user:save','user:presence','exports','util','moment'];(function(_0x24e5e1,_0x1b5473){var _0x11e76b=function(_0xc7a80d){while(--_0xc7a80d){_0x24e5e1['push'](_0x24e5e1['shift']());}};_0x11e76b(++_0x1b5473);}(_0xccb4,0x101));var _0x4ccb=function(_0x231e16,_0x67347b){_0x231e16=_0x231e16-0x0;var _0x570a7c=_0xccb4[_0x231e16];return _0x570a7c;};'use strict';var _=require('lodash');var util=require(_0x4ccb('0x0'));var moment=require(_0x4ccb('0x1'));var md5=require(_0x4ccb('0x2'));var Redis=require(_0x4ccb('0x3'));var config=require('../../../config/environment');config[_0x4ccb('0x4')]=_['defaults'](config[_0x4ccb('0x4')],{'host':_0x4ccb('0x5'),'port':0x18eb});var io=require(_0x4ccb('0x6'))(new Redis(config['redis']));function Agent(_0x47d07f){this['id']=_0x47d07f['id']||0x0;this[_0x4ccb('0x7')]=_0x47d07f['name']||'';this[_0x4ccb('0x8')]=_0x47d07f[_0x4ccb('0x8')]||'';this['accountcode']=_0x47d07f[_0x4ccb('0x9')]||'';this[_0x4ccb('0xa')]=_0x47d07f[_0x4ccb('0xa')]||'';this[_0x4ccb('0xb')]=_0x4ccb('0xc');this['stateTime']=0x0;this[_0x4ccb('0xd')]=_0x4ccb('0xc');this[_0x4ccb('0xe')]='';this[_0x4ccb('0xf')]='';this[_0x4ccb('0x10')]='';this[_0x4ccb('0x11')]='';this[_0x4ccb('0x12')]=_0x47d07f['online']||![];this[_0x4ccb('0x13')]='unknown';this['voiceStatusTime']=0x0;this[_0x4ccb('0x14')]='';this[_0x4ccb('0x15')]='';this[_0x4ccb('0x16')]=![];this['local']=![];this[_0x4ccb('0x2')]='';}Agent['prototype'][_0x4ccb('0x17')]=function(_0x4ca4d6){var _0x22e90b;if(_0x4ca4d6&&_0x4ca4d6[_0x4ccb('0xb')]){_0x22e90b=_0x4ca4d6[_0x4ccb('0xb')][_0x4ccb('0x18')]();switch(_0x22e90b){case'not_inuse':_0x22e90b=_0x4ccb('0x19');break;case _0x4ccb('0x1a'):_0x22e90b=_0x4ccb('0x1b');break;}}if(_0x22e90b&&this[_0x4ccb('0x13')]!==_0x22e90b||_0x4ca4d6[_0x4ccb('0x1c')]){this[_0x4ccb('0x1d')]=_[_0x4ccb('0x1e')](moment()[_0x4ccb('0x1f')]('x'));}if(_0x22e90b){this[_0x4ccb('0x13')]=_0x22e90b;}var _0x2d77bc={'id':this['id'],'name':this[_0x4ccb('0x7')],'email':this[_0x4ccb('0x8')],'accountcode':this[_0x4ccb('0x9')],'fullname':this[_0x4ccb('0xa')],'state':this[_0x4ccb('0xb')],'stateTime':this['stateTime'],'status':this['status'],'address':this[_0x4ccb('0xe')],'online':this['online'],'voiceStatus':this['voiceStatus'],'voiceStatusTime':this[_0x4ccb('0x1d')],'voiceStatusCallerIdNumber':this[_0x4ccb('0x14')],'voiceStatusQueue':this['voiceStatusQueue'],'interface':this[_0x4ccb('0x11')],'onhold':this[_0x4ccb('0x16')]};var _0x53a87f=md5(JSON['stringify'](_0x2d77bc));if(this[_0x4ccb('0x2')]!==_0x53a87f){this[_0x4ccb('0x2')]=_0x53a87f;io['to'](util[_0x4ccb('0x1f')](_0x4ccb('0x20'),_0x2d77bc[_0x4ccb('0x7')]))[_0x4ccb('0x21')](_0x4ccb('0x22'),_0x2d77bc);io[_0x4ccb('0x21')](_0x4ccb('0x23'),_0x2d77bc);}};module[_0x4ccb('0x24')]=Agent;