Built motion from commit d5e4af8c.|2.6.23
[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 _0xbe6a=['util','moment','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','redis','defaults','localhost','socket.io-emitter','./voiceQueue.socket','register','request','then','info','VoiceQueue,\x20%s,\x20%s','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','message','request\x20sent','result','catch','GetVoiceQueue','findAll','options','raw','where','limit','include','attributes','map','model','VoiceQueue','find','ShowVoiceQueue'];(function(_0x52e06f,_0xef68a0){var _0x416550=function(_0x4f654c){while(--_0x4f654c){_0x52e06f['push'](_0x52e06f['shift']());}};_0x416550(++_0xef68a0);}(_0xbe6a,0x78));var _0xabe6=function(_0x20845e,_0x211e78){_0x20845e=_0x20845e-0x0;var _0x28cf2b=_0xbe6a[_0x20845e];return _0x28cf2b;};'use strict';var _=require('lodash');var util=require(_0xabe6('0x0'));var moment=require(_0xabe6('0x1'));var BPromise=require('bluebird');var rs=require(_0xabe6('0x2'));var fs=require('fs');var Redis=require(_0xabe6('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0xabe6('0x4'));var logger=require(_0xabe6('0x5'))(_0xabe6('0x6'));var config=require(_0xabe6('0x7'));var jayson=require(_0xabe6('0x8'));var client=jayson['client']['http']({'port':0x232a});config[_0xabe6('0x9')]=_[_0xabe6('0xa')](config['redis'],{'host':_0xabe6('0xb'),'port':0x18eb});var socket=require(_0xabe6('0xc'))(new Redis(config[_0xabe6('0x9')]));require(_0xabe6('0xd'))[_0xabe6('0xe')](socket);function respondWithRpcPromise(_0x1b6bc5,_0xa6065c,_0x572ad2){return new BPromise(function(_0x16a9ff,_0x28eaed){return client[_0xabe6('0xf')](_0x1b6bc5,_0x572ad2)[_0xabe6('0x10')](function(_0x53224a){logger[_0xabe6('0x11')](_0xabe6('0x12'),_0xa6065c,'request\x20sent');logger[_0xabe6('0x13')](_0xabe6('0x14'),_0xa6065c,'request\x20sent',JSON[_0xabe6('0x15')](_0x53224a));if(_0x53224a['error']){if(_0x53224a['error']['code']===0x1f4){logger[_0xabe6('0x16')](_0xabe6('0x12'),_0xa6065c,_0x53224a['error']['message']);return _0x28eaed(_0x53224a['error'][_0xabe6('0x17')]);}logger[_0xabe6('0x16')]('VoiceQueue,\x20%s,\x20%s',_0xa6065c,_0x53224a[_0xabe6('0x16')][_0xabe6('0x17')]);return _0x16a9ff(_0x53224a[_0xabe6('0x16')][_0xabe6('0x17')]);}else{logger[_0xabe6('0x11')](_0xabe6('0x12'),_0xa6065c,_0xabe6('0x18'));_0x16a9ff(_0x53224a[_0xabe6('0x19')][_0xabe6('0x17')]);}})[_0xabe6('0x1a')](function(_0x5bb47c){logger[_0xabe6('0x16')]('VoiceQueue,\x20%s,\x20%s',_0xa6065c,_0x5bb47c);_0x28eaed(_0x5bb47c);});});}exports[_0xabe6('0x1b')]=function(_0x42f0b7){var _0x35e560=this;return new Promise(function(_0x92a95e,_0x3c61b2){return db['VoiceQueue'][_0xabe6('0x1c')]({'raw':_0x42f0b7['options']?_0x42f0b7[_0xabe6('0x1d')][_0xabe6('0x1e')]===undefined?!![]:![]:!![],'where':_0x42f0b7[_0xabe6('0x1d')]?_0x42f0b7[_0xabe6('0x1d')][_0xabe6('0x1f')]||null:null,'attributes':_0x42f0b7[_0xabe6('0x1d')]?_0x42f0b7[_0xabe6('0x1d')]['attributes']||null:null,'limit':_0x42f0b7[_0xabe6('0x1d')]?_0x42f0b7['options'][_0xabe6('0x20')]||null:null,'include':_0x42f0b7[_0xabe6('0x1d')]?_0x42f0b7[_0xabe6('0x1d')]['include']?_['map'](_0x42f0b7[_0xabe6('0x1d')][_0xabe6('0x21')],function(_0x38f901){return{'model':db[_0x38f901['model']],'as':_0x38f901['as'],'attributes':_0x38f901[_0xabe6('0x22')],'include':_0x38f901[_0xabe6('0x21')]?_[_0xabe6('0x23')](_0x38f901[_0xabe6('0x21')],function(_0x5b56ba){return{'model':db[_0x5b56ba[_0xabe6('0x24')]],'as':_0x5b56ba['as'],'attributes':_0x5b56ba['attributes'],'include':_0x5b56ba[_0xabe6('0x21')]?_['map'](_0x5b56ba['include'],function(_0x24f7d1){return{'model':db[_0x24f7d1[_0xabe6('0x24')]],'as':_0x24f7d1['as'],'attributes':_0x24f7d1['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x727491){logger[_0xabe6('0x11')](_0xabe6('0x1b'),_0x42f0b7);logger[_0xabe6('0x13')](_0xabe6('0x1b'),_0x42f0b7,JSON[_0xabe6('0x15')](_0x727491));_0x92a95e(_0x727491);})[_0xabe6('0x1a')](function(_0x14ac0b){logger[_0xabe6('0x16')](_0xabe6('0x1b'),_0x14ac0b[_0xabe6('0x17')],_0x42f0b7);_0x3c61b2(_0x35e560[_0xabe6('0x16')](0x1f4,_0x14ac0b[_0xabe6('0x17')]));});});};exports['ShowVoiceQueue']=function(_0x923b7b){var _0x22e8e5=this;return new Promise(function(_0x1e0d81,_0xf4f283){return db[_0xabe6('0x25')][_0xabe6('0x26')]({'raw':_0x923b7b['options']?_0x923b7b[_0xabe6('0x1d')][_0xabe6('0x1e')]===undefined?!![]:![]:!![],'where':_0x923b7b[_0xabe6('0x1d')]?_0x923b7b['options'][_0xabe6('0x1f')]||null:null,'attributes':_0x923b7b[_0xabe6('0x1d')]?_0x923b7b['options'][_0xabe6('0x22')]||null:null,'include':_0x923b7b[_0xabe6('0x1d')]?_0x923b7b[_0xabe6('0x1d')][_0xabe6('0x21')]?_[_0xabe6('0x23')](_0x923b7b[_0xabe6('0x1d')]['include'],function(_0x6a49ee){return{'model':db[_0x6a49ee[_0xabe6('0x24')]],'as':_0x6a49ee['as'],'attributes':_0x6a49ee[_0xabe6('0x22')],'include':_0x6a49ee[_0xabe6('0x21')]?_[_0xabe6('0x23')](_0x6a49ee['include'],function(_0x39e20b){return{'model':db[_0x39e20b[_0xabe6('0x24')]],'as':_0x39e20b['as'],'attributes':_0x39e20b['attributes'],'include':_0x39e20b[_0xabe6('0x21')]?_[_0xabe6('0x23')](_0x39e20b[_0xabe6('0x21')],function(_0x591810){return{'model':db[_0x591810[_0xabe6('0x24')]],'as':_0x591810['as'],'attributes':_0x591810[_0xabe6('0x22')]};}):[]};}):[]};}):[]:[]})[_0xabe6('0x10')](function(_0x3b654b){logger['info'](_0xabe6('0x27'),_0x923b7b);logger['debug']('ShowVoiceQueue',_0x923b7b,JSON[_0xabe6('0x15')](_0x3b654b));_0x1e0d81(_0x3b654b);})[_0xabe6('0x1a')](function(_0x48a9ba){logger[_0xabe6('0x16')]('ShowVoiceQueue',_0x48a9ba[_0xabe6('0x17')],_0x923b7b);_0xf4f283(_0x22e8e5[_0xabe6('0x16')](0x1f4,_0x48a9ba['message']));});});};