Built motion from commit 20b39a97.|2.6.29
[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 _0xb377=['Agents','mapAgentsId','waiting','updateRouting','prototype','_rr','map','updateRealtime','loggedIn','paused','length','online','available','name','stringify','format','sms_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','timeout','strategy','beepall'];(function(_0x1d6828,_0x30cbb6){var _0x25fa7f=function(_0x6ede4b){while(--_0x6ede4b){_0x1d6828['push'](_0x1d6828['shift']());}};_0x25fa7f(++_0x30cbb6);}(_0xb377,0x1b6));var _0x7b37=function(_0x171f9e,_0x4c22b9){_0x171f9e=_0x171f9e-0x0;var _0x2f0b1e=_0xb377[_0x171f9e];return _0x2f0b1e;};'use strict';var _=require(_0x7b37('0x0'));var md5=require(_0x7b37('0x1'));var util=require(_0x7b37('0x2'));var Redis=require(_0x7b37('0x3'));var config=require(_0x7b37('0x4'));config[_0x7b37('0x5')]=_[_0x7b37('0x6')](config[_0x7b37('0x5')],{'host':_0x7b37('0x7'),'port':0x18eb});var io=require(_0x7b37('0x8'))(new Redis(config[_0x7b37('0x5')]));function SmsQueue(_0x38d1b4){this['id']=_0x38d1b4['id']||0x0;this['name']=_0x38d1b4['name']||'';this[_0x7b37('0x9')]=_0x38d1b4['timeout']||0xa;this['strategy']=_0x38d1b4[_0x7b37('0xa')]||_0x7b37('0xb');this[_0x7b37('0xc')]=_0x38d1b4[_0x7b37('0xc')];this[_0x7b37('0xd')]={};this[_0x7b37('0xe')]=0x0;this[_0x7b37('0x1')]='';this[_0x7b37('0xf')]();this['updateRealtime']();}SmsQueue[_0x7b37('0x10')][_0x7b37('0xf')]=function(){var _0x4a51b0=this['mapAgentsId'][_0x7b37('0x11')];this[_0x7b37('0xd')]=_[_0x7b37('0x12')](this[_0x7b37('0xc')],'id');this[_0x7b37('0xd')][_0x7b37('0x11')]=_0x4a51b0;};SmsQueue[_0x7b37('0x10')][_0x7b37('0x13')]=function(){this[_0x7b37('0x14')]=0x0;this[_0x7b37('0x15')]=0x0;for(var _0x1a381a=0x0;_0x1a381a<this[_0x7b37('0xc')][_0x7b37('0x16')];_0x1a381a+=0x1){if(this[_0x7b37('0xc')][_0x1a381a][_0x7b37('0x17')]){this[_0x7b37('0x14')]+=0x1;}if(this[_0x7b37('0xc')][_0x1a381a]['smsPause']){this['paused']+=0x1;}}this[_0x7b37('0x18')]=this['loggedIn']-this['paused'];this[_0x7b37('0x18')]=this[_0x7b37('0x18')]>=0x0?this[_0x7b37('0x18')]:0x0;var _0x487f5c={'id':this['id'],'available':this[_0x7b37('0x18')],'loggedIn':this[_0x7b37('0x14')],'name':this[_0x7b37('0x19')],'paused':this['paused'],'waiting':this['waiting']};var _0x6905bb=md5(JSON[_0x7b37('0x1a')](_0x487f5c));if(this[_0x7b37('0x1')]!==_0x6905bb){this[_0x7b37('0x1')]=_0x6905bb;io['to'](util[_0x7b37('0x1b')]('sms:queue:%s',_0x487f5c['name']))['emit'](_0x7b37('0x1c'),_0x487f5c);}};module[_0x7b37('0x1d')]=SmsQueue;