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