Built motion from commit 753c950e.|2.5.42
[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 _0x3bd3=['redis','localhost','socket.io-emitter','./userVoiceQueueRt.socket','register','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','where','sequelize','COUNT','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','debug','lodash','util','bluebird','randomstring','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http'];(function(_0x104cc5,_0xe367a9){var _0x259111=function(_0x1088fc){while(--_0x1088fc){_0x104cc5['push'](_0x104cc5['shift']());}};_0x259111(++_0xe367a9);}(_0x3bd3,0x172));var _0x33bd=function(_0x35ad07,_0x4b6cc4){_0x35ad07=_0x35ad07-0x0;var _0x5346ee=_0x3bd3[_0x35ad07];return _0x5346ee;};'use strict';var _=require(_0x33bd('0x0'));var util=require(_0x33bd('0x1'));var moment=require('moment');var BPromise=require(_0x33bd('0x2'));var rs=require(_0x33bd('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x33bd('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x33bd('0x5'));var config=require(_0x33bd('0x6'));var jayson=require(_0x33bd('0x7'));var client=jayson[_0x33bd('0x8')][_0x33bd('0x9')]({'port':0x232a});config[_0x33bd('0xa')]=_['defaults'](config[_0x33bd('0xa')],{'host':_0x33bd('0xb'),'port':0x18eb});var socket=require(_0x33bd('0xc'))(new Redis(config[_0x33bd('0xa')]));require(_0x33bd('0xd'))[_0x33bd('0xe')](socket);function respondWithRpcPromise(_0x1f61f7,_0x1b8e75,_0x4261cf){return new BPromise(function(_0x2bcde4,_0xf0b64){return client[_0x33bd('0xf')](_0x1f61f7,_0x4261cf)[_0x33bd('0x10')](function(_0x3fdc5e){logger[_0x33bd('0x11')](_0x33bd('0x12'),_0x1b8e75,_0x33bd('0x13'));logger['debug'](_0x33bd('0x14'),_0x1b8e75,_0x33bd('0x13'),JSON[_0x33bd('0x15')](_0x3fdc5e));if(_0x3fdc5e['error']){if(_0x3fdc5e[_0x33bd('0x16')][_0x33bd('0x17')]===0x1f4){logger[_0x33bd('0x16')](_0x33bd('0x12'),_0x1b8e75,_0x3fdc5e['error'][_0x33bd('0x18')]);return _0xf0b64(_0x3fdc5e['error'][_0x33bd('0x18')]);}logger[_0x33bd('0x16')](_0x33bd('0x12'),_0x1b8e75,_0x3fdc5e[_0x33bd('0x16')]['message']);return _0x2bcde4(_0x3fdc5e['error'][_0x33bd('0x18')]);}else{logger[_0x33bd('0x11')](_0x33bd('0x12'),_0x1b8e75,'request\x20sent');_0x2bcde4(_0x3fdc5e[_0x33bd('0x19')][_0x33bd('0x18')]);}})[_0x33bd('0x1a')](function(_0x1c0fe5){logger[_0x33bd('0x16')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x1b8e75,_0x1c0fe5);_0xf0b64(_0x1c0fe5);});});}exports[_0x33bd('0x1b')]=function(_0x99c0b6){var _0x5be106=this;return new Promise(function(_0x53287d,_0x478086){return db[_0x33bd('0x1c')][_0x33bd('0x1d')]({'raw':_0x99c0b6['options']?_0x99c0b6[_0x33bd('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x99c0b6[_0x33bd('0x1e')]?_0x99c0b6[_0x33bd('0x1e')][_0x33bd('0x1f')]||null:null,'attributes':[[db[_0x33bd('0x20')]['fn'](_0x33bd('0x21'),db[_0x33bd('0x20')]['fn']('IF',db[_0x33bd('0x20')][_0x33bd('0x22')](_0x33bd('0x23')))),_0x33bd('0x24')]]})['then'](function(_0x27828d){logger['info']('GetVoiceQueueRtPauses',_0x99c0b6);logger[_0x33bd('0x25')](_0x33bd('0x1b'),_0x99c0b6,JSON[_0x33bd('0x15')](_0x27828d));_0x53287d(_0x27828d);})[_0x33bd('0x1a')](function(_0x5d4c7e){logger[_0x33bd('0x16')](_0x33bd('0x1b'),_0x5d4c7e[_0x33bd('0x18')],_0x99c0b6);_0x478086(_0x5be106['error'](0x1f4,_0x5d4c7e[_0x33bd('0x18')]));});});};