Built motion from commit e0fa946e.|2.6.5
[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 _0xf6fb=['redis','defaults','localhost','name','timeout','strategy','Agents','mapAgentsId','waiting','md5','prototype','updateRouting','_rr','map','updateRealtime','loggedIn','paused','online','smsPause','available','sms:queue:%s','emit','exports','util','ioredis'];(function(_0x3bf586,_0x4b8779){var _0x4c23b8=function(_0x2bf355){while(--_0x2bf355){_0x3bf586['push'](_0x3bf586['shift']());}};_0x4c23b8(++_0x4b8779);}(_0xf6fb,0x111));var _0xbf6f=function(_0x2673bc,_0x7ff44e){_0x2673bc=_0x2673bc-0x0;var _0x5f0d90=_0xf6fb[_0x2673bc];return _0x5f0d90;};'use strict';var _=require('lodash');var md5=require('md5');var util=require(_0xbf6f('0x0'));var Redis=require(_0xbf6f('0x1'));var config=require('../../../config/environment');config[_0xbf6f('0x2')]=_[_0xbf6f('0x3')](config['redis'],{'host':_0xbf6f('0x4'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xbf6f('0x2')]));function SmsQueue(_0x41f22f){this['id']=_0x41f22f['id']||0x0;this[_0xbf6f('0x5')]=_0x41f22f[_0xbf6f('0x5')]||'';this[_0xbf6f('0x6')]=_0x41f22f[_0xbf6f('0x6')]||0xa;this[_0xbf6f('0x7')]=_0x41f22f[_0xbf6f('0x7')]||'beepall';this[_0xbf6f('0x8')]=_0x41f22f[_0xbf6f('0x8')];this[_0xbf6f('0x9')]={};this[_0xbf6f('0xa')]=0x0;this[_0xbf6f('0xb')]='';this['updateRouting']();this['updateRealtime']();}SmsQueue[_0xbf6f('0xc')][_0xbf6f('0xd')]=function(){var _0x256f0a=this['mapAgentsId'][_0xbf6f('0xe')];this['mapAgentsId']=_[_0xbf6f('0xf')](this[_0xbf6f('0x8')],'id');this[_0xbf6f('0x9')]['_rr']=_0x256f0a;};SmsQueue[_0xbf6f('0xc')][_0xbf6f('0x10')]=function(){this[_0xbf6f('0x11')]=0x0;this[_0xbf6f('0x12')]=0x0;for(var _0xce557a=0x0;_0xce557a<this[_0xbf6f('0x8')]['length'];_0xce557a+=0x1){if(this[_0xbf6f('0x8')][_0xce557a][_0xbf6f('0x13')]){this[_0xbf6f('0x11')]+=0x1;}if(this[_0xbf6f('0x8')][_0xce557a][_0xbf6f('0x14')]){this[_0xbf6f('0x12')]+=0x1;}}this[_0xbf6f('0x15')]=this['loggedIn']-this['paused'];this[_0xbf6f('0x15')]=this[_0xbf6f('0x15')]>=0x0?this[_0xbf6f('0x15')]:0x0;var _0x4b3c33={'id':this['id'],'available':this['available'],'loggedIn':this[_0xbf6f('0x11')],'name':this[_0xbf6f('0x5')],'paused':this[_0xbf6f('0x12')],'waiting':this[_0xbf6f('0xa')]};var _0x18fc9d=md5(JSON['stringify'](_0x4b3c33));if(this['md5']!==_0x18fc9d){this[_0xbf6f('0xb')]=_0x18fc9d;io['to'](util['format'](_0xbf6f('0x16'),_0x4b3c33[_0xbf6f('0x5')]))[_0xbf6f('0x17')]('sms_queue:save',_0x4b3c33);}};module[_0xbf6f('0x18')]=SmsQueue;