2ba8208556607ea9cb5fee6146a06b66c2bc3f22
[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 _0x207d=['waiting','updateRouting','mapAgentsId','_rr','prototype','updateRealtime','loggedIn','paused','length','online','available','stringify','format','sms:queue:%s','emit','sms_queue:save','exports','lodash','md5','util','ioredis','redis','localhost','name','timeout','strategy','beepall','Agents'];(function(_0x5b445b,_0xd251da){var _0x1a40fe=function(_0x218fce){while(--_0x218fce){_0x5b445b['push'](_0x5b445b['shift']());}};_0x1a40fe(++_0xd251da);}(_0x207d,0x10d));var _0xd207=function(_0x427c3f,_0x3d0ef7){_0x427c3f=_0x427c3f-0x0;var _0x2409b8=_0x207d[_0x427c3f];return _0x2409b8;};'use strict';var _=require(_0xd207('0x0'));var md5=require(_0xd207('0x1'));var util=require(_0xd207('0x2'));var Redis=require(_0xd207('0x3'));var config=require('../../../config/environment');config[_0xd207('0x4')]=_['defaults'](config[_0xd207('0x4')],{'host':_0xd207('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xd207('0x4')]));function SmsQueue(_0x47386f){this['id']=_0x47386f['id']||0x0;this[_0xd207('0x6')]=_0x47386f[_0xd207('0x6')]||'';this[_0xd207('0x7')]=_0x47386f[_0xd207('0x7')]||0xa;this[_0xd207('0x8')]=_0x47386f[_0xd207('0x8')]||_0xd207('0x9');this[_0xd207('0xa')]=_0x47386f[_0xd207('0xa')];this['mapAgentsId']={};this[_0xd207('0xb')]=0x0;this[_0xd207('0x1')]='';this[_0xd207('0xc')]();this['updateRealtime']();}SmsQueue['prototype'][_0xd207('0xc')]=function(){var _0x260dfd=this[_0xd207('0xd')]['_rr'];this[_0xd207('0xd')]=_['map'](this['Agents'],'id');this['mapAgentsId'][_0xd207('0xe')]=_0x260dfd;};SmsQueue[_0xd207('0xf')][_0xd207('0x10')]=function(){this[_0xd207('0x11')]=0x0;this[_0xd207('0x12')]=0x0;for(var _0x450adf=0x0;_0x450adf<this[_0xd207('0xa')][_0xd207('0x13')];_0x450adf+=0x1){if(this[_0xd207('0xa')][_0x450adf][_0xd207('0x14')]){this[_0xd207('0x11')]+=0x1;}if(this['Agents'][_0x450adf]['smsPause']){this[_0xd207('0x12')]+=0x1;}}this[_0xd207('0x15')]=this[_0xd207('0x11')]-this['paused'];this['available']=this[_0xd207('0x15')]>=0x0?this[_0xd207('0x15')]:0x0;var _0x3e7e60={'id':this['id'],'available':this[_0xd207('0x15')],'loggedIn':this['loggedIn'],'name':this[_0xd207('0x6')],'paused':this['paused'],'waiting':this['waiting']};var _0x6b7fbd=md5(JSON[_0xd207('0x16')](_0x3e7e60));if(this[_0xd207('0x1')]!==_0x6b7fbd){this[_0xd207('0x1')]=_0x6b7fbd;io['to'](util[_0xd207('0x17')](_0xd207('0x18'),_0x3e7e60[_0xd207('0x6')]))[_0xd207('0x19')](_0xd207('0x1a'),_0x3e7e60);}};module[_0xd207('0x1b')]=SmsQueue;