6c5ec0b429c39b75bb9fa65f483224840467d44d
[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 _0x3e5c=['waiting','updateRouting','prototype','map','_rr','length','loggedIn','smsPause','paused','available','format','sms:queue:%s','sms_queue:save','exports','lodash','md5','util','ioredis','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x3e5c,0x9a));var _0xc3e5=function(_0x10e70d,_0x369bec){_0x10e70d=_0x10e70d-0x0;var _0x353b49=_0x3e5c[_0x10e70d];return _0x353b49;};'use strict';var _=require(_0xc3e5('0x0'));var md5=require(_0xc3e5('0x1'));var util=require(_0xc3e5('0x2'));var Redis=require(_0xc3e5('0x3'));var config=require('../../../config/environment');config[_0xc3e5('0x4')]=_[_0xc3e5('0x5')](config[_0xc3e5('0x4')],{'host':_0xc3e5('0x6'),'port':0x18eb});var io=require(_0xc3e5('0x7'))(new Redis(config[_0xc3e5('0x4')]));function SmsQueue(_0x4cb0db){this['id']=_0x4cb0db['id']||0x0;this[_0xc3e5('0x8')]=_0x4cb0db[_0xc3e5('0x8')]||'';this[_0xc3e5('0x9')]=_0x4cb0db[_0xc3e5('0x9')]||0xa;this[_0xc3e5('0xa')]=_0x4cb0db['strategy']||_0xc3e5('0xb');this[_0xc3e5('0xc')]=_0x4cb0db[_0xc3e5('0xc')];this[_0xc3e5('0xd')]={};this[_0xc3e5('0xe')]=0x0;this[_0xc3e5('0x1')]='';this[_0xc3e5('0xf')]();this['updateRealtime']();}SmsQueue[_0xc3e5('0x10')][_0xc3e5('0xf')]=function(){var _0x26985c=this[_0xc3e5('0xd')]['_rr'];this[_0xc3e5('0xd')]=_[_0xc3e5('0x11')](this[_0xc3e5('0xc')],'id');this[_0xc3e5('0xd')][_0xc3e5('0x12')]=_0x26985c;};SmsQueue[_0xc3e5('0x10')]['updateRealtime']=function(){this['loggedIn']=0x0;this['paused']=0x0;for(var _0x27c226=0x0;_0x27c226<this['Agents'][_0xc3e5('0x13')];_0x27c226+=0x1){if(this[_0xc3e5('0xc')][_0x27c226]['online']){this[_0xc3e5('0x14')]+=0x1;}if(this[_0xc3e5('0xc')][_0x27c226][_0xc3e5('0x15')]){this[_0xc3e5('0x16')]+=0x1;}}this[_0xc3e5('0x17')]=this['loggedIn']-this[_0xc3e5('0x16')];this[_0xc3e5('0x17')]=this[_0xc3e5('0x17')]>=0x0?this[_0xc3e5('0x17')]:0x0;var _0x1e884a={'id':this['id'],'available':this[_0xc3e5('0x17')],'loggedIn':this['loggedIn'],'name':this[_0xc3e5('0x8')],'paused':this[_0xc3e5('0x16')],'waiting':this['waiting']};var _0x1d0c5a=md5(JSON['stringify'](_0x1e884a));if(this[_0xc3e5('0x1')]!==_0x1d0c5a){this[_0xc3e5('0x1')]=_0x1d0c5a;io['to'](util[_0xc3e5('0x18')](_0xc3e5('0x19'),_0x1e884a[_0xc3e5('0x8')]))['emit'](_0xc3e5('0x1a'),_0x1e884a);}};module[_0xc3e5('0x1b')]=SmsQueue;