Built motion from commit 9d0783e6.|2.6.13
[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 _0x3642=['stringify','error','code','message','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','COUNT','sequelize','literal','outboundQueuePauses','catch','lodash','util','moment','bluebird','../../config/utils','rpc','redis','defaults','localhost','register','request','then','info','UserVoiceQueueRt,\x20%s,\x20%s','request\x20sent','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s'];(function(_0x6131cd,_0x4c26a1){var _0x47e916=function(_0x1f2bce){while(--_0x1f2bce){_0x6131cd['push'](_0x6131cd['shift']());}};_0x47e916(++_0x4c26a1);}(_0x3642,0x193));var _0x2364=function(_0x525b28,_0x5cf5a0){_0x525b28=_0x525b28-0x0;var _0x180178=_0x3642[_0x525b28];return _0x180178;};'use strict';var _=require(_0x2364('0x0'));var util=require(_0x2364('0x1'));var moment=require(_0x2364('0x2'));var BPromise=require(_0x2364('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x2364('0x4'));var logger=require('../../config/logger')(_0x2364('0x5'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});config[_0x2364('0x6')]=_[_0x2364('0x7')](config[_0x2364('0x6')],{'host':_0x2364('0x8'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x2364('0x6')]));require('./userVoiceQueueRt.socket')[_0x2364('0x9')](socket);function respondWithRpcPromise(_0x102466,_0x5927a0,_0x2fcfbf){return new BPromise(function(_0x2acd50,_0x5d0e4c){return client[_0x2364('0xa')](_0x102466,_0x2fcfbf)[_0x2364('0xb')](function(_0xa0f326){logger[_0x2364('0xc')](_0x2364('0xd'),_0x5927a0,_0x2364('0xe'));logger[_0x2364('0xf')](_0x2364('0x10'),_0x5927a0,_0x2364('0xe'),JSON[_0x2364('0x11')](_0xa0f326));if(_0xa0f326[_0x2364('0x12')]){if(_0xa0f326['error'][_0x2364('0x13')]===0x1f4){logger['error'](_0x2364('0xd'),_0x5927a0,_0xa0f326[_0x2364('0x12')][_0x2364('0x14')]);return _0x5d0e4c(_0xa0f326[_0x2364('0x12')][_0x2364('0x14')]);}logger[_0x2364('0x12')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x5927a0,_0xa0f326[_0x2364('0x12')]['message']);return _0x2acd50(_0xa0f326['error'][_0x2364('0x14')]);}else{logger[_0x2364('0xc')]('UserVoiceQueueRt,\x20%s,\x20%s',_0x5927a0,_0x2364('0xe'));_0x2acd50(_0xa0f326['result'][_0x2364('0x14')]);}})['catch'](function(_0x2a10ea){logger[_0x2364('0x12')](_0x2364('0xd'),_0x5927a0,_0x2a10ea);_0x5d0e4c(_0x2a10ea);});});}exports[_0x2364('0x15')]=function(_0x2145e9){var _0x12f230=this;return new Promise(function(_0x1c6c5f,_0x5d918d){return db[_0x2364('0x16')][_0x2364('0x17')]({'raw':_0x2145e9[_0x2364('0x18')]?_0x2145e9[_0x2364('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x2145e9['options']?_0x2145e9[_0x2364('0x18')]['where']||null:null,'attributes':[[db['sequelize']['fn'](_0x2364('0x19'),db[_0x2364('0x1a')]['fn']('IF',db['sequelize'][_0x2364('0x1b')]('`paused`\x20=\x201,\x201,\x20null'))),_0x2364('0x1c')]]})[_0x2364('0xb')](function(_0x27cf0d){logger[_0x2364('0xc')]('GetVoiceQueueRtPauses',_0x2145e9);logger[_0x2364('0xf')](_0x2364('0x15'),_0x2145e9,JSON[_0x2364('0x11')](_0x27cf0d));_0x1c6c5f(_0x27cf0d);})[_0x2364('0x1d')](function(_0x38bba1){logger[_0x2364('0x12')](_0x2364('0x15'),_0x38bba1[_0x2364('0x14')],_0x2145e9);_0x5d918d(_0x12f230[_0x2364('0x12')](0x1f4,_0x38bba1[_0x2364('0x14')]));});});};