04054a4a466cccec4cd39a9ec8406afa3542e5e5
[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 _0x4f18=['randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./userVoiceQueueRt.socket','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','raw','where','COUNT','sequelize','`paused`\x20=\x201,\x201,\x20null','lodash','util','moment'];(function(_0x539600,_0x300e76){var _0x73085c=function(_0x266a15){while(--_0x266a15){_0x539600['push'](_0x539600['shift']());}};_0x73085c(++_0x300e76);}(_0x4f18,0x189));var _0x84f1=function(_0x5d13cc,_0x477225){_0x5d13cc=_0x5d13cc-0x0;var _0x213938=_0x4f18[_0x5d13cc];return _0x213938;};'use strict';var _=require(_0x84f1('0x0'));var util=require(_0x84f1('0x1'));var moment=require(_0x84f1('0x2'));var BPromise=require('bluebird');var rs=require(_0x84f1('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x84f1('0x4'));var logger=require(_0x84f1('0x5'))(_0x84f1('0x6'));var config=require(_0x84f1('0x7'));var jayson=require(_0x84f1('0x8'));var client=jayson[_0x84f1('0x9')][_0x84f1('0xa')]({'port':0x232a});config[_0x84f1('0xb')]=_[_0x84f1('0xc')](config['redis'],{'host':_0x84f1('0xd'),'port':0x18eb});var socket=require(_0x84f1('0xe'))(new Redis(config[_0x84f1('0xb')]));require(_0x84f1('0xf'))['register'](socket);function respondWithRpcPromise(_0x497ef9,_0x40781b,_0xe18fd2){return new BPromise(function(_0x4a70af,_0x1bf878){return client[_0x84f1('0x10')](_0x497ef9,_0xe18fd2)[_0x84f1('0x11')](function(_0x559012){logger[_0x84f1('0x12')](_0x84f1('0x13'),_0x40781b,'request\x20sent');logger[_0x84f1('0x14')](_0x84f1('0x15'),_0x40781b,'request\x20sent',JSON[_0x84f1('0x16')](_0x559012));if(_0x559012[_0x84f1('0x17')]){if(_0x559012[_0x84f1('0x17')][_0x84f1('0x18')]===0x1f4){logger['error']('UserVoiceQueueRt,\x20%s,\x20%s',_0x40781b,_0x559012[_0x84f1('0x17')][_0x84f1('0x19')]);return _0x1bf878(_0x559012['error'][_0x84f1('0x19')]);}logger[_0x84f1('0x17')](_0x84f1('0x13'),_0x40781b,_0x559012[_0x84f1('0x17')]['message']);return _0x4a70af(_0x559012[_0x84f1('0x17')][_0x84f1('0x19')]);}else{logger[_0x84f1('0x12')](_0x84f1('0x13'),_0x40781b,'request\x20sent');_0x4a70af(_0x559012[_0x84f1('0x1a')][_0x84f1('0x19')]);}})['catch'](function(_0x6b3a53){logger[_0x84f1('0x17')](_0x84f1('0x13'),_0x40781b,_0x6b3a53);_0x1bf878(_0x6b3a53);});});}exports[_0x84f1('0x1b')]=function(_0xa5bc79){var _0x39fb68=this;return new Promise(function(_0xf26d47,_0x4c3e44){return db[_0x84f1('0x1c')][_0x84f1('0x1d')]({'raw':_0xa5bc79[_0x84f1('0x1e')]?_0xa5bc79['options'][_0x84f1('0x1f')]===undefined?!![]:![]:!![],'where':_0xa5bc79[_0x84f1('0x1e')]?_0xa5bc79[_0x84f1('0x1e')][_0x84f1('0x20')]||null:null,'attributes':[[db['sequelize']['fn'](_0x84f1('0x21'),db['sequelize']['fn']('IF',db[_0x84f1('0x22')]['literal'](_0x84f1('0x23')))),'outboundQueuePauses']]})[_0x84f1('0x11')](function(_0xdb5f81){logger[_0x84f1('0x12')](_0x84f1('0x1b'),_0xa5bc79);logger[_0x84f1('0x14')](_0x84f1('0x1b'),_0xa5bc79,JSON[_0x84f1('0x16')](_0xdb5f81));_0xf26d47(_0xdb5f81);})['catch'](function(_0x4885cf){logger[_0x84f1('0x17')]('GetVoiceQueueRtPauses',_0x4885cf['message'],_0xa5bc79);_0x4c3e44(_0x39fb68[_0x84f1('0x17')](0x1f4,_0x4885cf['message']));});});};