Built motion from commit 3c2ce842.|2.6.31
[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 _0x0eec=['paused','format','emit','sms_queue:save','lodash','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','md5','updateRouting','updateRealtime','prototype','_rr','map','length','online','loggedIn','available'];(function(_0x98db01,_0x352720){var _0x343f92=function(_0x54efbd){while(--_0x54efbd){_0x98db01['push'](_0x98db01['shift']());}};_0x343f92(++_0x352720);}(_0x0eec,0xac));var _0xc0ee=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x0eec[_0x20a584];return _0x4b41a8;};'use strict';var _=require(_0xc0ee('0x0'));var md5=require('md5');var util=require('util');var Redis=require(_0xc0ee('0x1'));var config=require(_0xc0ee('0x2'));config[_0xc0ee('0x3')]=_[_0xc0ee('0x4')](config[_0xc0ee('0x3')],{'host':_0xc0ee('0x5'),'port':0x18eb});var io=require(_0xc0ee('0x6'))(new Redis(config['redis']));function SmsQueue(_0x10ab80){this['id']=_0x10ab80['id']||0x0;this['name']=_0x10ab80[_0xc0ee('0x7')]||'';this[_0xc0ee('0x8')]=_0x10ab80[_0xc0ee('0x8')]||0xa;this[_0xc0ee('0x9')]=_0x10ab80[_0xc0ee('0x9')]||_0xc0ee('0xa');this[_0xc0ee('0xb')]=_0x10ab80['Agents'];this[_0xc0ee('0xc')]={};this[_0xc0ee('0xd')]=0x0;this[_0xc0ee('0xe')]='';this[_0xc0ee('0xf')]();this[_0xc0ee('0x10')]();}SmsQueue[_0xc0ee('0x11')][_0xc0ee('0xf')]=function(){var _0x47aedf=this[_0xc0ee('0xc')][_0xc0ee('0x12')];this[_0xc0ee('0xc')]=_[_0xc0ee('0x13')](this[_0xc0ee('0xb')],'id');this[_0xc0ee('0xc')][_0xc0ee('0x12')]=_0x47aedf;};SmsQueue[_0xc0ee('0x11')][_0xc0ee('0x10')]=function(){this['loggedIn']=0x0;this['paused']=0x0;for(var _0x1f3ad9=0x0;_0x1f3ad9<this[_0xc0ee('0xb')][_0xc0ee('0x14')];_0x1f3ad9+=0x1){if(this['Agents'][_0x1f3ad9][_0xc0ee('0x15')]){this[_0xc0ee('0x16')]+=0x1;}if(this[_0xc0ee('0xb')][_0x1f3ad9]['smsPause']){this['paused']+=0x1;}}this[_0xc0ee('0x17')]=this['loggedIn']-this[_0xc0ee('0x18')];this[_0xc0ee('0x17')]=this[_0xc0ee('0x17')]>=0x0?this['available']:0x0;var _0x4e7e82={'id':this['id'],'available':this[_0xc0ee('0x17')],'loggedIn':this[_0xc0ee('0x16')],'name':this[_0xc0ee('0x7')],'paused':this['paused'],'waiting':this[_0xc0ee('0xd')]};var _0xe15d59=md5(JSON['stringify'](_0x4e7e82));if(this['md5']!==_0xe15d59){this[_0xc0ee('0xe')]=_0xe15d59;io['to'](util[_0xc0ee('0x19')]('sms:queue:%s',_0x4e7e82[_0xc0ee('0x7')]))[_0xc0ee('0x1a')](_0xc0ee('0x1b'),_0x4e7e82);}};module['exports']=SmsQueue;