Built motion from commit e1760111.|2.6.18
[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 _0xee39=['lodash','md5','util','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','prototype','_rr','map','loggedIn','paused','length','online','available','waiting','stringify','format','emit','sms_queue:save','exports'];(function(_0x178668,_0x1ec300){var _0x26107d=function(_0x4c0aa8){while(--_0x4c0aa8){_0x178668['push'](_0x178668['shift']());}};_0x26107d(++_0x1ec300);}(_0xee39,0x1e6));var _0x9ee3=function(_0x2bb3a6,_0x327b1b){_0x2bb3a6=_0x2bb3a6-0x0;var _0xf7e1da=_0xee39[_0x2bb3a6];return _0xf7e1da;};'use strict';var _=require(_0x9ee3('0x0'));var md5=require(_0x9ee3('0x1'));var util=require(_0x9ee3('0x2'));var Redis=require('ioredis');var config=require(_0x9ee3('0x3'));config[_0x9ee3('0x4')]=_[_0x9ee3('0x5')](config[_0x9ee3('0x4')],{'host':_0x9ee3('0x6'),'port':0x18eb});var io=require(_0x9ee3('0x7'))(new Redis(config[_0x9ee3('0x4')]));function SmsQueue(_0x603485){this['id']=_0x603485['id']||0x0;this[_0x9ee3('0x8')]=_0x603485[_0x9ee3('0x8')]||'';this['timeout']=_0x603485[_0x9ee3('0x9')]||0xa;this[_0x9ee3('0xa')]=_0x603485[_0x9ee3('0xa')]||'beepall';this[_0x9ee3('0xb')]=_0x603485['Agents'];this[_0x9ee3('0xc')]={};this['waiting']=0x0;this[_0x9ee3('0x1')]='';this['updateRouting']();this['updateRealtime']();}SmsQueue[_0x9ee3('0xd')]['updateRouting']=function(){var _0x33e8bc=this['mapAgentsId'][_0x9ee3('0xe')];this[_0x9ee3('0xc')]=_[_0x9ee3('0xf')](this[_0x9ee3('0xb')],'id');this[_0x9ee3('0xc')][_0x9ee3('0xe')]=_0x33e8bc;};SmsQueue[_0x9ee3('0xd')]['updateRealtime']=function(){this[_0x9ee3('0x10')]=0x0;this[_0x9ee3('0x11')]=0x0;for(var _0x7fa8c=0x0;_0x7fa8c<this['Agents'][_0x9ee3('0x12')];_0x7fa8c+=0x1){if(this[_0x9ee3('0xb')][_0x7fa8c][_0x9ee3('0x13')]){this[_0x9ee3('0x10')]+=0x1;}if(this['Agents'][_0x7fa8c]['smsPause']){this[_0x9ee3('0x11')]+=0x1;}}this[_0x9ee3('0x14')]=this[_0x9ee3('0x10')]-this[_0x9ee3('0x11')];this[_0x9ee3('0x14')]=this[_0x9ee3('0x14')]>=0x0?this['available']:0x0;var _0x4a987a={'id':this['id'],'available':this[_0x9ee3('0x14')],'loggedIn':this[_0x9ee3('0x10')],'name':this[_0x9ee3('0x8')],'paused':this[_0x9ee3('0x11')],'waiting':this[_0x9ee3('0x15')]};var _0x25fad6=md5(JSON[_0x9ee3('0x16')](_0x4a987a));if(this[_0x9ee3('0x1')]!==_0x25fad6){this[_0x9ee3('0x1')]=_0x25fad6;io['to'](util[_0x9ee3('0x17')]('sms:queue:%s',_0x4a987a[_0x9ee3('0x8')]))[_0x9ee3('0x18')](_0x9ee3('0x19'),_0x4a987a);}};module[_0x9ee3('0x1a')]=SmsQueue;