2755c12c34f9c6ee9b6c4ea942a66ee2a71cc8df
[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 _0x4f5f=['../../config/utils','../../config/logger','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./userVoiceQueueRt.socket','register','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','error','message','result','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','raw','sequelize','COUNT','literal','catch','util','moment','bluebird','ioredis'];(function(_0x17f5a4,_0x504142){var _0x54f485=function(_0x484eee){while(--_0x484eee){_0x17f5a4['push'](_0x17f5a4['shift']());}};_0x54f485(++_0x504142);}(_0x4f5f,0x1ca));var _0xf4f5=function(_0xdea41a,_0x552987){_0xdea41a=_0xdea41a-0x0;var _0x15d0d8=_0x4f5f[_0xdea41a];return _0x15d0d8;};'use strict';var _=require('lodash');var util=require(_0xf4f5('0x0'));var moment=require(_0xf4f5('0x1'));var BPromise=require(_0xf4f5('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xf4f5('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0xf4f5('0x4'));var logger=require(_0xf4f5('0x5'))('rpc');var config=require(_0xf4f5('0x6'));var jayson=require('jayson/promise');var client=jayson[_0xf4f5('0x7')][_0xf4f5('0x8')]({'port':0x232a});config[_0xf4f5('0x9')]=_[_0xf4f5('0xa')](config[_0xf4f5('0x9')],{'host':_0xf4f5('0xb'),'port':0x18eb});var socket=require(_0xf4f5('0xc'))(new Redis(config[_0xf4f5('0x9')]));require(_0xf4f5('0xd'))[_0xf4f5('0xe')](socket);function respondWithRpcPromise(_0x402811,_0x2c78da,_0x425c6b){return new BPromise(function(_0x54745a,_0x59f5c7){return client[_0xf4f5('0xf')](_0x402811,_0x425c6b)[_0xf4f5('0x10')](function(_0x5b31d4){logger[_0xf4f5('0x11')](_0xf4f5('0x12'),_0x2c78da,_0xf4f5('0x13'));logger[_0xf4f5('0x14')]('UserVoiceQueueRt,\x20%s,\x20%s,\x20%s',_0x2c78da,_0xf4f5('0x13'),JSON['stringify'](_0x5b31d4));if(_0x5b31d4[_0xf4f5('0x15')]){if(_0x5b31d4['error']['code']===0x1f4){logger[_0xf4f5('0x15')](_0xf4f5('0x12'),_0x2c78da,_0x5b31d4[_0xf4f5('0x15')][_0xf4f5('0x16')]);return _0x59f5c7(_0x5b31d4['error'][_0xf4f5('0x16')]);}logger['error'](_0xf4f5('0x12'),_0x2c78da,_0x5b31d4['error'][_0xf4f5('0x16')]);return _0x54745a(_0x5b31d4['error']['message']);}else{logger[_0xf4f5('0x11')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x2c78da,'request\x20sent');_0x54745a(_0x5b31d4[_0xf4f5('0x17')][_0xf4f5('0x16')]);}})['catch'](function(_0x460603){logger[_0xf4f5('0x15')](_0xf4f5('0x12'),_0x2c78da,_0x460603);_0x59f5c7(_0x460603);});});}exports[_0xf4f5('0x18')]=function(_0x4abbee){var _0x122444=this;return new Promise(function(_0x22c22d,_0xe13fb5){return db[_0xf4f5('0x19')][_0xf4f5('0x1a')]({'raw':_0x4abbee[_0xf4f5('0x1b')]?_0x4abbee[_0xf4f5('0x1b')][_0xf4f5('0x1c')]===undefined?!![]:![]:!![],'where':_0x4abbee[_0xf4f5('0x1b')]?_0x4abbee[_0xf4f5('0x1b')]['where']||null:null,'attributes':[[db[_0xf4f5('0x1d')]['fn'](_0xf4f5('0x1e'),db[_0xf4f5('0x1d')]['fn']('IF',db[_0xf4f5('0x1d')][_0xf4f5('0x1f')]('`paused`\x20=\x201,\x201,\x20null'))),'outboundQueuePauses']]})[_0xf4f5('0x10')](function(_0x88645c){logger[_0xf4f5('0x11')]('GetVoiceQueueRtPauses',_0x4abbee);logger['debug'](_0xf4f5('0x18'),_0x4abbee,JSON['stringify'](_0x88645c));_0x22c22d(_0x88645c);})[_0xf4f5('0x20')](function(_0x19385f){logger[_0xf4f5('0x15')]('GetVoiceQueueRtPauses',_0x19385f[_0xf4f5('0x16')],_0x4abbee);_0xe13fb5(_0x122444[_0xf4f5('0x15')](0x1f4,_0x19385f['message']));});});};