Built motion from commit 25580385.|2.6.2
[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 _0xbf6e=['loggedIn','paused','online','smsPause','available','stringify','format','emit','sms_queue:save','exports','util','ioredis','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','beepall','Agents','waiting','md5','updateRealtime','prototype','updateRouting','mapAgentsId','_rr','map'];(function(_0x39cd25,_0x10d989){var _0x17367e=function(_0x480812){while(--_0x480812){_0x39cd25['push'](_0x39cd25['shift']());}};_0x17367e(++_0x10d989);}(_0xbf6e,0x149));var _0xebf6=function(_0x1cd61f,_0x22e7af){_0x1cd61f=_0x1cd61f-0x0;var _0x27cee9=_0xbf6e[_0x1cd61f];return _0x27cee9;};'use strict';var _=require('lodash');var md5=require('md5');var util=require(_0xebf6('0x0'));var Redis=require(_0xebf6('0x1'));var config=require(_0xebf6('0x2'));config[_0xebf6('0x3')]=_[_0xebf6('0x4')](config[_0xebf6('0x3')],{'host':_0xebf6('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xebf6('0x3')]));function SmsQueue(_0x6ff2a3){this['id']=_0x6ff2a3['id']||0x0;this[_0xebf6('0x6')]=_0x6ff2a3[_0xebf6('0x6')]||'';this[_0xebf6('0x7')]=_0x6ff2a3[_0xebf6('0x7')]||0xa;this[_0xebf6('0x8')]=_0x6ff2a3['strategy']||_0xebf6('0x9');this[_0xebf6('0xa')]=_0x6ff2a3[_0xebf6('0xa')];this['mapAgentsId']={};this[_0xebf6('0xb')]=0x0;this[_0xebf6('0xc')]='';this['updateRouting']();this[_0xebf6('0xd')]();}SmsQueue[_0xebf6('0xe')][_0xebf6('0xf')]=function(){var _0x3954f4=this[_0xebf6('0x10')][_0xebf6('0x11')];this['mapAgentsId']=_[_0xebf6('0x12')](this[_0xebf6('0xa')],'id');this['mapAgentsId'][_0xebf6('0x11')]=_0x3954f4;};SmsQueue[_0xebf6('0xe')][_0xebf6('0xd')]=function(){this[_0xebf6('0x13')]=0x0;this[_0xebf6('0x14')]=0x0;for(var _0x4dbf51=0x0;_0x4dbf51<this['Agents']['length'];_0x4dbf51+=0x1){if(this[_0xebf6('0xa')][_0x4dbf51][_0xebf6('0x15')]){this['loggedIn']+=0x1;}if(this[_0xebf6('0xa')][_0x4dbf51][_0xebf6('0x16')]){this[_0xebf6('0x14')]+=0x1;}}this[_0xebf6('0x17')]=this[_0xebf6('0x13')]-this[_0xebf6('0x14')];this[_0xebf6('0x17')]=this[_0xebf6('0x17')]>=0x0?this[_0xebf6('0x17')]:0x0;var _0x308480={'id':this['id'],'available':this['available'],'loggedIn':this['loggedIn'],'name':this[_0xebf6('0x6')],'paused':this[_0xebf6('0x14')],'waiting':this[_0xebf6('0xb')]};var _0x410f06=md5(JSON[_0xebf6('0x18')](_0x308480));if(this[_0xebf6('0xc')]!==_0x410f06){this[_0xebf6('0xc')]=_0x410f06;io['to'](util[_0xebf6('0x19')]('sms:queue:%s',_0x308480[_0xebf6('0x6')]))[_0xebf6('0x1a')](_0xebf6('0x1b'),_0x308480);}};module[_0xebf6('0x1c')]=SmsQueue;