b8488e09bcb5e2292b350e53613f01872e724633
[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 _0xcf0b=['attributes','limit','map','include','model','GetVoiceQueue','stringify','ShowVoiceQueue','find','lodash','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./voiceQueue.socket','register','request','then','info','VoiceQueue,\x20%s,\x20%s','request\x20sent','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','error','code','message','catch','VoiceQueue','findAll','options','where'];(function(_0x178e48,_0x3c9509){var _0x440d7e=function(_0xc2f8a0){while(--_0xc2f8a0){_0x178e48['push'](_0x178e48['shift']());}};_0x440d7e(++_0x3c9509);}(_0xcf0b,0x128));var _0xbcf0=function(_0x448ae2,_0x1676f5){_0x448ae2=_0x448ae2-0x0;var _0x4fdd34=_0xcf0b[_0x448ae2];return _0x4fdd34;};'use strict';var _=require(_0xbcf0('0x0'));var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xbcf0('0x1'));var fs=require('fs');var Redis=require(_0xbcf0('0x2'));var db=require(_0xbcf0('0x3'))['db'];var utils=require(_0xbcf0('0x4'));var logger=require(_0xbcf0('0x5'))(_0xbcf0('0x6'));var config=require(_0xbcf0('0x7'));var jayson=require(_0xbcf0('0x8'));var client=jayson[_0xbcf0('0x9')][_0xbcf0('0xa')]({'port':0x232a});config[_0xbcf0('0xb')]=_[_0xbcf0('0xc')](config['redis'],{'host':_0xbcf0('0xd'),'port':0x18eb});var socket=require(_0xbcf0('0xe'))(new Redis(config['redis']));require(_0xbcf0('0xf'))[_0xbcf0('0x10')](socket);function respondWithRpcPromise(_0x5af75f,_0x58ca8a,_0x563be5){return new BPromise(function(_0x3cc6f0,_0x2cbf11){return client[_0xbcf0('0x11')](_0x5af75f,_0x563be5)[_0xbcf0('0x12')](function(_0x507551){logger[_0xbcf0('0x13')](_0xbcf0('0x14'),_0x58ca8a,_0xbcf0('0x15'));logger[_0xbcf0('0x16')](_0xbcf0('0x17'),_0x58ca8a,_0xbcf0('0x15'),JSON['stringify'](_0x507551));if(_0x507551[_0xbcf0('0x18')]){if(_0x507551[_0xbcf0('0x18')][_0xbcf0('0x19')]===0x1f4){logger[_0xbcf0('0x18')]('VoiceQueue,\x20%s,\x20%s',_0x58ca8a,_0x507551[_0xbcf0('0x18')][_0xbcf0('0x1a')]);return _0x2cbf11(_0x507551[_0xbcf0('0x18')][_0xbcf0('0x1a')]);}logger[_0xbcf0('0x18')](_0xbcf0('0x14'),_0x58ca8a,_0x507551['error'][_0xbcf0('0x1a')]);return _0x3cc6f0(_0x507551[_0xbcf0('0x18')][_0xbcf0('0x1a')]);}else{logger[_0xbcf0('0x13')](_0xbcf0('0x14'),_0x58ca8a,'request\x20sent');_0x3cc6f0(_0x507551['result'][_0xbcf0('0x1a')]);}})[_0xbcf0('0x1b')](function(_0x565e21){logger['error'](_0xbcf0('0x14'),_0x58ca8a,_0x565e21);_0x2cbf11(_0x565e21);});});}exports['GetVoiceQueue']=function(_0x19f4e3){var _0x642214=this;return new Promise(function(_0x487bd7,_0x5905e8){return db[_0xbcf0('0x1c')][_0xbcf0('0x1d')]({'raw':_0x19f4e3['options']?_0x19f4e3[_0xbcf0('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x19f4e3[_0xbcf0('0x1e')]?_0x19f4e3[_0xbcf0('0x1e')][_0xbcf0('0x1f')]||null:null,'attributes':_0x19f4e3[_0xbcf0('0x1e')]?_0x19f4e3[_0xbcf0('0x1e')][_0xbcf0('0x20')]||null:null,'limit':_0x19f4e3['options']?_0x19f4e3[_0xbcf0('0x1e')][_0xbcf0('0x21')]||null:null,'include':_0x19f4e3['options']?_0x19f4e3[_0xbcf0('0x1e')]['include']?_[_0xbcf0('0x22')](_0x19f4e3[_0xbcf0('0x1e')][_0xbcf0('0x23')],function(_0x305382){return{'model':db[_0x305382[_0xbcf0('0x24')]],'as':_0x305382['as'],'attributes':_0x305382[_0xbcf0('0x20')],'include':_0x305382[_0xbcf0('0x23')]?_[_0xbcf0('0x22')](_0x305382[_0xbcf0('0x23')],function(_0x35653c){return{'model':db[_0x35653c[_0xbcf0('0x24')]],'as':_0x35653c['as'],'attributes':_0x35653c[_0xbcf0('0x20')],'include':_0x35653c[_0xbcf0('0x23')]?_[_0xbcf0('0x22')](_0x35653c[_0xbcf0('0x23')],function(_0x2192db){return{'model':db[_0x2192db['model']],'as':_0x2192db['as'],'attributes':_0x2192db[_0xbcf0('0x20')]};}):[]};}):[]};}):[]:[]})[_0xbcf0('0x12')](function(_0xd698c7){logger[_0xbcf0('0x13')](_0xbcf0('0x25'),_0x19f4e3);logger[_0xbcf0('0x16')]('GetVoiceQueue',_0x19f4e3,JSON[_0xbcf0('0x26')](_0xd698c7));_0x487bd7(_0xd698c7);})['catch'](function(_0x563e6c){logger[_0xbcf0('0x18')]('GetVoiceQueue',_0x563e6c[_0xbcf0('0x1a')],_0x19f4e3);_0x5905e8(_0x642214[_0xbcf0('0x18')](0x1f4,_0x563e6c[_0xbcf0('0x1a')]));});});};exports[_0xbcf0('0x27')]=function(_0x5499b6){var _0x33713f=this;return new Promise(function(_0x489f14,_0x2fdfa7){return db[_0xbcf0('0x1c')][_0xbcf0('0x28')]({'raw':_0x5499b6[_0xbcf0('0x1e')]?_0x5499b6[_0xbcf0('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x5499b6[_0xbcf0('0x1e')]?_0x5499b6[_0xbcf0('0x1e')][_0xbcf0('0x1f')]||null:null,'attributes':_0x5499b6[_0xbcf0('0x1e')]?_0x5499b6[_0xbcf0('0x1e')][_0xbcf0('0x20')]||null:null,'include':_0x5499b6[_0xbcf0('0x1e')]?_0x5499b6['options'][_0xbcf0('0x23')]?_['map'](_0x5499b6[_0xbcf0('0x1e')][_0xbcf0('0x23')],function(_0x185ed5){return{'model':db[_0x185ed5['model']],'as':_0x185ed5['as'],'attributes':_0x185ed5[_0xbcf0('0x20')],'include':_0x185ed5[_0xbcf0('0x23')]?_[_0xbcf0('0x22')](_0x185ed5[_0xbcf0('0x23')],function(_0x2a7ed8){return{'model':db[_0x2a7ed8[_0xbcf0('0x24')]],'as':_0x2a7ed8['as'],'attributes':_0x2a7ed8['attributes'],'include':_0x2a7ed8[_0xbcf0('0x23')]?_[_0xbcf0('0x22')](_0x2a7ed8[_0xbcf0('0x23')],function(_0x2a11c3){return{'model':db[_0x2a11c3[_0xbcf0('0x24')]],'as':_0x2a11c3['as'],'attributes':_0x2a11c3[_0xbcf0('0x20')]};}):[]};}):[]};}):[]:[]})[_0xbcf0('0x12')](function(_0x5e7ee4){logger[_0xbcf0('0x13')]('ShowVoiceQueue',_0x5499b6);logger[_0xbcf0('0x16')](_0xbcf0('0x27'),_0x5499b6,JSON[_0xbcf0('0x26')](_0x5e7ee4));_0x489f14(_0x5e7ee4);})[_0xbcf0('0x1b')](function(_0x192e30){logger[_0xbcf0('0x18')](_0xbcf0('0x27'),_0x192e30['message'],_0x5499b6);_0x2fdfa7(_0x33713f[_0xbcf0('0x18')](0x1f4,_0x192e30['message']));});});};