Built motion from commit 52c8a02d.|2.6.29
[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 _0x180f=['lodash','md5','ioredis','../../../config/environment','defaults','redis','localhost','socket.io-emitter','name','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','prototype','_rr','map','loggedIn','paused','online','smsPause','available','stringify','format','emit','exports'];(function(_0x56482c,_0x16118d){var _0x5aae7a=function(_0x52512f){while(--_0x52512f){_0x56482c['push'](_0x56482c['shift']());}};_0x5aae7a(++_0x16118d);}(_0x180f,0xf3));var _0xf180=function(_0x2d4065,_0x38dc95){_0x2d4065=_0x2d4065-0x0;var _0xef6016=_0x180f[_0x2d4065];return _0xef6016;};'use strict';var _=require(_0xf180('0x0'));var md5=require(_0xf180('0x1'));var util=require('util');var Redis=require(_0xf180('0x2'));var config=require(_0xf180('0x3'));config['redis']=_[_0xf180('0x4')](config[_0xf180('0x5')],{'host':_0xf180('0x6'),'port':0x18eb});var io=require(_0xf180('0x7'))(new Redis(config[_0xf180('0x5')]));function SmsQueue(_0x5f269f){this['id']=_0x5f269f['id']||0x0;this[_0xf180('0x8')]=_0x5f269f[_0xf180('0x8')]||'';this['timeout']=_0x5f269f['timeout']||0xa;this[_0xf180('0x9')]=_0x5f269f[_0xf180('0x9')]||_0xf180('0xa');this[_0xf180('0xb')]=_0x5f269f[_0xf180('0xb')];this[_0xf180('0xc')]={};this[_0xf180('0xd')]=0x0;this[_0xf180('0x1')]='';this[_0xf180('0xe')]();this['updateRealtime']();}SmsQueue[_0xf180('0xf')][_0xf180('0xe')]=function(){var _0x7e6bf4=this[_0xf180('0xc')][_0xf180('0x10')];this[_0xf180('0xc')]=_[_0xf180('0x11')](this[_0xf180('0xb')],'id');this[_0xf180('0xc')][_0xf180('0x10')]=_0x7e6bf4;};SmsQueue[_0xf180('0xf')]['updateRealtime']=function(){this[_0xf180('0x12')]=0x0;this[_0xf180('0x13')]=0x0;for(var _0x1eb0a2=0x0;_0x1eb0a2<this[_0xf180('0xb')]['length'];_0x1eb0a2+=0x1){if(this[_0xf180('0xb')][_0x1eb0a2][_0xf180('0x14')]){this[_0xf180('0x12')]+=0x1;}if(this['Agents'][_0x1eb0a2][_0xf180('0x15')]){this[_0xf180('0x13')]+=0x1;}}this['available']=this[_0xf180('0x12')]-this[_0xf180('0x13')];this['available']=this[_0xf180('0x16')]>=0x0?this[_0xf180('0x16')]:0x0;var _0x335c78={'id':this['id'],'available':this[_0xf180('0x16')],'loggedIn':this[_0xf180('0x12')],'name':this[_0xf180('0x8')],'paused':this[_0xf180('0x13')],'waiting':this[_0xf180('0xd')]};var _0x26c9c0=md5(JSON[_0xf180('0x17')](_0x335c78));if(this[_0xf180('0x1')]!==_0x26c9c0){this[_0xf180('0x1')]=_0x26c9c0;io['to'](util[_0xf180('0x18')]('sms:queue:%s',_0x335c78[_0xf180('0x8')]))[_0xf180('0x19')]('sms_queue:save',_0x335c78);}};module[_0xf180('0x1a')]=SmsQueue;