Built motion from commit 0900f080.|2.5.45
[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 _0xd52d=['localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','length','online','smsPause','available','stringify','sms:queue:%s','sms_queue:save','md5','util','../../../config/environment','redis'];(function(_0x57396e,_0x46d2fb){var _0x23b309=function(_0x548ea4){while(--_0x548ea4){_0x57396e['push'](_0x57396e['shift']());}};_0x23b309(++_0x46d2fb);}(_0xd52d,0x1c7));var _0xdd52=function(_0x580cef,_0x28b2d4){_0x580cef=_0x580cef-0x0;var _0x16b4ab=_0xd52d[_0x580cef];return _0x16b4ab;};'use strict';var _=require('lodash');var md5=require(_0xdd52('0x0'));var util=require(_0xdd52('0x1'));var Redis=require('ioredis');var config=require(_0xdd52('0x2'));config['redis']=_['defaults'](config[_0xdd52('0x3')],{'host':_0xdd52('0x4'),'port':0x18eb});var io=require(_0xdd52('0x5'))(new Redis(config[_0xdd52('0x3')]));function SmsQueue(_0x3b9337){this['id']=_0x3b9337['id']||0x0;this[_0xdd52('0x6')]=_0x3b9337[_0xdd52('0x6')]||'';this[_0xdd52('0x7')]=_0x3b9337['timeout']||0xa;this[_0xdd52('0x8')]=_0x3b9337[_0xdd52('0x8')]||_0xdd52('0x9');this[_0xdd52('0xa')]=_0x3b9337[_0xdd52('0xa')];this[_0xdd52('0xb')]={};this[_0xdd52('0xc')]=0x0;this[_0xdd52('0x0')]='';this[_0xdd52('0xd')]();this[_0xdd52('0xe')]();}SmsQueue[_0xdd52('0xf')][_0xdd52('0xd')]=function(){var _0x1cfc7f=this['mapAgentsId'][_0xdd52('0x10')];this[_0xdd52('0xb')]=_[_0xdd52('0x11')](this[_0xdd52('0xa')],'id');this[_0xdd52('0xb')][_0xdd52('0x10')]=_0x1cfc7f;};SmsQueue['prototype'][_0xdd52('0xe')]=function(){this[_0xdd52('0x12')]=0x0;this[_0xdd52('0x13')]=0x0;for(var _0x55b823=0x0;_0x55b823<this[_0xdd52('0xa')][_0xdd52('0x14')];_0x55b823+=0x1){if(this[_0xdd52('0xa')][_0x55b823][_0xdd52('0x15')]){this[_0xdd52('0x12')]+=0x1;}if(this[_0xdd52('0xa')][_0x55b823][_0xdd52('0x16')]){this[_0xdd52('0x13')]+=0x1;}}this['available']=this[_0xdd52('0x12')]-this['paused'];this[_0xdd52('0x17')]=this[_0xdd52('0x17')]>=0x0?this[_0xdd52('0x17')]:0x0;var _0x45062e={'id':this['id'],'available':this['available'],'loggedIn':this[_0xdd52('0x12')],'name':this[_0xdd52('0x6')],'paused':this[_0xdd52('0x13')],'waiting':this[_0xdd52('0xc')]};var _0x5de47a=md5(JSON[_0xdd52('0x18')](_0x45062e));if(this['md5']!==_0x5de47a){this[_0xdd52('0x0')]=_0x5de47a;io['to'](util['format'](_0xdd52('0x19'),_0x45062e[_0xdd52('0x6')]))['emit'](_0xdd52('0x1a'),_0x45062e);}};module['exports']=SmsQueue;