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