Built motion from commit da617fac.|2.6.6
[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 _0x3e74=['paused','online','available','waiting','stringify','md5','format','emit','exports','lodash','util','ioredis','../../../config/environment','redis','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRouting','updateRealtime','_rr','map','loggedIn'];(function(_0x198247,_0x491c12){var _0x2b18bc=function(_0x4a43e2){while(--_0x4a43e2){_0x198247['push'](_0x198247['shift']());}};_0x2b18bc(++_0x491c12);}(_0x3e74,0x175));var _0x43e7=function(_0x5043a5,_0x3e79eb){_0x5043a5=_0x5043a5-0x0;var _0x18312a=_0x3e74[_0x5043a5];return _0x18312a;};'use strict';var _=require(_0x43e7('0x0'));var md5=require('md5');var util=require(_0x43e7('0x1'));var Redis=require(_0x43e7('0x2'));var config=require(_0x43e7('0x3'));config['redis']=_['defaults'](config[_0x43e7('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0x43e7('0x5'))(new Redis(config[_0x43e7('0x4')]));function SmsQueue(_0xe78cb7){this['id']=_0xe78cb7['id']||0x0;this[_0x43e7('0x6')]=_0xe78cb7[_0x43e7('0x6')]||'';this['timeout']=_0xe78cb7[_0x43e7('0x7')]||0xa;this[_0x43e7('0x8')]=_0xe78cb7[_0x43e7('0x8')]||_0x43e7('0x9');this[_0x43e7('0xa')]=_0xe78cb7['Agents'];this[_0x43e7('0xb')]={};this['waiting']=0x0;this['md5']='';this[_0x43e7('0xc')]();this[_0x43e7('0xd')]();}SmsQueue['prototype'][_0x43e7('0xc')]=function(){var _0x513707=this[_0x43e7('0xb')][_0x43e7('0xe')];this['mapAgentsId']=_[_0x43e7('0xf')](this[_0x43e7('0xa')],'id');this[_0x43e7('0xb')][_0x43e7('0xe')]=_0x513707;};SmsQueue['prototype']['updateRealtime']=function(){this[_0x43e7('0x10')]=0x0;this[_0x43e7('0x11')]=0x0;for(var _0x44b0bd=0x0;_0x44b0bd<this['Agents']['length'];_0x44b0bd+=0x1){if(this[_0x43e7('0xa')][_0x44b0bd][_0x43e7('0x12')]){this[_0x43e7('0x10')]+=0x1;}if(this[_0x43e7('0xa')][_0x44b0bd]['smsPause']){this['paused']+=0x1;}}this[_0x43e7('0x13')]=this[_0x43e7('0x10')]-this[_0x43e7('0x11')];this['available']=this['available']>=0x0?this[_0x43e7('0x13')]:0x0;var _0x1ca758={'id':this['id'],'available':this[_0x43e7('0x13')],'loggedIn':this[_0x43e7('0x10')],'name':this[_0x43e7('0x6')],'paused':this[_0x43e7('0x11')],'waiting':this[_0x43e7('0x14')]};var _0x1441ef=md5(JSON[_0x43e7('0x15')](_0x1ca758));if(this[_0x43e7('0x16')]!==_0x1441ef){this[_0x43e7('0x16')]=_0x1441ef;io['to'](util[_0x43e7('0x17')]('sms:queue:%s',_0x1ca758[_0x43e7('0x6')]))[_0x43e7('0x18')]('sms_queue:save',_0x1ca758);}};module[_0x43e7('0x19')]=SmsQueue;