b649a8cab221d923f8c5dea6281bc1ec2ec45e3f
[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 _0x00ff=['online','voiceStatus','voiceStatusCallerIdNumber','voiceStatusQueue','onhold','local','prototype','updateStatusRealtime','state','toLowerCase','not_inuse','statePause','voiceStatusTime','toNumber','stringify','user:%s','user:ami:update','omit','emit','user:presence','lodash','util','moment','md5','ioredis','../../../config/environment','redis','localhost','name','email','accountcode','fullname','stateTime','status','unknown','address','mobile','interface'];(function(_0x256e32,_0x4013bc){var _0x464070=function(_0x449398){while(--_0x449398){_0x256e32['push'](_0x256e32['shift']());}};_0x464070(++_0x4013bc);}(_0x00ff,0xf8));var _0xf00f=function(_0x4aa03f,_0x53fa76){_0x4aa03f=_0x4aa03f-0x0;var _0xee82eb=_0x00ff[_0x4aa03f];return _0xee82eb;};'use strict';var _=require(_0xf00f('0x0'));var util=require(_0xf00f('0x1'));var moment=require(_0xf00f('0x2'));var md5=require(_0xf00f('0x3'));var Redis=require(_0xf00f('0x4'));var config=require(_0xf00f('0x5'));config['redis']=_['defaults'](config[_0xf00f('0x6')],{'host':_0xf00f('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xf00f('0x6')]));function Agent(_0x142654){this['id']=_0x142654['id']||0x0;this['name']=_0x142654[_0xf00f('0x8')]||'';this[_0xf00f('0x9')]=_0x142654['email']||'';this[_0xf00f('0xa')]=_0x142654[_0xf00f('0xa')]||'';this[_0xf00f('0xb')]=_0x142654[_0xf00f('0xb')]||'';this['state']='unknown';this[_0xf00f('0xc')]=0x0;this[_0xf00f('0xd')]=_0xf00f('0xe');this[_0xf00f('0xf')]='';this['phone']='';this[_0xf00f('0x10')]='';this[_0xf00f('0x11')]='';this[_0xf00f('0x12')]=_0x142654[_0xf00f('0x12')]||![];this[_0xf00f('0x13')]=_0xf00f('0xe');this['voiceStatusTime']=0x0;this[_0xf00f('0x14')]='';this[_0xf00f('0x15')]='';this[_0xf00f('0x16')]=![];this[_0xf00f('0x17')]=![];this[_0xf00f('0x3')]='';}Agent[_0xf00f('0x18')][_0xf00f('0x19')]=function(_0x37e2c4){var _0x43815e;if(_0x37e2c4&&_0x37e2c4['state']){_0x43815e=_0x37e2c4[_0xf00f('0x1a')][_0xf00f('0x1b')]();switch(_0x43815e){case _0xf00f('0x1c'):_0x43815e='idle';break;case'inuse':_0x43815e='talking';break;}}if(_0x43815e&&this[_0xf00f('0x13')]!==_0x43815e||_0x37e2c4[_0xf00f('0x1d')]){this[_0xf00f('0x1e')]=_[_0xf00f('0x1f')](moment()['format']('x'));}if(_0x43815e){this['voiceStatus']=_0x43815e;}var _0x2488ed={'id':this['id'],'name':this['name'],'email':this[_0xf00f('0x9')],'accountcode':this[_0xf00f('0xa')],'fullname':this[_0xf00f('0xb')],'state':this['state'],'stateTime':this[_0xf00f('0xc')],'status':this['status'],'address':this[_0xf00f('0xf')],'online':this[_0xf00f('0x12')],'voiceStatus':this['voiceStatus'],'voiceStatusTime':this[_0xf00f('0x1e')],'voiceStatusCallerIdNumber':this[_0xf00f('0x14')],'voiceStatusQueue':this[_0xf00f('0x15')],'interface':this[_0xf00f('0x11')],'onhold':this['onhold']};var _0x2b5994=md5(JSON[_0xf00f('0x20')](_0x2488ed));if(this[_0xf00f('0x3')]!==_0x2b5994){this[_0xf00f('0x3')]=_0x2b5994;io['to'](util['format'](_0xf00f('0x21'),_0x2488ed['name']))['emit'](_0xf00f('0x22'),_[_0xf00f('0x23')](_0x2488ed,[_0xf00f('0x12')]));io[_0xf00f('0x24')](_0xf00f('0x25'),_0x2488ed);}};module['exports']=Agent;