Built motion from commit (unavailable).|2.0.80
[motion2.git] / server / api / voiceQueue / voiceQueue.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 _0x430c=['VoiceQueue,\x20%s,\x20%s','debug','request\x20sent','error','code','message','result','catch','findAll','options','raw','where','attributes','include','map','model','GetVoiceQueue','ShowVoiceQueue','VoiceQueue','find','stringify','lodash','bluebird','randomstring','../../mysqldb','jayson/promise','client','socket.io-emitter','./voiceQueue.socket','register','request','then','info'];(function(_0x7b366c,_0x56f05e){var _0x4b3530=function(_0x54a8d6){while(--_0x54a8d6){_0x7b366c['push'](_0x7b366c['shift']());}};_0x4b3530(++_0x56f05e);}(_0x430c,0x1a1));var _0xc430=function(_0x9db5d3,_0x4eea5e){_0x9db5d3=_0x9db5d3-0x0;var _0x477a81=_0x430c[_0x9db5d3];return _0x477a81;};'use strict';var _=require(_0xc430('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xc430('0x1'));var rs=require(_0xc430('0x2'));var fs=require('fs');var db=require(_0xc430('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0xc430('0x4'));var client=jayson[_0xc430('0x5')]['http']({'port':0x232a});var socket=require(_0xc430('0x6'))({'host':'localhost','port':0x18eb});require(_0xc430('0x7'))[_0xc430('0x8')](socket);function respondWithRpcPromise(_0x814a90,_0x13ae66,_0x2e23f8){return new BPromise(function(_0x11f4b0,_0x861581){return client[_0xc430('0x9')](_0x814a90,_0x2e23f8)[_0xc430('0xa')](function(_0x5bbdf9){logger[_0xc430('0xb')](_0xc430('0xc'),_0x13ae66,'request\x20sent');logger[_0xc430('0xd')]('VoiceQueue,\x20%s,\x20%s,\x20%s',_0x13ae66,_0xc430('0xe'),JSON['stringify'](_0x5bbdf9));if(_0x5bbdf9[_0xc430('0xf')]){if(_0x5bbdf9[_0xc430('0xf')][_0xc430('0x10')]===0x1f4){logger[_0xc430('0xf')](_0xc430('0xc'),_0x13ae66,_0x5bbdf9[_0xc430('0xf')][_0xc430('0x11')]);return _0x861581(_0x5bbdf9['error']['message']);}logger[_0xc430('0xf')](_0xc430('0xc'),_0x13ae66,_0x5bbdf9[_0xc430('0xf')][_0xc430('0x11')]);return _0x11f4b0(_0x5bbdf9[_0xc430('0xf')]['message']);}else{logger[_0xc430('0xb')]('VoiceQueue,\x20%s,\x20%s',_0x13ae66,'request\x20sent');_0x11f4b0(_0x5bbdf9[_0xc430('0x12')][_0xc430('0x11')]);}})[_0xc430('0x13')](function(_0x5830b0){logger['error'](_0xc430('0xc'),_0x13ae66,_0x5830b0);_0x861581(_0x5830b0);});});}exports['GetVoiceQueue']=function(_0x2bcb21){var _0x4f7094=this;return new Promise(function(_0x564522,_0x2f3203){return db['VoiceQueue'][_0xc430('0x14')]({'raw':_0x2bcb21[_0xc430('0x15')]?_0x2bcb21[_0xc430('0x15')][_0xc430('0x16')]===undefined?!![]:![]:!![],'where':_0x2bcb21[_0xc430('0x15')]?_0x2bcb21['options'][_0xc430('0x17')]||null:null,'attributes':_0x2bcb21['options']?_0x2bcb21['options'][_0xc430('0x18')]||null:null,'limit':_0x2bcb21[_0xc430('0x15')]?_0x2bcb21[_0xc430('0x15')]['limit']||null:null,'include':_0x2bcb21[_0xc430('0x15')]?_0x2bcb21['options'][_0xc430('0x19')]?_[_0xc430('0x1a')](_0x2bcb21['options'][_0xc430('0x19')],function(_0x3cdbd3){return{'model':db[_0x3cdbd3['model']],'as':_0x3cdbd3['as'],'attributes':_0x3cdbd3[_0xc430('0x18')],'include':_0x3cdbd3['include']?_[_0xc430('0x1a')](_0x3cdbd3['include'],function(_0x3db397){return{'model':db[_0x3db397[_0xc430('0x1b')]],'as':_0x3db397['as'],'attributes':_0x3db397['attributes'],'include':_0x3db397[_0xc430('0x19')]?_[_0xc430('0x1a')](_0x3db397[_0xc430('0x19')],function(_0x44833e){return{'model':db[_0x44833e[_0xc430('0x1b')]],'as':_0x44833e['as'],'attributes':_0x44833e['attributes']};}):[]};}):[]};}):[]:[]})[_0xc430('0xa')](function(_0x1a9512){logger[_0xc430('0xb')](_0xc430('0x1c'),_0x2bcb21);logger['debug'](_0xc430('0x1c'),_0x2bcb21,JSON['stringify'](_0x1a9512));_0x564522(_0x1a9512);})[_0xc430('0x13')](function(_0x4ad29e){logger[_0xc430('0xf')](_0xc430('0x1c'),_0x4ad29e[_0xc430('0x11')],_0x2bcb21);_0x2f3203(_0x4f7094[_0xc430('0xf')](0x1f4,_0x4ad29e['message']));});});};exports[_0xc430('0x1d')]=function(_0x2a85aa){var _0x2bdfc4=this;return new Promise(function(_0xaec1ed,_0x49ba65){return db[_0xc430('0x1e')][_0xc430('0x1f')]({'raw':_0x2a85aa['options']?_0x2a85aa[_0xc430('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x2a85aa['options']?_0x2a85aa[_0xc430('0x15')][_0xc430('0x17')]||null:null,'attributes':_0x2a85aa[_0xc430('0x15')]?_0x2a85aa[_0xc430('0x15')][_0xc430('0x18')]||null:null,'include':_0x2a85aa[_0xc430('0x15')]?_0x2a85aa[_0xc430('0x15')][_0xc430('0x19')]?_['map'](_0x2a85aa[_0xc430('0x15')]['include'],function(_0x119bee){return{'model':db[_0x119bee[_0xc430('0x1b')]],'as':_0x119bee['as'],'attributes':_0x119bee[_0xc430('0x18')],'include':_0x119bee[_0xc430('0x19')]?_['map'](_0x119bee[_0xc430('0x19')],function(_0x510fa1){return{'model':db[_0x510fa1['model']],'as':_0x510fa1['as'],'attributes':_0x510fa1[_0xc430('0x18')],'include':_0x510fa1[_0xc430('0x19')]?_['map'](_0x510fa1[_0xc430('0x19')],function(_0x10e589){return{'model':db[_0x10e589[_0xc430('0x1b')]],'as':_0x10e589['as'],'attributes':_0x10e589[_0xc430('0x18')]};}):[]};}):[]};}):[]:[]})[_0xc430('0xa')](function(_0x2c00a4){logger[_0xc430('0xb')](_0xc430('0x1d'),_0x2a85aa);logger[_0xc430('0xd')](_0xc430('0x1d'),_0x2a85aa,JSON[_0xc430('0x20')](_0x2c00a4));_0xaec1ed(_0x2c00a4);})[_0xc430('0x13')](function(_0x5fd38b){logger[_0xc430('0xf')](_0xc430('0x1d'),_0x5fd38b['message'],_0x2a85aa);_0x49ba65(_0x2bdfc4[_0xc430('0xf')](0x1f4,_0x5fd38b[_0xc430('0x11')]));});});};