Built motion from commit fe909640.|2.6.8
[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 _0x644a=['exports','lodash','md5','util','ioredis','../../../config/environment','defaults','redis','name','timeout','strategy','beepall','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','Agents','loggedIn','paused','length','available','stringify','format','sms:queue:%s','sms_queue:save'];(function(_0xc69530,_0x57c174){var _0x148a92=function(_0x409d97){while(--_0x409d97){_0xc69530['push'](_0xc69530['shift']());}};_0x148a92(++_0x57c174);}(_0x644a,0xfd));var _0xa644=function(_0xbe200f,_0x4b50eb){_0xbe200f=_0xbe200f-0x0;var _0x192597=_0x644a[_0xbe200f];return _0x192597;};'use strict';var _=require(_0xa644('0x0'));var md5=require(_0xa644('0x1'));var util=require(_0xa644('0x2'));var Redis=require(_0xa644('0x3'));var config=require(_0xa644('0x4'));config['redis']=_[_0xa644('0x5')](config[_0xa644('0x6')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xa644('0x6')]));function SmsQueue(_0x40a46b){this['id']=_0x40a46b['id']||0x0;this[_0xa644('0x7')]=_0x40a46b['name']||'';this[_0xa644('0x8')]=_0x40a46b[_0xa644('0x8')]||0xa;this['strategy']=_0x40a46b[_0xa644('0x9')]||_0xa644('0xa');this['Agents']=_0x40a46b['Agents'];this[_0xa644('0xb')]={};this[_0xa644('0xc')]=0x0;this['md5']='';this[_0xa644('0xd')]();this[_0xa644('0xe')]();}SmsQueue[_0xa644('0xf')][_0xa644('0xd')]=function(){var _0x1b8510=this['mapAgentsId'][_0xa644('0x10')];this[_0xa644('0xb')]=_[_0xa644('0x11')](this[_0xa644('0x12')],'id');this[_0xa644('0xb')][_0xa644('0x10')]=_0x1b8510;};SmsQueue['prototype'][_0xa644('0xe')]=function(){this[_0xa644('0x13')]=0x0;this[_0xa644('0x14')]=0x0;for(var _0x10783c=0x0;_0x10783c<this[_0xa644('0x12')][_0xa644('0x15')];_0x10783c+=0x1){if(this['Agents'][_0x10783c]['online']){this['loggedIn']+=0x1;}if(this['Agents'][_0x10783c]['smsPause']){this['paused']+=0x1;}}this[_0xa644('0x16')]=this[_0xa644('0x13')]-this[_0xa644('0x14')];this[_0xa644('0x16')]=this[_0xa644('0x16')]>=0x0?this[_0xa644('0x16')]:0x0;var _0x6fb957={'id':this['id'],'available':this[_0xa644('0x16')],'loggedIn':this[_0xa644('0x13')],'name':this[_0xa644('0x7')],'paused':this[_0xa644('0x14')],'waiting':this[_0xa644('0xc')]};var _0x27ca70=md5(JSON[_0xa644('0x17')](_0x6fb957));if(this[_0xa644('0x1')]!==_0x27ca70){this['md5']=_0x27ca70;io['to'](util[_0xa644('0x18')](_0xa644('0x19'),_0x6fb957[_0xa644('0x7')]))['emit'](_0xa644('0x1a'),_0x6fb957);}};module[_0xa644('0x1b')]=SmsQueue;