8ba1780a08a8ef0b8c101de0705c0e20efeaccf2
[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 _0x9db9=['redis','defaults','name','email','accountcode','unknown','status','phone','mobile','interface','online','voiceStatus','voiceStatusTime','local','md5','prototype','updateStatusRealtime','state','toLowerCase','not_inuse','talking','statePause','fullname','stateTime','address','voiceStatusCallerIdNumber','onhold','stringify','emit','exports','lodash','moment'];(function(_0x47aa64,_0xfb8a07){var _0x549c7a=function(_0x266165){while(--_0x266165){_0x47aa64['push'](_0x47aa64['shift']());}};_0x549c7a(++_0xfb8a07);}(_0x9db9,0xfe));var _0x99db=function(_0x21f274,_0x43dc02){_0x21f274=_0x21f274-0x0;var _0xb64c7c=_0x9db9[_0x21f274];return _0xb64c7c;};'use strict';var _=require(_0x99db('0x0'));var util=require('util');var moment=require(_0x99db('0x1'));var md5=require('md5');var Redis=require('ioredis');var config=require('../../../config/environment');config[_0x99db('0x2')]=_[_0x99db('0x3')](config[_0x99db('0x2')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x99db('0x2')]));function Agent(_0x354e94){this['id']=_0x354e94['id']||0x0;this[_0x99db('0x4')]=_0x354e94[_0x99db('0x4')]||'';this['email']=_0x354e94[_0x99db('0x5')]||'';this[_0x99db('0x6')]=_0x354e94[_0x99db('0x6')]||'';this['fullname']=_0x354e94['fullname']||'';this['state']=_0x99db('0x7');this['stateTime']=0x0;this[_0x99db('0x8')]='unknown';this['address']='';this[_0x99db('0x9')]='';this[_0x99db('0xa')]='';this[_0x99db('0xb')]='';this[_0x99db('0xc')]=_0x354e94[_0x99db('0xc')]||![];this[_0x99db('0xd')]=_0x99db('0x7');this[_0x99db('0xe')]=0x0;this['voiceStatusCallerIdNumber']='';this['voiceStatusQueue']='';this['onhold']=![];this[_0x99db('0xf')]=![];this[_0x99db('0x10')]='';}Agent[_0x99db('0x11')][_0x99db('0x12')]=function(_0xafe583){var _0x59d2b0;if(_0xafe583&&_0xafe583['state']){_0x59d2b0=_0xafe583[_0x99db('0x13')][_0x99db('0x14')]();switch(_0x59d2b0){case _0x99db('0x15'):_0x59d2b0='idle';break;case'inuse':_0x59d2b0=_0x99db('0x16');break;}}if(_0x59d2b0&&this[_0x99db('0xd')]!==_0x59d2b0||_0xafe583[_0x99db('0x17')]){this[_0x99db('0xe')]=_['toNumber'](moment()['format']('x'));}if(_0x59d2b0){this[_0x99db('0xd')]=_0x59d2b0;}var _0x2287f2={'id':this['id'],'name':this['name'],'email':this['email'],'accountcode':this[_0x99db('0x6')],'fullname':this[_0x99db('0x18')],'state':this['state'],'stateTime':this[_0x99db('0x19')],'status':this[_0x99db('0x8')],'address':this[_0x99db('0x1a')],'online':this[_0x99db('0xc')],'voiceStatus':this[_0x99db('0xd')],'voiceStatusTime':this[_0x99db('0xe')],'voiceStatusCallerIdNumber':this[_0x99db('0x1b')],'voiceStatusQueue':this['voiceStatusQueue'],'interface':this[_0x99db('0xb')],'onhold':this[_0x99db('0x1c')]};var _0x515b4b=md5(JSON[_0x99db('0x1d')](_0x2287f2));if(this[_0x99db('0x10')]!==_0x515b4b){this[_0x99db('0x10')]=_0x515b4b;io['to'](util['format']('user:%s',_0x2287f2['name']))[_0x99db('0x1e')]('user:save',_0x2287f2);}};module[_0x99db('0x1f')]=Agent;