Built motion from commit 10af8726.|2.6.34
[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 _0x130f=['fullname','stateTime','status','unknown','address','phone','mobile','interface','online','voiceStatus','voiceStatusTime','voiceStatusCallerIdNumber','voiceStatusQueue','onhold','local','prototype','updateStatusRealtime','state','toLowerCase','not_inuse','idle','talking','statePause','format','stringify','user:%s','omit','emit','user:presence','exports','lodash','md5','ioredis','../../../config/environment','defaults','redis','socket.io-emitter','name','email','accountcode'];(function(_0x3b6c15,_0x1c663f){var _0x439db8=function(_0x576311){while(--_0x576311){_0x3b6c15['push'](_0x3b6c15['shift']());}};_0x439db8(++_0x1c663f);}(_0x130f,0xbe));var _0xf130=function(_0x25bddc,_0x1d6ca2){_0x25bddc=_0x25bddc-0x0;var _0x289fce=_0x130f[_0x25bddc];return _0x289fce;};'use strict';var _=require(_0xf130('0x0'));var util=require('util');var moment=require('moment');var md5=require(_0xf130('0x1'));var Redis=require(_0xf130('0x2'));var config=require(_0xf130('0x3'));config['redis']=_[_0xf130('0x4')](config[_0xf130('0x5')],{'host':'localhost','port':0x18eb});var io=require(_0xf130('0x6'))(new Redis(config['redis']));function Agent(_0x2d979e){this['id']=_0x2d979e['id']||0x0;this[_0xf130('0x7')]=_0x2d979e[_0xf130('0x7')]||'';this[_0xf130('0x8')]=_0x2d979e['email']||'';this[_0xf130('0x9')]=_0x2d979e[_0xf130('0x9')]||'';this['fullname']=_0x2d979e[_0xf130('0xa')]||'';this['state']='unknown';this[_0xf130('0xb')]=0x0;this[_0xf130('0xc')]=_0xf130('0xd');this[_0xf130('0xe')]='';this[_0xf130('0xf')]='';this[_0xf130('0x10')]='';this[_0xf130('0x11')]='';this['online']=_0x2d979e[_0xf130('0x12')]||![];this[_0xf130('0x13')]=_0xf130('0xd');this[_0xf130('0x14')]=0x0;this[_0xf130('0x15')]='';this[_0xf130('0x16')]='';this[_0xf130('0x17')]=![];this[_0xf130('0x18')]=![];this[_0xf130('0x1')]='';}Agent[_0xf130('0x19')][_0xf130('0x1a')]=function(_0x320a48){var _0xeb50a7;if(_0x320a48&&_0x320a48['state']){_0xeb50a7=_0x320a48[_0xf130('0x1b')][_0xf130('0x1c')]();switch(_0xeb50a7){case _0xf130('0x1d'):_0xeb50a7=_0xf130('0x1e');break;case'inuse':_0xeb50a7=_0xf130('0x1f');break;}}if(_0xeb50a7&&this['voiceStatus']!==_0xeb50a7||_0x320a48[_0xf130('0x20')]){this[_0xf130('0x14')]=_['toNumber'](moment()[_0xf130('0x21')]('x'));}if(_0xeb50a7){this[_0xf130('0x13')]=_0xeb50a7;}var _0x5cd152={'id':this['id'],'name':this[_0xf130('0x7')],'email':this[_0xf130('0x8')],'accountcode':this[_0xf130('0x9')],'fullname':this[_0xf130('0xa')],'state':this['state'],'stateTime':this[_0xf130('0xb')],'status':this[_0xf130('0xc')],'address':this[_0xf130('0xe')],'online':this[_0xf130('0x12')],'voiceStatus':this[_0xf130('0x13')],'voiceStatusTime':this[_0xf130('0x14')],'voiceStatusCallerIdNumber':this[_0xf130('0x15')],'voiceStatusQueue':this[_0xf130('0x16')],'interface':this[_0xf130('0x11')],'onhold':this[_0xf130('0x17')]};var _0x4a0b4c=md5(JSON[_0xf130('0x22')](_0x5cd152));if(this['md5']!==_0x4a0b4c){this[_0xf130('0x1')]=_0x4a0b4c;io['to'](util[_0xf130('0x21')](_0xf130('0x23'),_0x5cd152[_0xf130('0x7')]))['emit']('user:ami:update',_[_0xf130('0x24')](_0x5cd152,[_0xf130('0x12')]));io[_0xf130('0x25')](_0xf130('0x26'),_0x5cd152);}};module[_0xf130('0x27')]=Agent;