52063d1228c65e93a9ac7dfc1784f58b2e0495fe
[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 _0x7aa5=['where','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','request','then','request\x20sent','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','VoiceQueue,\x20%s,\x20%s','message','info','GetVoiceQueue','VoiceQueue','findAll','options','raw','attributes','limit','map','include','model','ShowVoiceQueue','find'];(function(_0x872dfa,_0x4ff880){var _0xc3de9c=function(_0x1f6deb){while(--_0x1f6deb){_0x872dfa['push'](_0x872dfa['shift']());}};_0xc3de9c(++_0x4ff880);}(_0x7aa5,0x10b));var _0x57aa=function(_0x222e2d,_0x4cff0c){_0x222e2d=_0x222e2d-0x0;var _0x3dbbac=_0x7aa5[_0x222e2d];return _0x3dbbac;};'use strict';var _=require(_0x57aa('0x0'));var util=require(_0x57aa('0x1'));var moment=require('moment');var BPromise=require(_0x57aa('0x2'));var rs=require(_0x57aa('0x3'));var fs=require('fs');var Redis=require(_0x57aa('0x4'));var db=require(_0x57aa('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x57aa('0x6'))(_0x57aa('0x7'));var config=require('../../config/environment');var jayson=require(_0x57aa('0x8'));var client=jayson[_0x57aa('0x9')]['http']({'port':0x232a});config[_0x57aa('0xa')]=_[_0x57aa('0xb')](config[_0x57aa('0xa')],{'host':_0x57aa('0xc'),'port':0x18eb});var socket=require(_0x57aa('0xd'))(new Redis(config[_0x57aa('0xa')]));require('./voiceQueue.socket')['register'](socket);function respondWithRpcPromise(_0x256766,_0x10f859,_0x23c43e){return new BPromise(function(_0x77465,_0x4c969f){return client[_0x57aa('0xe')](_0x256766,_0x23c43e)[_0x57aa('0xf')](function(_0x5f1c16){logger['info']('VoiceQueue,\x20%s,\x20%s',_0x10f859,_0x57aa('0x10'));logger[_0x57aa('0x11')](_0x57aa('0x12'),_0x10f859,'request\x20sent',JSON[_0x57aa('0x13')](_0x5f1c16));if(_0x5f1c16[_0x57aa('0x14')]){if(_0x5f1c16[_0x57aa('0x14')][_0x57aa('0x15')]===0x1f4){logger[_0x57aa('0x14')](_0x57aa('0x16'),_0x10f859,_0x5f1c16[_0x57aa('0x14')][_0x57aa('0x17')]);return _0x4c969f(_0x5f1c16[_0x57aa('0x14')]['message']);}logger[_0x57aa('0x14')](_0x57aa('0x16'),_0x10f859,_0x5f1c16['error'][_0x57aa('0x17')]);return _0x77465(_0x5f1c16[_0x57aa('0x14')][_0x57aa('0x17')]);}else{logger[_0x57aa('0x18')](_0x57aa('0x16'),_0x10f859,_0x57aa('0x10'));_0x77465(_0x5f1c16['result'][_0x57aa('0x17')]);}})['catch'](function(_0x299f5b){logger[_0x57aa('0x14')]('VoiceQueue,\x20%s,\x20%s',_0x10f859,_0x299f5b);_0x4c969f(_0x299f5b);});});}exports[_0x57aa('0x19')]=function(_0x347649){var _0x1d1d42=this;return new Promise(function(_0x4781f3,_0xa86852){return db[_0x57aa('0x1a')][_0x57aa('0x1b')]({'raw':_0x347649[_0x57aa('0x1c')]?_0x347649['options'][_0x57aa('0x1d')]===undefined?!![]:![]:!![],'where':_0x347649[_0x57aa('0x1c')]?_0x347649[_0x57aa('0x1c')]['where']||null:null,'attributes':_0x347649['options']?_0x347649[_0x57aa('0x1c')][_0x57aa('0x1e')]||null:null,'limit':_0x347649['options']?_0x347649[_0x57aa('0x1c')][_0x57aa('0x1f')]||null:null,'include':_0x347649[_0x57aa('0x1c')]?_0x347649[_0x57aa('0x1c')]['include']?_[_0x57aa('0x20')](_0x347649[_0x57aa('0x1c')][_0x57aa('0x21')],function(_0x4406e9){return{'model':db[_0x4406e9[_0x57aa('0x22')]],'as':_0x4406e9['as'],'attributes':_0x4406e9[_0x57aa('0x1e')],'include':_0x4406e9[_0x57aa('0x21')]?_[_0x57aa('0x20')](_0x4406e9[_0x57aa('0x21')],function(_0x4b00cd){return{'model':db[_0x4b00cd['model']],'as':_0x4b00cd['as'],'attributes':_0x4b00cd[_0x57aa('0x1e')],'include':_0x4b00cd['include']?_[_0x57aa('0x20')](_0x4b00cd[_0x57aa('0x21')],function(_0x220e7e){return{'model':db[_0x220e7e[_0x57aa('0x22')]],'as':_0x220e7e['as'],'attributes':_0x220e7e[_0x57aa('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x57aa('0xf')](function(_0x262118){logger[_0x57aa('0x18')](_0x57aa('0x19'),_0x347649);logger[_0x57aa('0x11')](_0x57aa('0x19'),_0x347649,JSON[_0x57aa('0x13')](_0x262118));_0x4781f3(_0x262118);})['catch'](function(_0x87759d){logger['error'](_0x57aa('0x19'),_0x87759d[_0x57aa('0x17')],_0x347649);_0xa86852(_0x1d1d42[_0x57aa('0x14')](0x1f4,_0x87759d['message']));});});};exports[_0x57aa('0x23')]=function(_0x28a4fc){var _0x3bf9d1=this;return new Promise(function(_0x34fea6,_0x488893){return db[_0x57aa('0x1a')][_0x57aa('0x24')]({'raw':_0x28a4fc[_0x57aa('0x1c')]?_0x28a4fc[_0x57aa('0x1c')][_0x57aa('0x1d')]===undefined?!![]:![]:!![],'where':_0x28a4fc[_0x57aa('0x1c')]?_0x28a4fc[_0x57aa('0x1c')][_0x57aa('0x25')]||null:null,'attributes':_0x28a4fc[_0x57aa('0x1c')]?_0x28a4fc[_0x57aa('0x1c')][_0x57aa('0x1e')]||null:null,'include':_0x28a4fc[_0x57aa('0x1c')]?_0x28a4fc[_0x57aa('0x1c')][_0x57aa('0x21')]?_[_0x57aa('0x20')](_0x28a4fc['options'][_0x57aa('0x21')],function(_0x40784e){return{'model':db[_0x40784e[_0x57aa('0x22')]],'as':_0x40784e['as'],'attributes':_0x40784e[_0x57aa('0x1e')],'include':_0x40784e[_0x57aa('0x21')]?_[_0x57aa('0x20')](_0x40784e[_0x57aa('0x21')],function(_0x13a533){return{'model':db[_0x13a533[_0x57aa('0x22')]],'as':_0x13a533['as'],'attributes':_0x13a533['attributes'],'include':_0x13a533[_0x57aa('0x21')]?_[_0x57aa('0x20')](_0x13a533['include'],function(_0x36407f){return{'model':db[_0x36407f[_0x57aa('0x22')]],'as':_0x36407f['as'],'attributes':_0x36407f[_0x57aa('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x57aa('0xf')](function(_0x273e98){logger[_0x57aa('0x18')](_0x57aa('0x23'),_0x28a4fc);logger[_0x57aa('0x11')](_0x57aa('0x23'),_0x28a4fc,JSON[_0x57aa('0x13')](_0x273e98));_0x34fea6(_0x273e98);})['catch'](function(_0x3fa8e4){logger[_0x57aa('0x14')](_0x57aa('0x23'),_0x3fa8e4[_0x57aa('0x17')],_0x28a4fc);_0x488893(_0x3bf9d1['error'](0x1f4,_0x3fa8e4[_0x57aa('0x17')]));});});};