0669ed23140b6be96357f99885040268506b3704
[motion2.git] / server / services / routing / model / faxQueue.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 _0x4e74=['redis','defaults','socket.io-emitter','name','timeout','strategy','beepall','Agents','updateRealtime','prototype','_rr','mapAgentsId','loggedIn','paused','online','faxPause','available','waiting','format','fax_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment'];(function(_0x44a64f,_0x38475c){var _0x52024b=function(_0x2cd055){while(--_0x2cd055){_0x44a64f['push'](_0x44a64f['shift']());}};_0x52024b(++_0x38475c);}(_0x4e74,0xcb));var _0x44e7=function(_0x27e811,_0x20137c){_0x27e811=_0x27e811-0x0;var _0x1627fa=_0x4e74[_0x27e811];return _0x1627fa;};'use strict';var _=require(_0x44e7('0x0'));var md5=require(_0x44e7('0x1'));var util=require(_0x44e7('0x2'));var Redis=require(_0x44e7('0x3'));var config=require(_0x44e7('0x4'));config[_0x44e7('0x5')]=_[_0x44e7('0x6')](config[_0x44e7('0x5')],{'host':'localhost','port':0x18eb});var io=require(_0x44e7('0x7'))(new Redis(config[_0x44e7('0x5')]));function FaxQueue(_0x112ee5){this['id']=_0x112ee5['id']||0x0;this[_0x44e7('0x8')]=_0x112ee5['name']||'';this[_0x44e7('0x9')]=_0x112ee5['timeout']||0xa;this[_0x44e7('0xa')]=_0x112ee5['strategy']||_0x44e7('0xb');this[_0x44e7('0xc')]=_0x112ee5[_0x44e7('0xc')];this['mapAgentsId']={};this['waiting']=0x0;this[_0x44e7('0x1')]='';this['updateRouting']();this[_0x44e7('0xd')]();}FaxQueue[_0x44e7('0xe')]['updateRouting']=function(){var _0x161422=this['mapAgentsId'][_0x44e7('0xf')];this['mapAgentsId']=_['map'](this[_0x44e7('0xc')],'id');this[_0x44e7('0x10')][_0x44e7('0xf')]=_0x161422;};FaxQueue[_0x44e7('0xe')][_0x44e7('0xd')]=function(){this[_0x44e7('0x11')]=0x0;this[_0x44e7('0x12')]=0x0;for(var _0x4c274e=0x0;_0x4c274e<this[_0x44e7('0xc')]['length'];_0x4c274e+=0x1){if(this['Agents'][_0x4c274e][_0x44e7('0x13')]){this[_0x44e7('0x11')]+=0x1;}if(this['Agents'][_0x4c274e][_0x44e7('0x14')]){this[_0x44e7('0x12')]+=0x1;}}this[_0x44e7('0x15')]=this[_0x44e7('0x11')]-this['paused'];this[_0x44e7('0x15')]=this['available']>=0x0?this[_0x44e7('0x15')]:0x0;var _0x3bc0f7={'id':this['id'],'available':this[_0x44e7('0x15')],'loggedIn':this[_0x44e7('0x11')],'name':this['name'],'paused':this[_0x44e7('0x12')],'waiting':this[_0x44e7('0x16')]};var _0x54aef1=md5(JSON['stringify'](_0x3bc0f7));if(this[_0x44e7('0x1')]!==_0x54aef1){this[_0x44e7('0x1')]=_0x54aef1;io['to'](util[_0x44e7('0x17')]('fax:queue:%s',_0x3bc0f7['name']))['emit'](_0x44e7('0x18'),_0x3bc0f7);}};module[_0x44e7('0x19')]=FaxQueue;