ab936a262e49ecf6b23ce05f492c77c25073e5e3
[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 _0x826a=['timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','_rr','map','paused','online','smsPause','available','loggedIn','stringify','format','sms:queue:%s','emit','sms_queue:save','exports','md5','ioredis','redis','defaults','localhost','name'];(function(_0x48960d,_0x2f9d59){var _0x2f15d6=function(_0x3866a9){while(--_0x3866a9){_0x48960d['push'](_0x48960d['shift']());}};_0x2f15d6(++_0x2f9d59);}(_0x826a,0x1aa));var _0xa826=function(_0x399382,_0x45a8f6){_0x399382=_0x399382-0x0;var _0x495861=_0x826a[_0x399382];return _0x495861;};'use strict';var _=require('lodash');var md5=require(_0xa826('0x0'));var util=require('util');var Redis=require(_0xa826('0x1'));var config=require('../../../config/environment');config[_0xa826('0x2')]=_[_0xa826('0x3')](config[_0xa826('0x2')],{'host':_0xa826('0x4'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xa826('0x2')]));function SmsQueue(_0x15f777){this['id']=_0x15f777['id']||0x0;this[_0xa826('0x5')]=_0x15f777[_0xa826('0x5')]||'';this[_0xa826('0x6')]=_0x15f777[_0xa826('0x6')]||0xa;this[_0xa826('0x7')]=_0x15f777[_0xa826('0x7')]||_0xa826('0x8');this[_0xa826('0x9')]=_0x15f777[_0xa826('0x9')];this[_0xa826('0xa')]={};this[_0xa826('0xb')]=0x0;this[_0xa826('0x0')]='';this[_0xa826('0xc')]();this[_0xa826('0xd')]();}SmsQueue['prototype'][_0xa826('0xc')]=function(){var _0x4b4caf=this[_0xa826('0xa')][_0xa826('0xe')];this[_0xa826('0xa')]=_[_0xa826('0xf')](this[_0xa826('0x9')],'id');this[_0xa826('0xa')][_0xa826('0xe')]=_0x4b4caf;};SmsQueue['prototype'][_0xa826('0xd')]=function(){this['loggedIn']=0x0;this[_0xa826('0x10')]=0x0;for(var _0x41c0c2=0x0;_0x41c0c2<this['Agents']['length'];_0x41c0c2+=0x1){if(this['Agents'][_0x41c0c2][_0xa826('0x11')]){this['loggedIn']+=0x1;}if(this['Agents'][_0x41c0c2][_0xa826('0x12')]){this[_0xa826('0x10')]+=0x1;}}this[_0xa826('0x13')]=this['loggedIn']-this[_0xa826('0x10')];this[_0xa826('0x13')]=this[_0xa826('0x13')]>=0x0?this[_0xa826('0x13')]:0x0;var _0x90486c={'id':this['id'],'available':this['available'],'loggedIn':this[_0xa826('0x14')],'name':this[_0xa826('0x5')],'paused':this[_0xa826('0x10')],'waiting':this['waiting']};var _0x5d8161=md5(JSON[_0xa826('0x15')](_0x90486c));if(this[_0xa826('0x0')]!==_0x5d8161){this[_0xa826('0x0')]=_0x5d8161;io['to'](util[_0xa826('0x16')](_0xa826('0x17'),_0x90486c['name']))[_0xa826('0x18')](_0xa826('0x19'),_0x90486c);}};module[_0xa826('0x1a')]=SmsQueue;