Built motion from commit d1eab355.|2.6.28
[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 _0x41f3=['raw','where','attributes','limit','map','include','model','then','ShowVoiceQueue','find','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','defaults','redis','localhost','./voiceQueue.socket','register','info','VoiceQueue,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','catch','GetVoiceQueue','VoiceQueue','findAll','options'];(function(_0x4d61ca,_0x2153c9){var _0xa1e14a=function(_0x4b2ca0){while(--_0x4b2ca0){_0x4d61ca['push'](_0x4d61ca['shift']());}};_0xa1e14a(++_0x2153c9);}(_0x41f3,0x11b));var _0x341f=function(_0x4f4c51,_0x3b2bc9){_0x4f4c51=_0x4f4c51-0x0;var _0x145dc3=_0x41f3[_0x4f4c51];return _0x145dc3;};'use strict';var _=require('lodash');var util=require(_0x341f('0x0'));var moment=require(_0x341f('0x1'));var BPromise=require('bluebird');var rs=require(_0x341f('0x2'));var fs=require('fs');var Redis=require(_0x341f('0x3'));var db=require(_0x341f('0x4'))['db'];var utils=require(_0x341f('0x5'));var logger=require(_0x341f('0x6'))(_0x341f('0x7'));var config=require('../../config/environment');var jayson=require(_0x341f('0x8'));var client=jayson[_0x341f('0x9')][_0x341f('0xa')]({'port':0x232a});config['redis']=_[_0x341f('0xb')](config[_0x341f('0xc')],{'host':_0x341f('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x341f('0xc')]));require(_0x341f('0xe'))[_0x341f('0xf')](socket);function respondWithRpcPromise(_0x58d306,_0x473e87,_0x51a8b8){return new BPromise(function(_0x3b6115,_0x39e28b){return client['request'](_0x58d306,_0x51a8b8)['then'](function(_0x2fd1ae){logger[_0x341f('0x10')](_0x341f('0x11'),_0x473e87,'request\x20sent');logger[_0x341f('0x12')]('VoiceQueue,\x20%s,\x20%s,\x20%s',_0x473e87,_0x341f('0x13'),JSON[_0x341f('0x14')](_0x2fd1ae));if(_0x2fd1ae[_0x341f('0x15')]){if(_0x2fd1ae[_0x341f('0x15')][_0x341f('0x16')]===0x1f4){logger[_0x341f('0x15')]('VoiceQueue,\x20%s,\x20%s',_0x473e87,_0x2fd1ae[_0x341f('0x15')]['message']);return _0x39e28b(_0x2fd1ae['error'][_0x341f('0x17')]);}logger['error']('VoiceQueue,\x20%s,\x20%s',_0x473e87,_0x2fd1ae[_0x341f('0x15')][_0x341f('0x17')]);return _0x3b6115(_0x2fd1ae['error']['message']);}else{logger[_0x341f('0x10')](_0x341f('0x11'),_0x473e87,_0x341f('0x13'));_0x3b6115(_0x2fd1ae['result']['message']);}})[_0x341f('0x18')](function(_0x2e9b13){logger[_0x341f('0x15')](_0x341f('0x11'),_0x473e87,_0x2e9b13);_0x39e28b(_0x2e9b13);});});}exports[_0x341f('0x19')]=function(_0x2074d1){var _0x7f0e46=this;return new Promise(function(_0x145492,_0x4ddc0b){return db[_0x341f('0x1a')][_0x341f('0x1b')]({'raw':_0x2074d1[_0x341f('0x1c')]?_0x2074d1[_0x341f('0x1c')][_0x341f('0x1d')]===undefined?!![]:![]:!![],'where':_0x2074d1[_0x341f('0x1c')]?_0x2074d1[_0x341f('0x1c')][_0x341f('0x1e')]||null:null,'attributes':_0x2074d1[_0x341f('0x1c')]?_0x2074d1[_0x341f('0x1c')][_0x341f('0x1f')]||null:null,'limit':_0x2074d1[_0x341f('0x1c')]?_0x2074d1[_0x341f('0x1c')][_0x341f('0x20')]||null:null,'include':_0x2074d1['options']?_0x2074d1[_0x341f('0x1c')]['include']?_[_0x341f('0x21')](_0x2074d1[_0x341f('0x1c')][_0x341f('0x22')],function(_0x429858){return{'model':db[_0x429858['model']],'as':_0x429858['as'],'attributes':_0x429858[_0x341f('0x1f')],'include':_0x429858['include']?_[_0x341f('0x21')](_0x429858[_0x341f('0x22')],function(_0x27b86f){return{'model':db[_0x27b86f[_0x341f('0x23')]],'as':_0x27b86f['as'],'attributes':_0x27b86f[_0x341f('0x1f')],'include':_0x27b86f[_0x341f('0x22')]?_[_0x341f('0x21')](_0x27b86f[_0x341f('0x22')],function(_0xecabf5){return{'model':db[_0xecabf5[_0x341f('0x23')]],'as':_0xecabf5['as'],'attributes':_0xecabf5[_0x341f('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x341f('0x24')](function(_0x5a882e){logger[_0x341f('0x10')](_0x341f('0x19'),_0x2074d1);logger['debug']('GetVoiceQueue',_0x2074d1,JSON[_0x341f('0x14')](_0x5a882e));_0x145492(_0x5a882e);})[_0x341f('0x18')](function(_0x4cbcad){logger[_0x341f('0x15')](_0x341f('0x19'),_0x4cbcad[_0x341f('0x17')],_0x2074d1);_0x4ddc0b(_0x7f0e46[_0x341f('0x15')](0x1f4,_0x4cbcad[_0x341f('0x17')]));});});};exports[_0x341f('0x25')]=function(_0x4dba19){var _0x55e0ea=this;return new Promise(function(_0x559de2,_0x5c4340){return db[_0x341f('0x1a')][_0x341f('0x26')]({'raw':_0x4dba19[_0x341f('0x1c')]?_0x4dba19[_0x341f('0x1c')][_0x341f('0x1d')]===undefined?!![]:![]:!![],'where':_0x4dba19[_0x341f('0x1c')]?_0x4dba19[_0x341f('0x1c')][_0x341f('0x1e')]||null:null,'attributes':_0x4dba19['options']?_0x4dba19['options'][_0x341f('0x1f')]||null:null,'include':_0x4dba19[_0x341f('0x1c')]?_0x4dba19[_0x341f('0x1c')][_0x341f('0x22')]?_[_0x341f('0x21')](_0x4dba19[_0x341f('0x1c')][_0x341f('0x22')],function(_0x1a0976){return{'model':db[_0x1a0976[_0x341f('0x23')]],'as':_0x1a0976['as'],'attributes':_0x1a0976[_0x341f('0x1f')],'include':_0x1a0976[_0x341f('0x22')]?_['map'](_0x1a0976[_0x341f('0x22')],function(_0x3072dc){return{'model':db[_0x3072dc[_0x341f('0x23')]],'as':_0x3072dc['as'],'attributes':_0x3072dc[_0x341f('0x1f')],'include':_0x3072dc[_0x341f('0x22')]?_[_0x341f('0x21')](_0x3072dc['include'],function(_0x59be82){return{'model':db[_0x59be82['model']],'as':_0x59be82['as'],'attributes':_0x59be82[_0x341f('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x4c2291){logger[_0x341f('0x10')]('ShowVoiceQueue',_0x4dba19);logger[_0x341f('0x12')](_0x341f('0x25'),_0x4dba19,JSON[_0x341f('0x14')](_0x4c2291));_0x559de2(_0x4c2291);})[_0x341f('0x18')](function(_0x203182){logger[_0x341f('0x15')](_0x341f('0x25'),_0x203182[_0x341f('0x17')],_0x4dba19);_0x5c4340(_0x55e0ea[_0x341f('0x15')](0x1f4,_0x203182[_0x341f('0x17')]));});});};