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