Built motion from commit 0bd120ac.|2.6.25
[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 _0xad95=['sms:queue:%s','emit','sms_queue:save','exports','lodash','md5','util','redis','defaults','socket.io-emitter','timeout','strategy','beepall','Agents','updateRouting','updateRealtime','_rr','mapAgentsId','map','paused','length','online','loggedIn','smsPause','available','name','waiting'];(function(_0x43f55c,_0x5b8a7b){var _0x40fdb2=function(_0x1ee4b1){while(--_0x1ee4b1){_0x43f55c['push'](_0x43f55c['shift']());}};_0x40fdb2(++_0x5b8a7b);}(_0xad95,0x70));var _0x5ad9=function(_0x21d73a,_0x4c935a){_0x21d73a=_0x21d73a-0x0;var _0x73ef62=_0xad95[_0x21d73a];return _0x73ef62;};'use strict';var _=require(_0x5ad9('0x0'));var md5=require(_0x5ad9('0x1'));var util=require(_0x5ad9('0x2'));var Redis=require('ioredis');var config=require('../../../config/environment');config[_0x5ad9('0x3')]=_[_0x5ad9('0x4')](config['redis'],{'host':'localhost','port':0x18eb});var io=require(_0x5ad9('0x5'))(new Redis(config['redis']));function SmsQueue(_0x4ccfdf){this['id']=_0x4ccfdf['id']||0x0;this['name']=_0x4ccfdf['name']||'';this[_0x5ad9('0x6')]=_0x4ccfdf[_0x5ad9('0x6')]||0xa;this[_0x5ad9('0x7')]=_0x4ccfdf[_0x5ad9('0x7')]||_0x5ad9('0x8');this['Agents']=_0x4ccfdf[_0x5ad9('0x9')];this['mapAgentsId']={};this['waiting']=0x0;this[_0x5ad9('0x1')]='';this[_0x5ad9('0xa')]();this[_0x5ad9('0xb')]();}SmsQueue['prototype'][_0x5ad9('0xa')]=function(){var _0x2262eb=this['mapAgentsId'][_0x5ad9('0xc')];this[_0x5ad9('0xd')]=_[_0x5ad9('0xe')](this[_0x5ad9('0x9')],'id');this[_0x5ad9('0xd')][_0x5ad9('0xc')]=_0x2262eb;};SmsQueue['prototype']['updateRealtime']=function(){this['loggedIn']=0x0;this[_0x5ad9('0xf')]=0x0;for(var _0x4519ad=0x0;_0x4519ad<this['Agents'][_0x5ad9('0x10')];_0x4519ad+=0x1){if(this[_0x5ad9('0x9')][_0x4519ad][_0x5ad9('0x11')]){this[_0x5ad9('0x12')]+=0x1;}if(this[_0x5ad9('0x9')][_0x4519ad][_0x5ad9('0x13')]){this[_0x5ad9('0xf')]+=0x1;}}this[_0x5ad9('0x14')]=this[_0x5ad9('0x12')]-this[_0x5ad9('0xf')];this['available']=this[_0x5ad9('0x14')]>=0x0?this['available']:0x0;var _0x3d1c8f={'id':this['id'],'available':this[_0x5ad9('0x14')],'loggedIn':this[_0x5ad9('0x12')],'name':this[_0x5ad9('0x15')],'paused':this[_0x5ad9('0xf')],'waiting':this[_0x5ad9('0x16')]};var _0x110c04=md5(JSON['stringify'](_0x3d1c8f));if(this[_0x5ad9('0x1')]!==_0x110c04){this['md5']=_0x110c04;io['to'](util['format'](_0x5ad9('0x17'),_0x3d1c8f['name']))[_0x5ad9('0x18')](_0x5ad9('0x19'),_0x3d1c8f);}};module[_0x5ad9('0x1a')]=SmsQueue;