Built motion from commit 953226e6.|2.6.32
[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 _0x0397=['email','accountcode','fullname','state','stateTime','unknown','address','phone','interface','online','voiceStatus','voiceStatusTime','voiceStatusQueue','local','prototype','toLowerCase','not_inuse','idle','inuse','talking','statePause','toNumber','format','status','voiceStatusCallerIdNumber','onhold','stringify','user:%s','emit','user:ami:update','omit','user:presence','util','moment','md5','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name'];(function(_0x6eb833,_0x2bb5e5){var _0xdfc38c=function(_0x13c4a4){while(--_0x13c4a4){_0x6eb833['push'](_0x6eb833['shift']());}};_0xdfc38c(++_0x2bb5e5);}(_0x0397,0x13f));var _0x7039=function(_0x287a47,_0x2f731c){_0x287a47=_0x287a47-0x0;var _0x3fb726=_0x0397[_0x287a47];return _0x3fb726;};'use strict';var _=require('lodash');var util=require(_0x7039('0x0'));var moment=require(_0x7039('0x1'));var md5=require(_0x7039('0x2'));var Redis=require('ioredis');var config=require(_0x7039('0x3'));config[_0x7039('0x4')]=_[_0x7039('0x5')](config[_0x7039('0x4')],{'host':_0x7039('0x6'),'port':0x18eb});var io=require(_0x7039('0x7'))(new Redis(config[_0x7039('0x4')]));function Agent(_0x58b31e){this['id']=_0x58b31e['id']||0x0;this[_0x7039('0x8')]=_0x58b31e['name']||'';this[_0x7039('0x9')]=_0x58b31e[_0x7039('0x9')]||'';this[_0x7039('0xa')]=_0x58b31e[_0x7039('0xa')]||'';this[_0x7039('0xb')]=_0x58b31e[_0x7039('0xb')]||'';this[_0x7039('0xc')]='unknown';this[_0x7039('0xd')]=0x0;this['status']=_0x7039('0xe');this[_0x7039('0xf')]='';this[_0x7039('0x10')]='';this['mobile']='';this[_0x7039('0x11')]='';this[_0x7039('0x12')]=_0x58b31e['online']||![];this[_0x7039('0x13')]='unknown';this[_0x7039('0x14')]=0x0;this['voiceStatusCallerIdNumber']='';this[_0x7039('0x15')]='';this['onhold']=![];this[_0x7039('0x16')]=![];this[_0x7039('0x2')]='';}Agent[_0x7039('0x17')]['updateStatusRealtime']=function(_0x29c700){var _0x3359ed;if(_0x29c700&&_0x29c700['state']){_0x3359ed=_0x29c700[_0x7039('0xc')][_0x7039('0x18')]();switch(_0x3359ed){case _0x7039('0x19'):_0x3359ed=_0x7039('0x1a');break;case _0x7039('0x1b'):_0x3359ed=_0x7039('0x1c');break;}}if(_0x3359ed&&this[_0x7039('0x13')]!==_0x3359ed||_0x29c700[_0x7039('0x1d')]){this[_0x7039('0x14')]=_[_0x7039('0x1e')](moment()[_0x7039('0x1f')]('x'));}if(_0x3359ed){this[_0x7039('0x13')]=_0x3359ed;}var _0x3a97e5={'id':this['id'],'name':this['name'],'email':this['email'],'accountcode':this['accountcode'],'fullname':this[_0x7039('0xb')],'state':this[_0x7039('0xc')],'stateTime':this[_0x7039('0xd')],'status':this[_0x7039('0x20')],'address':this['address'],'online':this[_0x7039('0x12')],'voiceStatus':this[_0x7039('0x13')],'voiceStatusTime':this[_0x7039('0x14')],'voiceStatusCallerIdNumber':this[_0x7039('0x21')],'voiceStatusQueue':this[_0x7039('0x15')],'interface':this[_0x7039('0x11')],'onhold':this[_0x7039('0x22')]};var _0x3db92c=md5(JSON[_0x7039('0x23')](_0x3a97e5));if(this['md5']!==_0x3db92c){this['md5']=_0x3db92c;io['to'](util[_0x7039('0x1f')](_0x7039('0x24'),_0x3a97e5['name']))[_0x7039('0x25')](_0x7039('0x26'),_[_0x7039('0x27')](_0x3a97e5,[_0x7039('0x12')]));io[_0x7039('0x25')](_0x7039('0x28'),_0x3a97e5);}};module['exports']=Agent;