69a555242d5a7626ff0dca4f8f85baca600f130f
[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 _0x3fd8=['voiceStatusQueue','local','updateStatusRealtime','toLowerCase','idle','inuse','voiceStatus','statePause','toNumber','accountcode','status','onhold','stringify','format','user:%s','user:ami:update','omit','emit','user:presence','lodash','md5','ioredis','../../../config/environment','redis','socket.io-emitter','name','email','fullname','state','unknown','stateTime','address','mobile','online','voiceStatusTime','voiceStatusCallerIdNumber'];(function(_0x199572,_0x33e667){var _0x13cfa3=function(_0x53c075){while(--_0x53c075){_0x199572['push'](_0x199572['shift']());}};_0x13cfa3(++_0x33e667);}(_0x3fd8,0xa3));var _0x83fd=function(_0x1b62ca,_0x3f621a){_0x1b62ca=_0x1b62ca-0x0;var _0x2f71a9=_0x3fd8[_0x1b62ca];return _0x2f71a9;};'use strict';var _=require(_0x83fd('0x0'));var util=require('util');var moment=require('moment');var md5=require(_0x83fd('0x1'));var Redis=require(_0x83fd('0x2'));var config=require(_0x83fd('0x3'));config[_0x83fd('0x4')]=_['defaults'](config[_0x83fd('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0x83fd('0x5'))(new Redis(config[_0x83fd('0x4')]));function Agent(_0x4d948c){this['id']=_0x4d948c['id']||0x0;this[_0x83fd('0x6')]=_0x4d948c[_0x83fd('0x6')]||'';this[_0x83fd('0x7')]=_0x4d948c[_0x83fd('0x7')]||'';this['accountcode']=_0x4d948c['accountcode']||'';this['fullname']=_0x4d948c[_0x83fd('0x8')]||'';this[_0x83fd('0x9')]=_0x83fd('0xa');this[_0x83fd('0xb')]=0x0;this['status']=_0x83fd('0xa');this[_0x83fd('0xc')]='';this['phone']='';this[_0x83fd('0xd')]='';this['interface']='';this[_0x83fd('0xe')]=_0x4d948c[_0x83fd('0xe')]||![];this['voiceStatus']=_0x83fd('0xa');this[_0x83fd('0xf')]=0x0;this[_0x83fd('0x10')]='';this[_0x83fd('0x11')]='';this['onhold']=![];this[_0x83fd('0x12')]=![];this['md5']='';}Agent['prototype'][_0x83fd('0x13')]=function(_0x2d99b4){var _0x68ef17;if(_0x2d99b4&&_0x2d99b4[_0x83fd('0x9')]){_0x68ef17=_0x2d99b4['state'][_0x83fd('0x14')]();switch(_0x68ef17){case'not_inuse':_0x68ef17=_0x83fd('0x15');break;case _0x83fd('0x16'):_0x68ef17='talking';break;}}if(_0x68ef17&&this[_0x83fd('0x17')]!==_0x68ef17||_0x2d99b4[_0x83fd('0x18')]){this[_0x83fd('0xf')]=_[_0x83fd('0x19')](moment()['format']('x'));}if(_0x68ef17){this[_0x83fd('0x17')]=_0x68ef17;}var _0x2db2ab={'id':this['id'],'name':this[_0x83fd('0x6')],'email':this[_0x83fd('0x7')],'accountcode':this[_0x83fd('0x1a')],'fullname':this[_0x83fd('0x8')],'state':this[_0x83fd('0x9')],'stateTime':this['stateTime'],'status':this[_0x83fd('0x1b')],'address':this[_0x83fd('0xc')],'online':this[_0x83fd('0xe')],'voiceStatus':this[_0x83fd('0x17')],'voiceStatusTime':this[_0x83fd('0xf')],'voiceStatusCallerIdNumber':this[_0x83fd('0x10')],'voiceStatusQueue':this[_0x83fd('0x11')],'interface':this['interface'],'onhold':this[_0x83fd('0x1c')]};var _0x606062=md5(JSON[_0x83fd('0x1d')](_0x2db2ab));if(this['md5']!==_0x606062){this[_0x83fd('0x1')]=_0x606062;io['to'](util[_0x83fd('0x1e')](_0x83fd('0x1f'),_0x2db2ab[_0x83fd('0x6')]))['emit'](_0x83fd('0x20'),_[_0x83fd('0x21')](_0x2db2ab,[_0x83fd('0xe')]));io[_0x83fd('0x22')](_0x83fd('0x23'),_0x2db2ab);}};module['exports']=Agent;