Built motion from commit bab6f49e.|2.6.17
[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 _0x57d4=['sms:queue:%s','emit','sms_queue:save','exports','lodash','md5','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','updateRealtime','prototype','updateRouting','_rr','map','paused','length','online','loggedIn','available','stringify','format'];(function(_0x225f50,_0x48a77d){var _0x19d003=function(_0x58965d){while(--_0x58965d){_0x225f50['push'](_0x225f50['shift']());}};_0x19d003(++_0x48a77d);}(_0x57d4,0x78));var _0x457d=function(_0x16e4fe,_0x27b334){_0x16e4fe=_0x16e4fe-0x0;var _0x4642d8=_0x57d4[_0x16e4fe];return _0x4642d8;};'use strict';var _=require(_0x457d('0x0'));var md5=require(_0x457d('0x1'));var util=require('util');var Redis=require(_0x457d('0x2'));var config=require(_0x457d('0x3'));config[_0x457d('0x4')]=_[_0x457d('0x5')](config[_0x457d('0x4')],{'host':_0x457d('0x6'),'port':0x18eb});var io=require(_0x457d('0x7'))(new Redis(config[_0x457d('0x4')]));function SmsQueue(_0x4745ed){this['id']=_0x4745ed['id']||0x0;this[_0x457d('0x8')]=_0x4745ed[_0x457d('0x8')]||'';this['timeout']=_0x4745ed[_0x457d('0x9')]||0xa;this[_0x457d('0xa')]=_0x4745ed['strategy']||'beepall';this[_0x457d('0xb')]=_0x4745ed[_0x457d('0xb')];this[_0x457d('0xc')]={};this['waiting']=0x0;this['md5']='';this['updateRouting']();this[_0x457d('0xd')]();}SmsQueue[_0x457d('0xe')][_0x457d('0xf')]=function(){var _0x128e09=this[_0x457d('0xc')][_0x457d('0x10')];this[_0x457d('0xc')]=_[_0x457d('0x11')](this[_0x457d('0xb')],'id');this['mapAgentsId'][_0x457d('0x10')]=_0x128e09;};SmsQueue[_0x457d('0xe')]['updateRealtime']=function(){this['loggedIn']=0x0;this[_0x457d('0x12')]=0x0;for(var _0x19ac04=0x0;_0x19ac04<this[_0x457d('0xb')][_0x457d('0x13')];_0x19ac04+=0x1){if(this[_0x457d('0xb')][_0x19ac04][_0x457d('0x14')]){this[_0x457d('0x15')]+=0x1;}if(this[_0x457d('0xb')][_0x19ac04]['smsPause']){this[_0x457d('0x12')]+=0x1;}}this[_0x457d('0x16')]=this[_0x457d('0x15')]-this['paused'];this['available']=this[_0x457d('0x16')]>=0x0?this['available']:0x0;var _0x151416={'id':this['id'],'available':this[_0x457d('0x16')],'loggedIn':this['loggedIn'],'name':this[_0x457d('0x8')],'paused':this['paused'],'waiting':this['waiting']};var _0xbdded1=md5(JSON[_0x457d('0x17')](_0x151416));if(this[_0x457d('0x1')]!==_0xbdded1){this[_0x457d('0x1')]=_0xbdded1;io['to'](util[_0x457d('0x18')](_0x457d('0x19'),_0x151416[_0x457d('0x8')]))[_0x457d('0x1a')](_0x457d('0x1b'),_0x151416);}};module[_0x457d('0x1c')]=SmsQueue;