Built motion from commit 19a84241.|2.5.34
[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 _0xb17b=['message','result','catch','UserVoiceQueueRt','findAll','options','raw','where','sequelize','COUNT','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','GetVoiceQueueRtPauses','lodash','util','moment','bluebird','ioredis','../../config/logger','rpc','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./userVoiceQueueRt.socket','register','request','then','info','request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error','UserVoiceQueueRt,\x20%s,\x20%s'];(function(_0x31dc39,_0x1ed3dd){var _0x4c426c=function(_0x27c291){while(--_0x27c291){_0x31dc39['push'](_0x31dc39['shift']());}};_0x4c426c(++_0x1ed3dd);}(_0xb17b,0x1bb));var _0xbb17=function(_0x3d6995,_0x163ddf){_0x3d6995=_0x3d6995-0x0;var _0x5279d4=_0xb17b[_0x3d6995];return _0x5279d4;};'use strict';var _=require(_0xbb17('0x0'));var util=require(_0xbb17('0x1'));var moment=require(_0xbb17('0x2'));var BPromise=require(_0xbb17('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xbb17('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xbb17('0x5'))(_0xbb17('0x6'));var config=require(_0xbb17('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xbb17('0x8')][_0xbb17('0x9')]({'port':0x232a});config[_0xbb17('0xa')]=_[_0xbb17('0xb')](config[_0xbb17('0xa')],{'host':_0xbb17('0xc'),'port':0x18eb});var socket=require(_0xbb17('0xd'))(new Redis(config['redis']));require(_0xbb17('0xe'))[_0xbb17('0xf')](socket);function respondWithRpcPromise(_0x578ea6,_0x2267ef,_0x77975){return new BPromise(function(_0x65b0f8,_0x2ec805){return client[_0xbb17('0x10')](_0x578ea6,_0x77975)[_0xbb17('0x11')](function(_0x59bea0){logger[_0xbb17('0x12')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x2267ef,_0xbb17('0x13'));logger[_0xbb17('0x14')](_0xbb17('0x15'),_0x2267ef,_0xbb17('0x13'),JSON[_0xbb17('0x16')](_0x59bea0));if(_0x59bea0[_0xbb17('0x17')]){if(_0x59bea0[_0xbb17('0x17')]['code']===0x1f4){logger['error'](_0xbb17('0x18'),_0x2267ef,_0x59bea0[_0xbb17('0x17')]['message']);return _0x2ec805(_0x59bea0[_0xbb17('0x17')][_0xbb17('0x19')]);}logger[_0xbb17('0x17')](_0xbb17('0x18'),_0x2267ef,_0x59bea0[_0xbb17('0x17')][_0xbb17('0x19')]);return _0x65b0f8(_0x59bea0[_0xbb17('0x17')][_0xbb17('0x19')]);}else{logger[_0xbb17('0x12')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x2267ef,_0xbb17('0x13'));_0x65b0f8(_0x59bea0[_0xbb17('0x1a')][_0xbb17('0x19')]);}})[_0xbb17('0x1b')](function(_0x5d1670){logger[_0xbb17('0x17')](_0xbb17('0x18'),_0x2267ef,_0x5d1670);_0x2ec805(_0x5d1670);});});}exports['GetVoiceQueueRtPauses']=function(_0x79bdc1){var _0x56152a=this;return new Promise(function(_0x59bcd3,_0x4bc0d4){return db[_0xbb17('0x1c')][_0xbb17('0x1d')]({'raw':_0x79bdc1[_0xbb17('0x1e')]?_0x79bdc1[_0xbb17('0x1e')][_0xbb17('0x1f')]===undefined?!![]:![]:!![],'where':_0x79bdc1['options']?_0x79bdc1[_0xbb17('0x1e')][_0xbb17('0x20')]||null:null,'attributes':[[db[_0xbb17('0x21')]['fn'](_0xbb17('0x22'),db[_0xbb17('0x21')]['fn']('IF',db[_0xbb17('0x21')][_0xbb17('0x23')](_0xbb17('0x24')))),_0xbb17('0x25')]]})[_0xbb17('0x11')](function(_0x3b44b9){logger[_0xbb17('0x12')](_0xbb17('0x26'),_0x79bdc1);logger[_0xbb17('0x14')](_0xbb17('0x26'),_0x79bdc1,JSON[_0xbb17('0x16')](_0x3b44b9));_0x59bcd3(_0x3b44b9);})[_0xbb17('0x1b')](function(_0x4d402c){logger['error'](_0xbb17('0x26'),_0x4d402c[_0xbb17('0x19')],_0x79bdc1);_0x4bc0d4(_0x56152a[_0xbb17('0x17')](0x1f4,_0x4d402c[_0xbb17('0x19')]));});});};