Built motion from commit 449495f6.|2.6.27
[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 _0x6007=['randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','defaults','redis','localhost','socket.io-emitter','./voiceQueue.socket','register','request','then','info','VoiceQueue,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','catch','GetVoiceQueue','VoiceQueue','findAll','options','raw','where','attributes','limit','include','map','model','ShowVoiceQueue','find','stringify','lodash','util','bluebird'];(function(_0x36c5b0,_0x5001da){var _0xf19333=function(_0x1e880a){while(--_0x1e880a){_0x36c5b0['push'](_0x36c5b0['shift']());}};_0xf19333(++_0x5001da);}(_0x6007,0xa1));var _0x7600=function(_0x45bf86,_0x75586e){_0x45bf86=_0x45bf86-0x0;var _0x1f02b7=_0x6007[_0x45bf86];return _0x1f02b7;};'use strict';var _=require(_0x7600('0x0'));var util=require(_0x7600('0x1'));var moment=require('moment');var BPromise=require(_0x7600('0x2'));var rs=require(_0x7600('0x3'));var fs=require('fs');var Redis=require(_0x7600('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x7600('0x5'));var logger=require(_0x7600('0x6'))(_0x7600('0x7'));var config=require(_0x7600('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x7600('0x9')]['http']({'port':0x232a});config['redis']=_[_0x7600('0xa')](config[_0x7600('0xb')],{'host':_0x7600('0xc'),'port':0x18eb});var socket=require(_0x7600('0xd'))(new Redis(config[_0x7600('0xb')]));require(_0x7600('0xe'))[_0x7600('0xf')](socket);function respondWithRpcPromise(_0x30e407,_0x269021,_0x16ad27){return new BPromise(function(_0x2fe754,_0x30dc46){return client[_0x7600('0x10')](_0x30e407,_0x16ad27)[_0x7600('0x11')](function(_0x393b0f){logger[_0x7600('0x12')](_0x7600('0x13'),_0x269021,_0x7600('0x14'));logger[_0x7600('0x15')]('VoiceQueue,\x20%s,\x20%s,\x20%s',_0x269021,'request\x20sent',JSON['stringify'](_0x393b0f));if(_0x393b0f[_0x7600('0x16')]){if(_0x393b0f['error'][_0x7600('0x17')]===0x1f4){logger[_0x7600('0x16')](_0x7600('0x13'),_0x269021,_0x393b0f[_0x7600('0x16')][_0x7600('0x18')]);return _0x30dc46(_0x393b0f['error'][_0x7600('0x18')]);}logger[_0x7600('0x16')]('VoiceQueue,\x20%s,\x20%s',_0x269021,_0x393b0f[_0x7600('0x16')][_0x7600('0x18')]);return _0x2fe754(_0x393b0f[_0x7600('0x16')]['message']);}else{logger['info']('VoiceQueue,\x20%s,\x20%s',_0x269021,_0x7600('0x14'));_0x2fe754(_0x393b0f[_0x7600('0x19')][_0x7600('0x18')]);}})[_0x7600('0x1a')](function(_0x149a99){logger[_0x7600('0x16')](_0x7600('0x13'),_0x269021,_0x149a99);_0x30dc46(_0x149a99);});});}exports[_0x7600('0x1b')]=function(_0x5533d3){var _0x147895=this;return new Promise(function(_0x83121b,_0x55a828){return db[_0x7600('0x1c')][_0x7600('0x1d')]({'raw':_0x5533d3[_0x7600('0x1e')]?_0x5533d3[_0x7600('0x1e')][_0x7600('0x1f')]===undefined?!![]:![]:!![],'where':_0x5533d3[_0x7600('0x1e')]?_0x5533d3[_0x7600('0x1e')][_0x7600('0x20')]||null:null,'attributes':_0x5533d3[_0x7600('0x1e')]?_0x5533d3[_0x7600('0x1e')][_0x7600('0x21')]||null:null,'limit':_0x5533d3[_0x7600('0x1e')]?_0x5533d3[_0x7600('0x1e')][_0x7600('0x22')]||null:null,'include':_0x5533d3[_0x7600('0x1e')]?_0x5533d3['options'][_0x7600('0x23')]?_[_0x7600('0x24')](_0x5533d3['options'][_0x7600('0x23')],function(_0x563cbf){return{'model':db[_0x563cbf[_0x7600('0x25')]],'as':_0x563cbf['as'],'attributes':_0x563cbf[_0x7600('0x21')],'include':_0x563cbf[_0x7600('0x23')]?_[_0x7600('0x24')](_0x563cbf[_0x7600('0x23')],function(_0x344755){return{'model':db[_0x344755[_0x7600('0x25')]],'as':_0x344755['as'],'attributes':_0x344755[_0x7600('0x21')],'include':_0x344755['include']?_['map'](_0x344755[_0x7600('0x23')],function(_0xdbc7fa){return{'model':db[_0xdbc7fa['model']],'as':_0xdbc7fa['as'],'attributes':_0xdbc7fa['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x583231){logger[_0x7600('0x12')](_0x7600('0x1b'),_0x5533d3);logger[_0x7600('0x15')]('GetVoiceQueue',_0x5533d3,JSON['stringify'](_0x583231));_0x83121b(_0x583231);})[_0x7600('0x1a')](function(_0x1369ad){logger[_0x7600('0x16')](_0x7600('0x1b'),_0x1369ad[_0x7600('0x18')],_0x5533d3);_0x55a828(_0x147895[_0x7600('0x16')](0x1f4,_0x1369ad['message']));});});};exports[_0x7600('0x26')]=function(_0x1f4ba7){var _0x523957=this;return new Promise(function(_0x2f5261,_0x10ad9f){return db[_0x7600('0x1c')][_0x7600('0x27')]({'raw':_0x1f4ba7['options']?_0x1f4ba7[_0x7600('0x1e')][_0x7600('0x1f')]===undefined?!![]:![]:!![],'where':_0x1f4ba7[_0x7600('0x1e')]?_0x1f4ba7[_0x7600('0x1e')]['where']||null:null,'attributes':_0x1f4ba7[_0x7600('0x1e')]?_0x1f4ba7[_0x7600('0x1e')][_0x7600('0x21')]||null:null,'include':_0x1f4ba7[_0x7600('0x1e')]?_0x1f4ba7[_0x7600('0x1e')]['include']?_[_0x7600('0x24')](_0x1f4ba7[_0x7600('0x1e')]['include'],function(_0x2dc082){return{'model':db[_0x2dc082[_0x7600('0x25')]],'as':_0x2dc082['as'],'attributes':_0x2dc082['attributes'],'include':_0x2dc082[_0x7600('0x23')]?_[_0x7600('0x24')](_0x2dc082[_0x7600('0x23')],function(_0x1de9d0){return{'model':db[_0x1de9d0[_0x7600('0x25')]],'as':_0x1de9d0['as'],'attributes':_0x1de9d0[_0x7600('0x21')],'include':_0x1de9d0[_0x7600('0x23')]?_[_0x7600('0x24')](_0x1de9d0[_0x7600('0x23')],function(_0x56c625){return{'model':db[_0x56c625[_0x7600('0x25')]],'as':_0x56c625['as'],'attributes':_0x56c625[_0x7600('0x21')]};}):[]};}):[]};}):[]:[]})[_0x7600('0x11')](function(_0x26a60c){logger[_0x7600('0x12')](_0x7600('0x26'),_0x1f4ba7);logger[_0x7600('0x15')](_0x7600('0x26'),_0x1f4ba7,JSON[_0x7600('0x28')](_0x26a60c));_0x2f5261(_0x26a60c);})[_0x7600('0x1a')](function(_0x54bb3b){logger[_0x7600('0x16')](_0x7600('0x26'),_0x54bb3b[_0x7600('0x18')],_0x1f4ba7);_0x10ad9f(_0x523957[_0x7600('0x16')](0x1f4,_0x54bb3b[_0x7600('0x18')]));});});};