Built motion from commit 497d3d92.|2.5.43
[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 _0xeb5d=['waiting','updateRouting','updateRealtime','prototype','_rr','map','paused','length','loggedIn','available','stringify','format','emit','md5','util','ioredis','../../../config/environment','redis','localhost','name','timeout','strategy','beepall','Agents','mapAgentsId'];(function(_0x2181fc,_0x7283aa){var _0x315da1=function(_0x1df7ca){while(--_0x1df7ca){_0x2181fc['push'](_0x2181fc['shift']());}};_0x315da1(++_0x7283aa);}(_0xeb5d,0x16b));var _0xdeb5=function(_0x46698a,_0x8de1e4){_0x46698a=_0x46698a-0x0;var _0x356db0=_0xeb5d[_0x46698a];return _0x356db0;};'use strict';var _=require('lodash');var md5=require(_0xdeb5('0x0'));var util=require(_0xdeb5('0x1'));var Redis=require(_0xdeb5('0x2'));var config=require(_0xdeb5('0x3'));config['redis']=_['defaults'](config[_0xdeb5('0x4')],{'host':_0xdeb5('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xdeb5('0x4')]));function SmsQueue(_0x255dd0){this['id']=_0x255dd0['id']||0x0;this[_0xdeb5('0x6')]=_0x255dd0[_0xdeb5('0x6')]||'';this[_0xdeb5('0x7')]=_0x255dd0[_0xdeb5('0x7')]||0xa;this[_0xdeb5('0x8')]=_0x255dd0[_0xdeb5('0x8')]||_0xdeb5('0x9');this[_0xdeb5('0xa')]=_0x255dd0[_0xdeb5('0xa')];this[_0xdeb5('0xb')]={};this[_0xdeb5('0xc')]=0x0;this[_0xdeb5('0x0')]='';this[_0xdeb5('0xd')]();this[_0xdeb5('0xe')]();}SmsQueue[_0xdeb5('0xf')]['updateRouting']=function(){var _0x2ec04f=this[_0xdeb5('0xb')][_0xdeb5('0x10')];this[_0xdeb5('0xb')]=_[_0xdeb5('0x11')](this[_0xdeb5('0xa')],'id');this[_0xdeb5('0xb')][_0xdeb5('0x10')]=_0x2ec04f;};SmsQueue['prototype'][_0xdeb5('0xe')]=function(){this['loggedIn']=0x0;this[_0xdeb5('0x12')]=0x0;for(var _0x11d83a=0x0;_0x11d83a<this[_0xdeb5('0xa')][_0xdeb5('0x13')];_0x11d83a+=0x1){if(this[_0xdeb5('0xa')][_0x11d83a]['online']){this[_0xdeb5('0x14')]+=0x1;}if(this[_0xdeb5('0xa')][_0x11d83a]['smsPause']){this[_0xdeb5('0x12')]+=0x1;}}this[_0xdeb5('0x15')]=this[_0xdeb5('0x14')]-this['paused'];this['available']=this[_0xdeb5('0x15')]>=0x0?this['available']:0x0;var _0x1679ee={'id':this['id'],'available':this[_0xdeb5('0x15')],'loggedIn':this[_0xdeb5('0x14')],'name':this['name'],'paused':this[_0xdeb5('0x12')],'waiting':this['waiting']};var _0x20ac22=md5(JSON[_0xdeb5('0x16')](_0x1679ee));if(this[_0xdeb5('0x0')]!==_0x20ac22){this[_0xdeb5('0x0')]=_0x20ac22;io['to'](util[_0xdeb5('0x17')]('sms:queue:%s',_0x1679ee[_0xdeb5('0x6')]))[_0xdeb5('0x18')]('sms_queue:save',_0x1679ee);}};module['exports']=SmsQueue;