Built motion from commit c738b9ac.|2.6.25
[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 _0x7e40=['toLowerCase','not_inuse','idle','talking','voiceStatus','statePause','toNumber','format','stateTime','status','stringify','user:ami:update','omit','emit','exports','util','moment','ioredis','redis','socket.io-emitter','name','email','accountcode','fullname','state','unknown','phone','mobile','interface','online','voiceStatusTime','voiceStatusQueue','onhold','local','md5','prototype'];(function(_0x412cad,_0x4a0234){var _0x39a591=function(_0x31e4c2){while(--_0x31e4c2){_0x412cad['push'](_0x412cad['shift']());}};_0x39a591(++_0x4a0234);}(_0x7e40,0x9f));var _0x07e4=function(_0x5732d6,_0x2c9500){_0x5732d6=_0x5732d6-0x0;var _0x3a1a0f=_0x7e40[_0x5732d6];return _0x3a1a0f;};'use strict';var _=require('lodash');var util=require(_0x07e4('0x0'));var moment=require(_0x07e4('0x1'));var md5=require('md5');var Redis=require(_0x07e4('0x2'));var config=require('../../../config/environment');config['redis']=_['defaults'](config[_0x07e4('0x3')],{'host':'localhost','port':0x18eb});var io=require(_0x07e4('0x4'))(new Redis(config['redis']));function Agent(_0x4b1c3f){this['id']=_0x4b1c3f['id']||0x0;this['name']=_0x4b1c3f[_0x07e4('0x5')]||'';this[_0x07e4('0x6')]=_0x4b1c3f[_0x07e4('0x6')]||'';this[_0x07e4('0x7')]=_0x4b1c3f[_0x07e4('0x7')]||'';this['fullname']=_0x4b1c3f[_0x07e4('0x8')]||'';this[_0x07e4('0x9')]='unknown';this['stateTime']=0x0;this['status']=_0x07e4('0xa');this['address']='';this[_0x07e4('0xb')]='';this[_0x07e4('0xc')]='';this[_0x07e4('0xd')]='';this['online']=_0x4b1c3f[_0x07e4('0xe')]||![];this['voiceStatus']=_0x07e4('0xa');this[_0x07e4('0xf')]=0x0;this['voiceStatusCallerIdNumber']='';this[_0x07e4('0x10')]='';this[_0x07e4('0x11')]=![];this[_0x07e4('0x12')]=![];this[_0x07e4('0x13')]='';}Agent[_0x07e4('0x14')]['updateStatusRealtime']=function(_0x3cb034){var _0x304d1d;if(_0x3cb034&&_0x3cb034[_0x07e4('0x9')]){_0x304d1d=_0x3cb034[_0x07e4('0x9')][_0x07e4('0x15')]();switch(_0x304d1d){case _0x07e4('0x16'):_0x304d1d=_0x07e4('0x17');break;case'inuse':_0x304d1d=_0x07e4('0x18');break;}}if(_0x304d1d&&this[_0x07e4('0x19')]!==_0x304d1d||_0x3cb034[_0x07e4('0x1a')]){this[_0x07e4('0xf')]=_[_0x07e4('0x1b')](moment()[_0x07e4('0x1c')]('x'));}if(_0x304d1d){this[_0x07e4('0x19')]=_0x304d1d;}var _0x3045a5={'id':this['id'],'name':this[_0x07e4('0x5')],'email':this['email'],'accountcode':this[_0x07e4('0x7')],'fullname':this[_0x07e4('0x8')],'state':this['state'],'stateTime':this[_0x07e4('0x1d')],'status':this[_0x07e4('0x1e')],'address':this['address'],'online':this['online'],'voiceStatus':this[_0x07e4('0x19')],'voiceStatusTime':this[_0x07e4('0xf')],'voiceStatusCallerIdNumber':this['voiceStatusCallerIdNumber'],'voiceStatusQueue':this['voiceStatusQueue'],'interface':this[_0x07e4('0xd')],'onhold':this['onhold']};var _0x2553cc=md5(JSON[_0x07e4('0x1f')](_0x3045a5));if(this[_0x07e4('0x13')]!==_0x2553cc){this[_0x07e4('0x13')]=_0x2553cc;io['to'](util[_0x07e4('0x1c')]('user:%s',_0x3045a5[_0x07e4('0x5')]))['emit'](_0x07e4('0x20'),_[_0x07e4('0x21')](_0x3045a5,[_0x07e4('0xe')]));io[_0x07e4('0x22')]('user:presence',_0x3045a5);}};module[_0x07e4('0x23')]=Agent;