Built motion from commit e02f907f.|2.6.14
[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 _0xaa7c=['md5','updateRouting','updateRealtime','_rr','map','prototype','loggedIn','paused','online','available','stringify','format','sms:queue:%s','emit','sms_queue:save','exports','lodash','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting'];(function(_0x5b013a,_0x1a2504){var _0x2b6ae7=function(_0x3c26d3){while(--_0x3c26d3){_0x5b013a['push'](_0x5b013a['shift']());}};_0x2b6ae7(++_0x1a2504);}(_0xaa7c,0x1ec));var _0xcaa7=function(_0x4f8473,_0x46115b){_0x4f8473=_0x4f8473-0x0;var _0x2532c6=_0xaa7c[_0x4f8473];return _0x2532c6;};'use strict';var _=require(_0xcaa7('0x0'));var md5=require('md5');var util=require('util');var Redis=require('ioredis');var config=require('../../../config/environment');config[_0xcaa7('0x1')]=_[_0xcaa7('0x2')](config['redis'],{'host':_0xcaa7('0x3'),'port':0x18eb});var io=require(_0xcaa7('0x4'))(new Redis(config[_0xcaa7('0x1')]));function SmsQueue(_0x17d8cf){this['id']=_0x17d8cf['id']||0x0;this[_0xcaa7('0x5')]=_0x17d8cf['name']||'';this[_0xcaa7('0x6')]=_0x17d8cf['timeout']||0xa;this['strategy']=_0x17d8cf[_0xcaa7('0x7')]||_0xcaa7('0x8');this[_0xcaa7('0x9')]=_0x17d8cf['Agents'];this[_0xcaa7('0xa')]={};this[_0xcaa7('0xb')]=0x0;this[_0xcaa7('0xc')]='';this[_0xcaa7('0xd')]();this[_0xcaa7('0xe')]();}SmsQueue['prototype'][_0xcaa7('0xd')]=function(){var _0x39d53a=this[_0xcaa7('0xa')][_0xcaa7('0xf')];this[_0xcaa7('0xa')]=_[_0xcaa7('0x10')](this['Agents'],'id');this[_0xcaa7('0xa')][_0xcaa7('0xf')]=_0x39d53a;};SmsQueue[_0xcaa7('0x11')][_0xcaa7('0xe')]=function(){this[_0xcaa7('0x12')]=0x0;this[_0xcaa7('0x13')]=0x0;for(var _0x299490=0x0;_0x299490<this['Agents']['length'];_0x299490+=0x1){if(this[_0xcaa7('0x9')][_0x299490][_0xcaa7('0x14')]){this[_0xcaa7('0x12')]+=0x1;}if(this[_0xcaa7('0x9')][_0x299490]['smsPause']){this[_0xcaa7('0x13')]+=0x1;}}this[_0xcaa7('0x15')]=this[_0xcaa7('0x12')]-this[_0xcaa7('0x13')];this[_0xcaa7('0x15')]=this[_0xcaa7('0x15')]>=0x0?this[_0xcaa7('0x15')]:0x0;var _0x5c2a74={'id':this['id'],'available':this['available'],'loggedIn':this[_0xcaa7('0x12')],'name':this[_0xcaa7('0x5')],'paused':this[_0xcaa7('0x13')],'waiting':this[_0xcaa7('0xb')]};var _0x131e52=md5(JSON[_0xcaa7('0x16')](_0x5c2a74));if(this[_0xcaa7('0xc')]!==_0x131e52){this['md5']=_0x131e52;io['to'](util[_0xcaa7('0x17')](_0xcaa7('0x18'),_0x5c2a74[_0xcaa7('0x5')]))[_0xcaa7('0x19')](_0xcaa7('0x1a'),_0x5c2a74);}};module[_0xcaa7('0x1b')]=SmsQueue;