ede9351c1884ec6c988e65250a8dcc1954c7a779
[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 _0xbe02=['beepall','Agents','mapAgentsId','map','_rr','prototype','updateRealtime','loggedIn','paused','length','available','waiting','stringify','exports','lodash','md5','util','ioredis','redis','defaults','localhost','socket.io-emitter','name','strategy'];(function(_0x4609a3,_0x3072cc){var _0x250284=function(_0x298953){while(--_0x298953){_0x4609a3['push'](_0x4609a3['shift']());}};_0x250284(++_0x3072cc);}(_0xbe02,0x146));var _0x2be0=function(_0x21bb19,_0x281dd9){_0x21bb19=_0x21bb19-0x0;var _0x1f3052=_0xbe02[_0x21bb19];return _0x1f3052;};'use strict';var _=require(_0x2be0('0x0'));var md5=require(_0x2be0('0x1'));var util=require(_0x2be0('0x2'));var Redis=require(_0x2be0('0x3'));var config=require('../../../config/environment');config[_0x2be0('0x4')]=_[_0x2be0('0x5')](config[_0x2be0('0x4')],{'host':_0x2be0('0x6'),'port':0x18eb});var io=require(_0x2be0('0x7'))(new Redis(config[_0x2be0('0x4')]));function SmsQueue(_0x40f52b){this['id']=_0x40f52b['id']||0x0;this[_0x2be0('0x8')]=_0x40f52b[_0x2be0('0x8')]||'';this['timeout']=_0x40f52b['timeout']||0xa;this[_0x2be0('0x9')]=_0x40f52b[_0x2be0('0x9')]||_0x2be0('0xa');this[_0x2be0('0xb')]=_0x40f52b[_0x2be0('0xb')];this[_0x2be0('0xc')]={};this['waiting']=0x0;this['md5']='';this['updateRouting']();this['updateRealtime']();}SmsQueue['prototype']['updateRouting']=function(){var _0x367444=this[_0x2be0('0xc')]['_rr'];this[_0x2be0('0xc')]=_[_0x2be0('0xd')](this[_0x2be0('0xb')],'id');this[_0x2be0('0xc')][_0x2be0('0xe')]=_0x367444;};SmsQueue[_0x2be0('0xf')][_0x2be0('0x10')]=function(){this[_0x2be0('0x11')]=0x0;this[_0x2be0('0x12')]=0x0;for(var _0x271f25=0x0;_0x271f25<this['Agents'][_0x2be0('0x13')];_0x271f25+=0x1){if(this[_0x2be0('0xb')][_0x271f25]['online']){this[_0x2be0('0x11')]+=0x1;}if(this[_0x2be0('0xb')][_0x271f25]['smsPause']){this[_0x2be0('0x12')]+=0x1;}}this[_0x2be0('0x14')]=this[_0x2be0('0x11')]-this[_0x2be0('0x12')];this[_0x2be0('0x14')]=this[_0x2be0('0x14')]>=0x0?this[_0x2be0('0x14')]:0x0;var _0x415894={'id':this['id'],'available':this[_0x2be0('0x14')],'loggedIn':this[_0x2be0('0x11')],'name':this[_0x2be0('0x8')],'paused':this[_0x2be0('0x12')],'waiting':this[_0x2be0('0x15')]};var _0x34f588=md5(JSON[_0x2be0('0x16')](_0x415894));if(this[_0x2be0('0x1')]!==_0x34f588){this[_0x2be0('0x1')]=_0x34f588;io['to'](util['format']('sms:queue:%s',_0x415894[_0x2be0('0x8')]))['emit']('sms_queue:save',_0x415894);}};module[_0x2be0('0x17')]=SmsQueue;