b00e3fefa66583f65fc61e8427ce967771559f88
[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 _0xd1e5=['online','voiceStatus','voiceStatusTime','voiceStatusQueue','local','prototype','updateStatusRealtime','toLowerCase','not_inuse','inuse','talking','statePause','toNumber','voiceStatusCallerIdNumber','onhold','stringify','format','user:%s','emit','user:save','exports','lodash','util','md5','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','email','accountcode','fullname','state','stateTime','status','unknown','address','phone','mobile','interface'];(function(_0x350277,_0x25d306){var _0x5e418b=function(_0x19c176){while(--_0x19c176){_0x350277['push'](_0x350277['shift']());}};_0x5e418b(++_0x25d306);}(_0xd1e5,0x1e3));var _0x5d1e=function(_0x104a88,_0x5d5cc5){_0x104a88=_0x104a88-0x0;var _0x2223c4=_0xd1e5[_0x104a88];return _0x2223c4;};'use strict';var _=require(_0x5d1e('0x0'));var util=require(_0x5d1e('0x1'));var moment=require('moment');var md5=require(_0x5d1e('0x2'));var Redis=require(_0x5d1e('0x3'));var config=require(_0x5d1e('0x4'));config[_0x5d1e('0x5')]=_[_0x5d1e('0x6')](config[_0x5d1e('0x5')],{'host':_0x5d1e('0x7'),'port':0x18eb});var io=require(_0x5d1e('0x8'))(new Redis(config[_0x5d1e('0x5')]));function Agent(_0x2fbea0){this['id']=_0x2fbea0['id']||0x0;this[_0x5d1e('0x9')]=_0x2fbea0[_0x5d1e('0x9')]||'';this[_0x5d1e('0xa')]=_0x2fbea0[_0x5d1e('0xa')]||'';this[_0x5d1e('0xb')]=_0x2fbea0['accountcode']||'';this[_0x5d1e('0xc')]=_0x2fbea0[_0x5d1e('0xc')]||'';this[_0x5d1e('0xd')]='unknown';this[_0x5d1e('0xe')]=0x0;this[_0x5d1e('0xf')]=_0x5d1e('0x10');this[_0x5d1e('0x11')]='';this[_0x5d1e('0x12')]='';this[_0x5d1e('0x13')]='';this[_0x5d1e('0x14')]='';this[_0x5d1e('0x15')]=_0x2fbea0[_0x5d1e('0x15')]||![];this[_0x5d1e('0x16')]=_0x5d1e('0x10');this[_0x5d1e('0x17')]=0x0;this['voiceStatusCallerIdNumber']='';this[_0x5d1e('0x18')]='';this['onhold']=![];this[_0x5d1e('0x19')]=![];this['md5']='';}Agent[_0x5d1e('0x1a')][_0x5d1e('0x1b')]=function(_0x4ff8e8){var _0x119335;if(_0x4ff8e8&&_0x4ff8e8[_0x5d1e('0xd')]){_0x119335=_0x4ff8e8[_0x5d1e('0xd')][_0x5d1e('0x1c')]();switch(_0x119335){case _0x5d1e('0x1d'):_0x119335='idle';break;case _0x5d1e('0x1e'):_0x119335=_0x5d1e('0x1f');break;}}if(_0x119335&&this[_0x5d1e('0x16')]!==_0x119335||_0x4ff8e8[_0x5d1e('0x20')]){this[_0x5d1e('0x17')]=_[_0x5d1e('0x21')](moment()['format']('x'));}if(_0x119335){this[_0x5d1e('0x16')]=_0x119335;}var _0x665720={'id':this['id'],'name':this[_0x5d1e('0x9')],'email':this[_0x5d1e('0xa')],'accountcode':this['accountcode'],'fullname':this['fullname'],'state':this[_0x5d1e('0xd')],'stateTime':this['stateTime'],'status':this[_0x5d1e('0xf')],'address':this[_0x5d1e('0x11')],'online':this[_0x5d1e('0x15')],'voiceStatus':this[_0x5d1e('0x16')],'voiceStatusTime':this[_0x5d1e('0x17')],'voiceStatusCallerIdNumber':this[_0x5d1e('0x22')],'voiceStatusQueue':this[_0x5d1e('0x18')],'interface':this[_0x5d1e('0x14')],'onhold':this[_0x5d1e('0x23')]};var _0x30d78e=md5(JSON[_0x5d1e('0x24')](_0x665720));if(this[_0x5d1e('0x2')]!==_0x30d78e){this['md5']=_0x30d78e;io['to'](util[_0x5d1e('0x25')](_0x5d1e('0x26'),_0x665720[_0x5d1e('0x9')]))[_0x5d1e('0x27')](_0x5d1e('0x28'),_0x665720);}};module[_0x5d1e('0x29')]=Agent;