65ccdf1fac68644dad05677380cf0da096818967
[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 _0xe12a=['options','raw','where','attributes','limit','include','map','model','find','ShowVoiceQueue','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','client','http','redis','defaults','./voiceQueue.socket','request','then','info','request\x20sent','debug','stringify','error','code','VoiceQueue,\x20%s,\x20%s','message','result','catch','GetVoiceQueue','VoiceQueue','findAll'];(function(_0x1682e1,_0x498495){var _0x40f9a7=function(_0x5330bc){while(--_0x5330bc){_0x1682e1['push'](_0x1682e1['shift']());}};_0x40f9a7(++_0x498495);}(_0xe12a,0x1d2));var _0xae12=function(_0xf2a881,_0xea5c08){_0xf2a881=_0xf2a881-0x0;var _0x29279e=_0xe12a[_0xf2a881];return _0x29279e;};'use strict';var _=require('lodash');var util=require(_0xae12('0x0'));var moment=require(_0xae12('0x1'));var BPromise=require(_0xae12('0x2'));var rs=require(_0xae12('0x3'));var fs=require('fs');var Redis=require(_0xae12('0x4'));var db=require(_0xae12('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xae12('0x6'));var config=require(_0xae12('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xae12('0x8')][_0xae12('0x9')]({'port':0x232a});config[_0xae12('0xa')]=_[_0xae12('0xb')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xae12('0xc'))['register'](socket);function respondWithRpcPromise(_0x46f24b,_0x20a503,_0x4091b6){return new BPromise(function(_0x59199f,_0x1aeb64){return client[_0xae12('0xd')](_0x46f24b,_0x4091b6)[_0xae12('0xe')](function(_0x2e8fab){logger[_0xae12('0xf')]('VoiceQueue,\x20%s,\x20%s',_0x20a503,_0xae12('0x10'));logger[_0xae12('0x11')]('VoiceQueue,\x20%s,\x20%s,\x20%s',_0x20a503,'request\x20sent',JSON[_0xae12('0x12')](_0x2e8fab));if(_0x2e8fab[_0xae12('0x13')]){if(_0x2e8fab[_0xae12('0x13')][_0xae12('0x14')]===0x1f4){logger[_0xae12('0x13')](_0xae12('0x15'),_0x20a503,_0x2e8fab[_0xae12('0x13')][_0xae12('0x16')]);return _0x1aeb64(_0x2e8fab[_0xae12('0x13')][_0xae12('0x16')]);}logger[_0xae12('0x13')](_0xae12('0x15'),_0x20a503,_0x2e8fab['error'][_0xae12('0x16')]);return _0x59199f(_0x2e8fab[_0xae12('0x13')][_0xae12('0x16')]);}else{logger[_0xae12('0xf')](_0xae12('0x15'),_0x20a503,_0xae12('0x10'));_0x59199f(_0x2e8fab[_0xae12('0x17')][_0xae12('0x16')]);}})[_0xae12('0x18')](function(_0x1eae4e){logger[_0xae12('0x13')]('VoiceQueue,\x20%s,\x20%s',_0x20a503,_0x1eae4e);_0x1aeb64(_0x1eae4e);});});}exports[_0xae12('0x19')]=function(_0xbd689c){var _0x29e7e4=this;return new Promise(function(_0x4fcf9d,_0x149f69){return db[_0xae12('0x1a')][_0xae12('0x1b')]({'raw':_0xbd689c[_0xae12('0x1c')]?_0xbd689c['options'][_0xae12('0x1d')]===undefined?!![]:![]:!![],'where':_0xbd689c['options']?_0xbd689c[_0xae12('0x1c')][_0xae12('0x1e')]||null:null,'attributes':_0xbd689c[_0xae12('0x1c')]?_0xbd689c[_0xae12('0x1c')][_0xae12('0x1f')]||null:null,'limit':_0xbd689c[_0xae12('0x1c')]?_0xbd689c[_0xae12('0x1c')][_0xae12('0x20')]||null:null,'include':_0xbd689c[_0xae12('0x1c')]?_0xbd689c[_0xae12('0x1c')][_0xae12('0x21')]?_[_0xae12('0x22')](_0xbd689c['options'][_0xae12('0x21')],function(_0x2a8645){return{'model':db[_0x2a8645[_0xae12('0x23')]],'as':_0x2a8645['as'],'attributes':_0x2a8645['attributes'],'include':_0x2a8645[_0xae12('0x21')]?_[_0xae12('0x22')](_0x2a8645[_0xae12('0x21')],function(_0x29c218){return{'model':db[_0x29c218[_0xae12('0x23')]],'as':_0x29c218['as'],'attributes':_0x29c218[_0xae12('0x1f')],'include':_0x29c218['include']?_[_0xae12('0x22')](_0x29c218[_0xae12('0x21')],function(_0x15c069){return{'model':db[_0x15c069[_0xae12('0x23')]],'as':_0x15c069['as'],'attributes':_0x15c069[_0xae12('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5b34ce){logger[_0xae12('0xf')](_0xae12('0x19'),_0xbd689c);logger[_0xae12('0x11')]('GetVoiceQueue',_0xbd689c,JSON[_0xae12('0x12')](_0x5b34ce));_0x4fcf9d(_0x5b34ce);})[_0xae12('0x18')](function(_0x46bdca){logger[_0xae12('0x13')](_0xae12('0x19'),_0x46bdca[_0xae12('0x16')],_0xbd689c);_0x149f69(_0x29e7e4['error'](0x1f4,_0x46bdca['message']));});});};exports['ShowVoiceQueue']=function(_0x5889fd){var _0x1e377c=this;return new Promise(function(_0x168aa0,_0x9a412a){return db['VoiceQueue'][_0xae12('0x24')]({'raw':_0x5889fd[_0xae12('0x1c')]?_0x5889fd[_0xae12('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x5889fd[_0xae12('0x1c')]?_0x5889fd[_0xae12('0x1c')]['where']||null:null,'attributes':_0x5889fd[_0xae12('0x1c')]?_0x5889fd[_0xae12('0x1c')][_0xae12('0x1f')]||null:null,'include':_0x5889fd[_0xae12('0x1c')]?_0x5889fd[_0xae12('0x1c')][_0xae12('0x21')]?_['map'](_0x5889fd[_0xae12('0x1c')]['include'],function(_0x14d3ba){return{'model':db[_0x14d3ba[_0xae12('0x23')]],'as':_0x14d3ba['as'],'attributes':_0x14d3ba[_0xae12('0x1f')],'include':_0x14d3ba['include']?_[_0xae12('0x22')](_0x14d3ba[_0xae12('0x21')],function(_0x2388a6){return{'model':db[_0x2388a6[_0xae12('0x23')]],'as':_0x2388a6['as'],'attributes':_0x2388a6['attributes'],'include':_0x2388a6[_0xae12('0x21')]?_[_0xae12('0x22')](_0x2388a6['include'],function(_0x32f60a){return{'model':db[_0x32f60a['model']],'as':_0x32f60a['as'],'attributes':_0x32f60a[_0xae12('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xae12('0xe')](function(_0xa1222f){logger[_0xae12('0xf')]('ShowVoiceQueue',_0x5889fd);logger[_0xae12('0x11')](_0xae12('0x25'),_0x5889fd,JSON[_0xae12('0x12')](_0xa1222f));_0x168aa0(_0xa1222f);})['catch'](function(_0x33a577){logger['error'](_0xae12('0x25'),_0x33a577[_0xae12('0x16')],_0x5889fd);_0x9a412a(_0x1e377c[_0xae12('0x13')](0x1f4,_0x33a577[_0xae12('0x16')]));});});};