6e3d60c88de6d622d595e2eacd2a79cc31cf321c
[motion2.git] / server / services / routing / model / smsQueue.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 _0xf109=['loggedIn','online','smsPause','available','paused','stringify','format','sms:queue:%s','emit','exports','lodash','md5','util','defaults','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr'];(function(_0x13ea7d,_0x452aad){var _0x4463a1=function(_0x546219){while(--_0x546219){_0x13ea7d['push'](_0x13ea7d['shift']());}};_0x4463a1(++_0x452aad);}(_0xf109,0xce));var _0x9f10=function(_0x8a969d,_0x339d9f){_0x8a969d=_0x8a969d-0x0;var _0x1d8dc7=_0xf109[_0x8a969d];return _0x1d8dc7;};'use strict';var _=require(_0x9f10('0x0'));var md5=require(_0x9f10('0x1'));var util=require(_0x9f10('0x2'));var Redis=require('ioredis');var config=require('../../../config/environment');config['redis']=_[_0x9f10('0x3')](config[_0x9f10('0x4')],{'host':_0x9f10('0x5'),'port':0x18eb});var io=require(_0x9f10('0x6'))(new Redis(config[_0x9f10('0x4')]));function SmsQueue(_0x3e30c0){this['id']=_0x3e30c0['id']||0x0;this[_0x9f10('0x7')]=_0x3e30c0[_0x9f10('0x7')]||'';this[_0x9f10('0x8')]=_0x3e30c0[_0x9f10('0x8')]||0xa;this[_0x9f10('0x9')]=_0x3e30c0['strategy']||_0x9f10('0xa');this[_0x9f10('0xb')]=_0x3e30c0[_0x9f10('0xb')];this[_0x9f10('0xc')]={};this[_0x9f10('0xd')]=0x0;this['md5']='';this[_0x9f10('0xe')]();this[_0x9f10('0xf')]();}SmsQueue[_0x9f10('0x10')]['updateRouting']=function(){var _0x50215f=this[_0x9f10('0xc')][_0x9f10('0x11')];this[_0x9f10('0xc')]=_['map'](this[_0x9f10('0xb')],'id');this[_0x9f10('0xc')][_0x9f10('0x11')]=_0x50215f;};SmsQueue['prototype'][_0x9f10('0xf')]=function(){this[_0x9f10('0x12')]=0x0;this['paused']=0x0;for(var _0x40a48a=0x0;_0x40a48a<this[_0x9f10('0xb')]['length'];_0x40a48a+=0x1){if(this['Agents'][_0x40a48a][_0x9f10('0x13')]){this[_0x9f10('0x12')]+=0x1;}if(this['Agents'][_0x40a48a][_0x9f10('0x14')]){this['paused']+=0x1;}}this[_0x9f10('0x15')]=this[_0x9f10('0x12')]-this['paused'];this[_0x9f10('0x15')]=this[_0x9f10('0x15')]>=0x0?this['available']:0x0;var _0x150813={'id':this['id'],'available':this['available'],'loggedIn':this[_0x9f10('0x12')],'name':this['name'],'paused':this[_0x9f10('0x16')],'waiting':this['waiting']};var _0x54c262=md5(JSON[_0x9f10('0x17')](_0x150813));if(this[_0x9f10('0x1')]!==_0x54c262){this[_0x9f10('0x1')]=_0x54c262;io['to'](util[_0x9f10('0x18')](_0x9f10('0x19'),_0x150813[_0x9f10('0x7')]))[_0x9f10('0x1a')]('sms_queue:save',_0x150813);}};module[_0x9f10('0x1b')]=SmsQueue;