Built motion from commit (unavailable).|2.5.23
[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 _0x5f6d=['name','email','accountcode','fullname','unknown','stateTime','status','phone','mobile','interface','online','voiceStatus','voiceStatusTime','voiceStatusCallerIdNumber','voiceStatusQueue','onhold','md5','prototype','updateStatusRealtime','state','not_inuse','idle','talking','toNumber','format','stringify','user:%s','user:save','user:presence','exports','util','ioredis','../../../config/environment','redis','defaults','localhost'];(function(_0xf27504,_0x41df27){var _0x3ec4c6=function(_0x29bd63){while(--_0x29bd63){_0xf27504['push'](_0xf27504['shift']());}};_0x3ec4c6(++_0x41df27);}(_0x5f6d,0x11a));var _0xd5f6=function(_0x29426f,_0x1bf472){_0x29426f=_0x29426f-0x0;var _0x52b29a=_0x5f6d[_0x29426f];return _0x52b29a;};'use strict';var _=require('lodash');var util=require(_0xd5f6('0x0'));var moment=require('moment');var md5=require('md5');var Redis=require(_0xd5f6('0x1'));var config=require(_0xd5f6('0x2'));config[_0xd5f6('0x3')]=_[_0xd5f6('0x4')](config[_0xd5f6('0x3')],{'host':_0xd5f6('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xd5f6('0x3')]));function Agent(_0x48e2cf){this['id']=_0x48e2cf['id']||0x0;this[_0xd5f6('0x6')]=_0x48e2cf[_0xd5f6('0x6')]||'';this['email']=_0x48e2cf[_0xd5f6('0x7')]||'';this[_0xd5f6('0x8')]=_0x48e2cf[_0xd5f6('0x8')]||'';this['fullname']=_0x48e2cf[_0xd5f6('0x9')]||'';this['state']=_0xd5f6('0xa');this[_0xd5f6('0xb')]=0x0;this[_0xd5f6('0xc')]='unknown';this['address']='';this[_0xd5f6('0xd')]='';this[_0xd5f6('0xe')]='';this[_0xd5f6('0xf')]='';this[_0xd5f6('0x10')]=_0x48e2cf[_0xd5f6('0x10')]||![];this[_0xd5f6('0x11')]=_0xd5f6('0xa');this[_0xd5f6('0x12')]=0x0;this[_0xd5f6('0x13')]='';this[_0xd5f6('0x14')]='';this[_0xd5f6('0x15')]=![];this['local']=![];this[_0xd5f6('0x16')]='';}Agent[_0xd5f6('0x17')][_0xd5f6('0x18')]=function(_0x2054ac){var _0x4fee16;if(_0x2054ac&&_0x2054ac[_0xd5f6('0x19')]){_0x4fee16=_0x2054ac[_0xd5f6('0x19')]['toLowerCase']();switch(_0x4fee16){case _0xd5f6('0x1a'):_0x4fee16=_0xd5f6('0x1b');break;case'inuse':_0x4fee16=_0xd5f6('0x1c');break;}}if(_0x4fee16&&this['voiceStatus']!==_0x4fee16||_0x2054ac['statePause']){this[_0xd5f6('0x12')]=_[_0xd5f6('0x1d')](moment()[_0xd5f6('0x1e')]('x'));}if(_0x4fee16){this[_0xd5f6('0x11')]=_0x4fee16;}var _0x268ec4={'id':this['id'],'name':this[_0xd5f6('0x6')],'email':this[_0xd5f6('0x7')],'accountcode':this[_0xd5f6('0x8')],'fullname':this[_0xd5f6('0x9')],'state':this[_0xd5f6('0x19')],'stateTime':this['stateTime'],'status':this[_0xd5f6('0xc')],'address':this['address'],'online':this[_0xd5f6('0x10')],'voiceStatus':this[_0xd5f6('0x11')],'voiceStatusTime':this[_0xd5f6('0x12')],'voiceStatusCallerIdNumber':this[_0xd5f6('0x13')],'voiceStatusQueue':this['voiceStatusQueue'],'interface':this[_0xd5f6('0xf')],'onhold':this[_0xd5f6('0x15')]};var _0x1d99fa=md5(JSON[_0xd5f6('0x1f')](_0x268ec4));if(this[_0xd5f6('0x16')]!==_0x1d99fa){this['md5']=_0x1d99fa;io['to'](util[_0xd5f6('0x1e')](_0xd5f6('0x20'),_0x268ec4['name']))['emit'](_0xd5f6('0x21'),_0x268ec4);io['emit'](_0xd5f6('0x22'),_0x268ec4);}};module[_0xd5f6('0x23')]=Agent;