Built motion from commit 5b761a7b.|2.5.36
[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 _0x6658=['Agents','waiting','updateRouting','updateRealtime','prototype','mapAgentsId','_rr','map','paused','length','online','smsPause','available','stringify','emit','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','socket.io-emitter','name','timeout','strategy','beepall'];(function(_0x212f61,_0x3a7481){var _0x200c9f=function(_0x127cc8){while(--_0x127cc8){_0x212f61['push'](_0x212f61['shift']());}};_0x200c9f(++_0x3a7481);}(_0x6658,0x198));var _0x8665=function(_0x47f6c0,_0x3b0379){_0x47f6c0=_0x47f6c0-0x0;var _0x482b6c=_0x6658[_0x47f6c0];return _0x482b6c;};'use strict';var _=require(_0x8665('0x0'));var md5=require(_0x8665('0x1'));var util=require(_0x8665('0x2'));var Redis=require(_0x8665('0x3'));var config=require(_0x8665('0x4'));config[_0x8665('0x5')]=_[_0x8665('0x6')](config[_0x8665('0x5')],{'host':'localhost','port':0x18eb});var io=require(_0x8665('0x7'))(new Redis(config[_0x8665('0x5')]));function SmsQueue(_0x4cf7f4){this['id']=_0x4cf7f4['id']||0x0;this['name']=_0x4cf7f4[_0x8665('0x8')]||'';this[_0x8665('0x9')]=_0x4cf7f4[_0x8665('0x9')]||0xa;this[_0x8665('0xa')]=_0x4cf7f4[_0x8665('0xa')]||_0x8665('0xb');this[_0x8665('0xc')]=_0x4cf7f4[_0x8665('0xc')];this['mapAgentsId']={};this[_0x8665('0xd')]=0x0;this[_0x8665('0x1')]='';this[_0x8665('0xe')]();this[_0x8665('0xf')]();}SmsQueue[_0x8665('0x10')][_0x8665('0xe')]=function(){var _0x34f02e=this[_0x8665('0x11')][_0x8665('0x12')];this[_0x8665('0x11')]=_[_0x8665('0x13')](this[_0x8665('0xc')],'id');this[_0x8665('0x11')][_0x8665('0x12')]=_0x34f02e;};SmsQueue['prototype'][_0x8665('0xf')]=function(){this['loggedIn']=0x0;this[_0x8665('0x14')]=0x0;for(var _0x16452c=0x0;_0x16452c<this[_0x8665('0xc')][_0x8665('0x15')];_0x16452c+=0x1){if(this[_0x8665('0xc')][_0x16452c][_0x8665('0x16')]){this['loggedIn']+=0x1;}if(this[_0x8665('0xc')][_0x16452c][_0x8665('0x17')]){this['paused']+=0x1;}}this[_0x8665('0x18')]=this['loggedIn']-this[_0x8665('0x14')];this[_0x8665('0x18')]=this[_0x8665('0x18')]>=0x0?this['available']:0x0;var _0x331e01={'id':this['id'],'available':this[_0x8665('0x18')],'loggedIn':this['loggedIn'],'name':this[_0x8665('0x8')],'paused':this[_0x8665('0x14')],'waiting':this[_0x8665('0xd')]};var _0x5d1118=md5(JSON[_0x8665('0x19')](_0x331e01));if(this[_0x8665('0x1')]!==_0x5d1118){this[_0x8665('0x1')]=_0x5d1118;io['to'](util['format']('sms:queue:%s',_0x331e01['name']))[_0x8665('0x1a')]('sms_queue:save',_0x331e01);}};module[_0x8665('0x1b')]=SmsQueue;