98a9a3b37cdefea98508b1d45889698c0db69bc5
[motion2.git] / server / api / userVoiceQueueRt / userVoiceQueueRt.rpc.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 _0x71b8=['defaults','localhost','socket.io-emitter','./userVoiceQueueRt.socket','request','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','raw','where','sequelize','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','then','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','redis'];(function(_0x14286b,_0x29e206){var _0x18ee17=function(_0x46b51a){while(--_0x46b51a){_0x14286b['push'](_0x14286b['shift']());}};_0x18ee17(++_0x29e206);}(_0x71b8,0x90));var _0x871b=function(_0xa148b7,_0x2f3eb2){_0xa148b7=_0xa148b7-0x0;var _0x51efd3=_0x71b8[_0xa148b7];return _0x51efd3;};'use strict';var _=require(_0x871b('0x0'));var util=require(_0x871b('0x1'));var moment=require(_0x871b('0x2'));var BPromise=require(_0x871b('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x871b('0x4'));var db=require(_0x871b('0x5'))['db'];var utils=require(_0x871b('0x6'));var logger=require(_0x871b('0x7'))('rpc');var config=require(_0x871b('0x8'));var jayson=require(_0x871b('0x9'));var client=jayson['client'][_0x871b('0xa')]({'port':0x232a});config[_0x871b('0xb')]=_[_0x871b('0xc')](config[_0x871b('0xb')],{'host':_0x871b('0xd'),'port':0x18eb});var socket=require(_0x871b('0xe'))(new Redis(config[_0x871b('0xb')]));require(_0x871b('0xf'))['register'](socket);function respondWithRpcPromise(_0x687da9,_0x48bccd,_0x44c777){return new BPromise(function(_0x36205f,_0x1eea07){return client[_0x871b('0x10')](_0x687da9,_0x44c777)['then'](function(_0xa6d086){logger[_0x871b('0x11')](_0x871b('0x12'),_0x48bccd,_0x871b('0x13'));logger[_0x871b('0x14')](_0x871b('0x15'),_0x48bccd,_0x871b('0x13'),JSON[_0x871b('0x16')](_0xa6d086));if(_0xa6d086[_0x871b('0x17')]){if(_0xa6d086['error'][_0x871b('0x18')]===0x1f4){logger[_0x871b('0x17')](_0x871b('0x12'),_0x48bccd,_0xa6d086[_0x871b('0x17')][_0x871b('0x19')]);return _0x1eea07(_0xa6d086[_0x871b('0x17')][_0x871b('0x19')]);}logger[_0x871b('0x17')](_0x871b('0x12'),_0x48bccd,_0xa6d086[_0x871b('0x17')][_0x871b('0x19')]);return _0x36205f(_0xa6d086[_0x871b('0x17')][_0x871b('0x19')]);}else{logger['info'](_0x871b('0x12'),_0x48bccd,_0x871b('0x13'));_0x36205f(_0xa6d086[_0x871b('0x1a')][_0x871b('0x19')]);}})[_0x871b('0x1b')](function(_0x4210d0){logger[_0x871b('0x17')](_0x871b('0x12'),_0x48bccd,_0x4210d0);_0x1eea07(_0x4210d0);});});}exports[_0x871b('0x1c')]=function(_0x5303f6){var _0x58f31d=this;return new Promise(function(_0x4391ce,_0x579bc2){return db[_0x871b('0x1d')][_0x871b('0x1e')]({'raw':_0x5303f6['options']?_0x5303f6[_0x871b('0x1f')][_0x871b('0x20')]===undefined?!![]:![]:!![],'where':_0x5303f6['options']?_0x5303f6[_0x871b('0x1f')][_0x871b('0x21')]||null:null,'attributes':[[db[_0x871b('0x22')]['fn']('COUNT',db[_0x871b('0x22')]['fn']('IF',db['sequelize'][_0x871b('0x23')](_0x871b('0x24')))),_0x871b('0x25')]]})[_0x871b('0x26')](function(_0x317f79){logger['info'](_0x871b('0x1c'),_0x5303f6);logger[_0x871b('0x14')]('GetVoiceQueueRtPauses',_0x5303f6,JSON[_0x871b('0x16')](_0x317f79));_0x4391ce(_0x317f79);})[_0x871b('0x1b')](function(_0x12b69c){logger[_0x871b('0x17')](_0x871b('0x1c'),_0x12b69c[_0x871b('0x19')],_0x5303f6);_0x579bc2(_0x58f31d[_0x871b('0x17')](0x1f4,_0x12b69c[_0x871b('0x19')]));});});};