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