Built motion from commit d6d69adf.|2.6.33
[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 _0x3b3b=['./voiceQueue.socket','register','request','info','VoiceQueue,\x20%s,\x20%s','request\x20sent','VoiceQueue,\x20%s,\x20%s,\x20%s','error','code','message','result','GetVoiceQueue','VoiceQueue','options','raw','where','limit','include','map','model','attributes','then','debug','catch','ShowVoiceQueue','find','lodash','util','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter'];(function(_0x31d794,_0x160894){var _0x325661=function(_0x456ed2){while(--_0x456ed2){_0x31d794['push'](_0x31d794['shift']());}};_0x325661(++_0x160894);}(_0x3b3b,0x162));var _0xb3b3=function(_0x26306f,_0xce1ef9){_0x26306f=_0x26306f-0x0;var _0x21cae4=_0x3b3b[_0x26306f];return _0x21cae4;};'use strict';var _=require(_0xb3b3('0x0'));var util=require(_0xb3b3('0x1'));var moment=require('moment');var BPromise=require(_0xb3b3('0x2'));var rs=require(_0xb3b3('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xb3b3('0x4'))['db'];var utils=require(_0xb3b3('0x5'));var logger=require('../../config/logger')(_0xb3b3('0x6'));var config=require(_0xb3b3('0x7'));var jayson=require(_0xb3b3('0x8'));var client=jayson[_0xb3b3('0x9')][_0xb3b3('0xa')]({'port':0x232a});config[_0xb3b3('0xb')]=_[_0xb3b3('0xc')](config['redis'],{'host':_0xb3b3('0xd'),'port':0x18eb});var socket=require(_0xb3b3('0xe'))(new Redis(config['redis']));require(_0xb3b3('0xf'))[_0xb3b3('0x10')](socket);function respondWithRpcPromise(_0x39d4f4,_0x11c94a,_0x467b2e){return new BPromise(function(_0x4fcce4,_0x2d768e){return client[_0xb3b3('0x11')](_0x39d4f4,_0x467b2e)['then'](function(_0x11efb6){logger[_0xb3b3('0x12')](_0xb3b3('0x13'),_0x11c94a,_0xb3b3('0x14'));logger['debug'](_0xb3b3('0x15'),_0x11c94a,'request\x20sent',JSON['stringify'](_0x11efb6));if(_0x11efb6['error']){if(_0x11efb6[_0xb3b3('0x16')][_0xb3b3('0x17')]===0x1f4){logger[_0xb3b3('0x16')]('VoiceQueue,\x20%s,\x20%s',_0x11c94a,_0x11efb6[_0xb3b3('0x16')][_0xb3b3('0x18')]);return _0x2d768e(_0x11efb6[_0xb3b3('0x16')]['message']);}logger['error'](_0xb3b3('0x13'),_0x11c94a,_0x11efb6[_0xb3b3('0x16')][_0xb3b3('0x18')]);return _0x4fcce4(_0x11efb6['error'][_0xb3b3('0x18')]);}else{logger[_0xb3b3('0x12')](_0xb3b3('0x13'),_0x11c94a,_0xb3b3('0x14'));_0x4fcce4(_0x11efb6[_0xb3b3('0x19')][_0xb3b3('0x18')]);}})['catch'](function(_0x406675){logger[_0xb3b3('0x16')](_0xb3b3('0x13'),_0x11c94a,_0x406675);_0x2d768e(_0x406675);});});}exports[_0xb3b3('0x1a')]=function(_0xc5a16e){var _0x5afc9d=this;return new Promise(function(_0x300362,_0x2c83fc){return db[_0xb3b3('0x1b')]['findAll']({'raw':_0xc5a16e[_0xb3b3('0x1c')]?_0xc5a16e[_0xb3b3('0x1c')][_0xb3b3('0x1d')]===undefined?!![]:![]:!![],'where':_0xc5a16e[_0xb3b3('0x1c')]?_0xc5a16e[_0xb3b3('0x1c')][_0xb3b3('0x1e')]||null:null,'attributes':_0xc5a16e[_0xb3b3('0x1c')]?_0xc5a16e[_0xb3b3('0x1c')]['attributes']||null:null,'limit':_0xc5a16e[_0xb3b3('0x1c')]?_0xc5a16e[_0xb3b3('0x1c')][_0xb3b3('0x1f')]||null:null,'include':_0xc5a16e[_0xb3b3('0x1c')]?_0xc5a16e[_0xb3b3('0x1c')][_0xb3b3('0x20')]?_[_0xb3b3('0x21')](_0xc5a16e['options']['include'],function(_0x48729e){return{'model':db[_0x48729e[_0xb3b3('0x22')]],'as':_0x48729e['as'],'attributes':_0x48729e[_0xb3b3('0x23')],'include':_0x48729e[_0xb3b3('0x20')]?_['map'](_0x48729e[_0xb3b3('0x20')],function(_0x1f244a){return{'model':db[_0x1f244a[_0xb3b3('0x22')]],'as':_0x1f244a['as'],'attributes':_0x1f244a['attributes'],'include':_0x1f244a[_0xb3b3('0x20')]?_[_0xb3b3('0x21')](_0x1f244a[_0xb3b3('0x20')],function(_0x5a440a){return{'model':db[_0x5a440a[_0xb3b3('0x22')]],'as':_0x5a440a['as'],'attributes':_0x5a440a[_0xb3b3('0x23')]};}):[]};}):[]};}):[]:[]})[_0xb3b3('0x24')](function(_0x18120d){logger[_0xb3b3('0x12')](_0xb3b3('0x1a'),_0xc5a16e);logger[_0xb3b3('0x25')](_0xb3b3('0x1a'),_0xc5a16e,JSON['stringify'](_0x18120d));_0x300362(_0x18120d);})[_0xb3b3('0x26')](function(_0x5e6676){logger['error'](_0xb3b3('0x1a'),_0x5e6676[_0xb3b3('0x18')],_0xc5a16e);_0x2c83fc(_0x5afc9d[_0xb3b3('0x16')](0x1f4,_0x5e6676[_0xb3b3('0x18')]));});});};exports[_0xb3b3('0x27')]=function(_0x2412f1){var _0x2e9759=this;return new Promise(function(_0x265f0a,_0x112632){return db[_0xb3b3('0x1b')][_0xb3b3('0x28')]({'raw':_0x2412f1['options']?_0x2412f1[_0xb3b3('0x1c')][_0xb3b3('0x1d')]===undefined?!![]:![]:!![],'where':_0x2412f1[_0xb3b3('0x1c')]?_0x2412f1[_0xb3b3('0x1c')][_0xb3b3('0x1e')]||null:null,'attributes':_0x2412f1[_0xb3b3('0x1c')]?_0x2412f1[_0xb3b3('0x1c')]['attributes']||null:null,'include':_0x2412f1[_0xb3b3('0x1c')]?_0x2412f1[_0xb3b3('0x1c')]['include']?_[_0xb3b3('0x21')](_0x2412f1['options'][_0xb3b3('0x20')],function(_0x3740e7){return{'model':db[_0x3740e7[_0xb3b3('0x22')]],'as':_0x3740e7['as'],'attributes':_0x3740e7[_0xb3b3('0x23')],'include':_0x3740e7['include']?_['map'](_0x3740e7[_0xb3b3('0x20')],function(_0x595ca5){return{'model':db[_0x595ca5[_0xb3b3('0x22')]],'as':_0x595ca5['as'],'attributes':_0x595ca5[_0xb3b3('0x23')],'include':_0x595ca5[_0xb3b3('0x20')]?_[_0xb3b3('0x21')](_0x595ca5[_0xb3b3('0x20')],function(_0x3b7cde){return{'model':db[_0x3b7cde[_0xb3b3('0x22')]],'as':_0x3b7cde['as'],'attributes':_0x3b7cde[_0xb3b3('0x23')]};}):[]};}):[]};}):[]:[]})[_0xb3b3('0x24')](function(_0x3cba94){logger[_0xb3b3('0x12')](_0xb3b3('0x27'),_0x2412f1);logger['debug'](_0xb3b3('0x27'),_0x2412f1,JSON['stringify'](_0x3cba94));_0x265f0a(_0x3cba94);})['catch'](function(_0x9eb66a){logger[_0xb3b3('0x16')](_0xb3b3('0x27'),_0x9eb66a[_0xb3b3('0x18')],_0x2412f1);_0x112632(_0x2e9759['error'](0x1f4,_0x9eb66a[_0xb3b3('0x18')]));});});};