Built motion from commit ddca4d0d.|2.5.47
[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 _0xc3fe=['updateRealtime','prototype','map','paused','online','smsPause','available','loggedIn','stringify','sms:queue:%s','sms_queue:save','exports','lodash','md5','util','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRouting'];(function(_0x34d735,_0x2ec5d5){var _0x3dc2e2=function(_0x5c22d1){while(--_0x5c22d1){_0x34d735['push'](_0x34d735['shift']());}};_0x3dc2e2(++_0x2ec5d5);}(_0xc3fe,0xff));var _0xec3f=function(_0x173cf6,_0x111b73){_0x173cf6=_0x173cf6-0x0;var _0x2cfb3c=_0xc3fe[_0x173cf6];return _0x2cfb3c;};'use strict';var _=require(_0xec3f('0x0'));var md5=require(_0xec3f('0x1'));var util=require(_0xec3f('0x2'));var Redis=require('ioredis');var config=require(_0xec3f('0x3'));config[_0xec3f('0x4')]=_[_0xec3f('0x5')](config['redis'],{'host':_0xec3f('0x6'),'port':0x18eb});var io=require(_0xec3f('0x7'))(new Redis(config[_0xec3f('0x4')]));function SmsQueue(_0x5807a9){this['id']=_0x5807a9['id']||0x0;this['name']=_0x5807a9[_0xec3f('0x8')]||'';this[_0xec3f('0x9')]=_0x5807a9['timeout']||0xa;this['strategy']=_0x5807a9[_0xec3f('0xa')]||'beepall';this[_0xec3f('0xb')]=_0x5807a9[_0xec3f('0xb')];this[_0xec3f('0xc')]={};this[_0xec3f('0xd')]=0x0;this['md5']='';this[_0xec3f('0xe')]();this[_0xec3f('0xf')]();}SmsQueue[_0xec3f('0x10')][_0xec3f('0xe')]=function(){var _0x13911d=this[_0xec3f('0xc')]['_rr'];this[_0xec3f('0xc')]=_[_0xec3f('0x11')](this[_0xec3f('0xb')],'id');this['mapAgentsId']['_rr']=_0x13911d;};SmsQueue[_0xec3f('0x10')]['updateRealtime']=function(){this['loggedIn']=0x0;this[_0xec3f('0x12')]=0x0;for(var _0x4318bd=0x0;_0x4318bd<this[_0xec3f('0xb')]['length'];_0x4318bd+=0x1){if(this['Agents'][_0x4318bd][_0xec3f('0x13')]){this['loggedIn']+=0x1;}if(this[_0xec3f('0xb')][_0x4318bd][_0xec3f('0x14')]){this['paused']+=0x1;}}this[_0xec3f('0x15')]=this[_0xec3f('0x16')]-this[_0xec3f('0x12')];this[_0xec3f('0x15')]=this['available']>=0x0?this[_0xec3f('0x15')]:0x0;var _0xc04d54={'id':this['id'],'available':this[_0xec3f('0x15')],'loggedIn':this[_0xec3f('0x16')],'name':this[_0xec3f('0x8')],'paused':this['paused'],'waiting':this[_0xec3f('0xd')]};var _0x4bea4e=md5(JSON[_0xec3f('0x17')](_0xc04d54));if(this[_0xec3f('0x1')]!==_0x4bea4e){this[_0xec3f('0x1')]=_0x4bea4e;io['to'](util['format'](_0xec3f('0x18'),_0xc04d54[_0xec3f('0x8')]))['emit'](_0xec3f('0x19'),_0xc04d54);}};module[_0xec3f('0x1a')]=SmsQueue;