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