509ff58046394c342161ead0abc3ec496cdd6b83
[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 _0x116c=['error','message','result','catch','UserVoiceQueueRt','findAll','options','where','sequelize','COUNT','`paused`\x20=\x201,\x201,\x20null','GetVoiceQueueRtPauses','stringify','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','register','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x1a809b,_0x4c15e3){var _0x5d90e6=function(_0x5dd2e1){while(--_0x5dd2e1){_0x1a809b['push'](_0x1a809b['shift']());}};_0x5d90e6(++_0x4c15e3);}(_0x116c,0x161));var _0xc116=function(_0x504708,_0x5462f8){_0x504708=_0x504708-0x0;var _0x3599fd=_0x116c[_0x504708];return _0x3599fd;};'use strict';var _=require(_0xc116('0x0'));var util=require(_0xc116('0x1'));var moment=require('moment');var BPromise=require(_0xc116('0x2'));var rs=require(_0xc116('0x3'));var fs=require('fs');var Redis=require(_0xc116('0x4'));var db=require(_0xc116('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xc116('0x6'));var config=require(_0xc116('0x7'));var jayson=require(_0xc116('0x8'));var client=jayson[_0xc116('0x9')][_0xc116('0xa')]({'port':0x232a});config[_0xc116('0xb')]=_['defaults'](config['redis'],{'host':_0xc116('0xc'),'port':0x18eb});var socket=require(_0xc116('0xd'))(new Redis(config[_0xc116('0xb')]));require('./userVoiceQueueRt.socket')[_0xc116('0xe')](socket);function respondWithRpcPromise(_0x1dc9ad,_0x19f6b3,_0x42d5cb){return new BPromise(function(_0x15912c,_0xbcf72e){return client[_0xc116('0xf')](_0x1dc9ad,_0x42d5cb)[_0xc116('0x10')](function(_0x4d8668){logger[_0xc116('0x11')](_0xc116('0x12'),_0x19f6b3,_0xc116('0x13'));logger[_0xc116('0x14')]('UserVoiceQueueRt,\x20%s,\x20%s,\x20%s',_0x19f6b3,'request\x20sent',JSON['stringify'](_0x4d8668));if(_0x4d8668[_0xc116('0x15')]){if(_0x4d8668[_0xc116('0x15')]['code']===0x1f4){logger[_0xc116('0x15')](_0xc116('0x12'),_0x19f6b3,_0x4d8668[_0xc116('0x15')][_0xc116('0x16')]);return _0xbcf72e(_0x4d8668[_0xc116('0x15')][_0xc116('0x16')]);}logger[_0xc116('0x15')](_0xc116('0x12'),_0x19f6b3,_0x4d8668[_0xc116('0x15')][_0xc116('0x16')]);return _0x15912c(_0x4d8668[_0xc116('0x15')][_0xc116('0x16')]);}else{logger['info'](_0xc116('0x12'),_0x19f6b3,_0xc116('0x13'));_0x15912c(_0x4d8668[_0xc116('0x17')][_0xc116('0x16')]);}})[_0xc116('0x18')](function(_0x574326){logger[_0xc116('0x15')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x19f6b3,_0x574326);_0xbcf72e(_0x574326);});});}exports['GetVoiceQueueRtPauses']=function(_0x503e2e){var _0x20ea73=this;return new Promise(function(_0x2a1c09,_0x127741){return db[_0xc116('0x19')][_0xc116('0x1a')]({'raw':_0x503e2e[_0xc116('0x1b')]?_0x503e2e[_0xc116('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x503e2e[_0xc116('0x1b')]?_0x503e2e[_0xc116('0x1b')][_0xc116('0x1c')]||null:null,'attributes':[[db[_0xc116('0x1d')]['fn'](_0xc116('0x1e'),db[_0xc116('0x1d')]['fn']('IF',db['sequelize']['literal'](_0xc116('0x1f')))),'outboundQueuePauses']]})[_0xc116('0x10')](function(_0x2c6c2b){logger['info']('GetVoiceQueueRtPauses',_0x503e2e);logger[_0xc116('0x14')](_0xc116('0x20'),_0x503e2e,JSON[_0xc116('0x21')](_0x2c6c2b));_0x2a1c09(_0x2c6c2b);})['catch'](function(_0x323f0b){logger[_0xc116('0x15')](_0xc116('0x20'),_0x323f0b[_0xc116('0x16')],_0x503e2e);_0x127741(_0x20ea73['error'](0x1f4,_0x323f0b[_0xc116('0x16')]));});});};