Built motion from commit 639a1a7f.|2.6.19
[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 _0x063c=['paused','length','online','loggedIn','smsPause','available','waiting','stringify','format','emit','sms_queue:save','exports','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRouting','prototype','_rr','updateRealtime'];(function(_0x31fee1,_0x8d0b5){var _0x834e13=function(_0x16d2df){while(--_0x16d2df){_0x31fee1['push'](_0x31fee1['shift']());}};_0x834e13(++_0x8d0b5);}(_0x063c,0xba));var _0xc063=function(_0x176c9e,_0x2717f9){_0x176c9e=_0x176c9e-0x0;var _0xdee434=_0x063c[_0x176c9e];return _0xdee434;};'use strict';var _=require('lodash');var md5=require(_0xc063('0x0'));var util=require(_0xc063('0x1'));var Redis=require(_0xc063('0x2'));var config=require(_0xc063('0x3'));config[_0xc063('0x4')]=_[_0xc063('0x5')](config['redis'],{'host':_0xc063('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function SmsQueue(_0x59b81f){this['id']=_0x59b81f['id']||0x0;this[_0xc063('0x7')]=_0x59b81f[_0xc063('0x7')]||'';this['timeout']=_0x59b81f[_0xc063('0x8')]||0xa;this[_0xc063('0x9')]=_0x59b81f[_0xc063('0x9')]||_0xc063('0xa');this['Agents']=_0x59b81f[_0xc063('0xb')];this[_0xc063('0xc')]={};this['waiting']=0x0;this[_0xc063('0x0')]='';this[_0xc063('0xd')]();this['updateRealtime']();}SmsQueue[_0xc063('0xe')]['updateRouting']=function(){var _0x54c605=this['mapAgentsId'][_0xc063('0xf')];this[_0xc063('0xc')]=_['map'](this[_0xc063('0xb')],'id');this['mapAgentsId'][_0xc063('0xf')]=_0x54c605;};SmsQueue[_0xc063('0xe')][_0xc063('0x10')]=function(){this['loggedIn']=0x0;this[_0xc063('0x11')]=0x0;for(var _0x1249b2=0x0;_0x1249b2<this[_0xc063('0xb')][_0xc063('0x12')];_0x1249b2+=0x1){if(this[_0xc063('0xb')][_0x1249b2][_0xc063('0x13')]){this[_0xc063('0x14')]+=0x1;}if(this[_0xc063('0xb')][_0x1249b2][_0xc063('0x15')]){this['paused']+=0x1;}}this[_0xc063('0x16')]=this[_0xc063('0x14')]-this['paused'];this[_0xc063('0x16')]=this[_0xc063('0x16')]>=0x0?this['available']:0x0;var _0x238ecb={'id':this['id'],'available':this[_0xc063('0x16')],'loggedIn':this[_0xc063('0x14')],'name':this[_0xc063('0x7')],'paused':this['paused'],'waiting':this[_0xc063('0x17')]};var _0x28d3ce=md5(JSON[_0xc063('0x18')](_0x238ecb));if(this['md5']!==_0x28d3ce){this[_0xc063('0x0')]=_0x28d3ce;io['to'](util[_0xc063('0x19')]('sms:queue:%s',_0x238ecb[_0xc063('0x7')]))[_0xc063('0x1a')](_0xc063('0x1b'),_0x238ecb);}};module[_0xc063('0x1c')]=SmsQueue;