034866d979ed9e55b42a69de12c8bdba025f4a43
[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 _0x54f3=['sms:queue:%s','exports','md5','util','ioredis','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','waiting','prototype','updateRouting','mapAgentsId','_rr','map','updateRealtime','loggedIn','length','online','available','paused'];(function(_0x4e5b0a,_0x544766){var _0x2a8177=function(_0xcd3ef9){while(--_0xcd3ef9){_0x4e5b0a['push'](_0x4e5b0a['shift']());}};_0x2a8177(++_0x544766);}(_0x54f3,0x120));var _0x354f=function(_0x19950b,_0x53d0d7){_0x19950b=_0x19950b-0x0;var _0x3c6b41=_0x54f3[_0x19950b];return _0x3c6b41;};'use strict';var _=require('lodash');var md5=require(_0x354f('0x0'));var util=require(_0x354f('0x1'));var Redis=require(_0x354f('0x2'));var config=require(_0x354f('0x3'));config[_0x354f('0x4')]=_['defaults'](config['redis'],{'host':_0x354f('0x5'),'port':0x18eb});var io=require(_0x354f('0x6'))(new Redis(config[_0x354f('0x4')]));function SmsQueue(_0x5bafb1){this['id']=_0x5bafb1['id']||0x0;this['name']=_0x5bafb1[_0x354f('0x7')]||'';this['timeout']=_0x5bafb1[_0x354f('0x8')]||0xa;this[_0x354f('0x9')]=_0x5bafb1[_0x354f('0x9')]||_0x354f('0xa');this['Agents']=_0x5bafb1[_0x354f('0xb')];this['mapAgentsId']={};this[_0x354f('0xc')]=0x0;this[_0x354f('0x0')]='';this['updateRouting']();this['updateRealtime']();}SmsQueue[_0x354f('0xd')][_0x354f('0xe')]=function(){var _0x55e064=this[_0x354f('0xf')][_0x354f('0x10')];this['mapAgentsId']=_[_0x354f('0x11')](this[_0x354f('0xb')],'id');this[_0x354f('0xf')][_0x354f('0x10')]=_0x55e064;};SmsQueue[_0x354f('0xd')][_0x354f('0x12')]=function(){this[_0x354f('0x13')]=0x0;this['paused']=0x0;for(var _0xf2e013=0x0;_0xf2e013<this[_0x354f('0xb')][_0x354f('0x14')];_0xf2e013+=0x1){if(this['Agents'][_0xf2e013][_0x354f('0x15')]){this[_0x354f('0x13')]+=0x1;}if(this[_0x354f('0xb')][_0xf2e013]['smsPause']){this['paused']+=0x1;}}this[_0x354f('0x16')]=this[_0x354f('0x13')]-this[_0x354f('0x17')];this[_0x354f('0x16')]=this[_0x354f('0x16')]>=0x0?this[_0x354f('0x16')]:0x0;var _0x1210a6={'id':this['id'],'available':this['available'],'loggedIn':this[_0x354f('0x13')],'name':this[_0x354f('0x7')],'paused':this[_0x354f('0x17')],'waiting':this['waiting']};var _0x3bb1a1=md5(JSON['stringify'](_0x1210a6));if(this[_0x354f('0x0')]!==_0x3bb1a1){this[_0x354f('0x0')]=_0x3bb1a1;io['to'](util['format'](_0x354f('0x18'),_0x1210a6[_0x354f('0x7')]))['emit']('sms_queue:save',_0x1210a6);}};module[_0x354f('0x19')]=SmsQueue;