Built motion from commit 39adb707.|2.6.14
[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 _0x4a30=['model','catch','ShowVoiceQueue','find','lodash','util','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','then','info','VoiceQueue,\x20%s,\x20%s','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','GetVoiceQueue','VoiceQueue','findAll','options','raw','where','attributes','limit','map','include'];(function(_0x30c649,_0x2ebbac){var _0x3edfb9=function(_0xab82f5){while(--_0xab82f5){_0x30c649['push'](_0x30c649['shift']());}};_0x3edfb9(++_0x2ebbac);}(_0x4a30,0x15a));var _0x04a3=function(_0x52e8f1,_0x2d3350){_0x52e8f1=_0x52e8f1-0x0;var _0x589cdb=_0x4a30[_0x52e8f1];return _0x589cdb;};'use strict';var _=require(_0x04a3('0x0'));var util=require(_0x04a3('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x04a3('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x04a3('0x3'))['db'];var utils=require(_0x04a3('0x4'));var logger=require('../../config/logger')(_0x04a3('0x5'));var config=require(_0x04a3('0x6'));var jayson=require(_0x04a3('0x7'));var client=jayson[_0x04a3('0x8')][_0x04a3('0x9')]({'port':0x232a});config[_0x04a3('0xa')]=_[_0x04a3('0xb')](config[_0x04a3('0xa')],{'host':_0x04a3('0xc'),'port':0x18eb});var socket=require(_0x04a3('0xd'))(new Redis(config[_0x04a3('0xa')]));require('./voiceQueue.socket')['register'](socket);function respondWithRpcPromise(_0x20881c,_0x29658e,_0x333d8c){return new BPromise(function(_0x1e1c91,_0x4ef162){return client['request'](_0x20881c,_0x333d8c)[_0x04a3('0xe')](function(_0x128ee3){logger[_0x04a3('0xf')](_0x04a3('0x10'),_0x29658e,'request\x20sent');logger[_0x04a3('0x11')](_0x04a3('0x12'),_0x29658e,_0x04a3('0x13'),JSON[_0x04a3('0x14')](_0x128ee3));if(_0x128ee3['error']){if(_0x128ee3['error']['code']===0x1f4){logger[_0x04a3('0x15')](_0x04a3('0x10'),_0x29658e,_0x128ee3[_0x04a3('0x15')][_0x04a3('0x16')]);return _0x4ef162(_0x128ee3[_0x04a3('0x15')][_0x04a3('0x16')]);}logger[_0x04a3('0x15')](_0x04a3('0x10'),_0x29658e,_0x128ee3[_0x04a3('0x15')]['message']);return _0x1e1c91(_0x128ee3[_0x04a3('0x15')]['message']);}else{logger[_0x04a3('0xf')]('VoiceQueue,\x20%s,\x20%s',_0x29658e,_0x04a3('0x13'));_0x1e1c91(_0x128ee3[_0x04a3('0x17')]['message']);}})['catch'](function(_0x5e3050){logger[_0x04a3('0x15')](_0x04a3('0x10'),_0x29658e,_0x5e3050);_0x4ef162(_0x5e3050);});});}exports[_0x04a3('0x18')]=function(_0x29915d){var _0x367cbb=this;return new Promise(function(_0x572f9f,_0x1afca1){return db[_0x04a3('0x19')][_0x04a3('0x1a')]({'raw':_0x29915d[_0x04a3('0x1b')]?_0x29915d[_0x04a3('0x1b')][_0x04a3('0x1c')]===undefined?!![]:![]:!![],'where':_0x29915d[_0x04a3('0x1b')]?_0x29915d[_0x04a3('0x1b')][_0x04a3('0x1d')]||null:null,'attributes':_0x29915d[_0x04a3('0x1b')]?_0x29915d['options'][_0x04a3('0x1e')]||null:null,'limit':_0x29915d[_0x04a3('0x1b')]?_0x29915d[_0x04a3('0x1b')][_0x04a3('0x1f')]||null:null,'include':_0x29915d[_0x04a3('0x1b')]?_0x29915d[_0x04a3('0x1b')]['include']?_[_0x04a3('0x20')](_0x29915d[_0x04a3('0x1b')][_0x04a3('0x21')],function(_0x1fd93b){return{'model':db[_0x1fd93b[_0x04a3('0x22')]],'as':_0x1fd93b['as'],'attributes':_0x1fd93b[_0x04a3('0x1e')],'include':_0x1fd93b[_0x04a3('0x21')]?_[_0x04a3('0x20')](_0x1fd93b['include'],function(_0xc13d2a){return{'model':db[_0xc13d2a[_0x04a3('0x22')]],'as':_0xc13d2a['as'],'attributes':_0xc13d2a[_0x04a3('0x1e')],'include':_0xc13d2a[_0x04a3('0x21')]?_[_0x04a3('0x20')](_0xc13d2a[_0x04a3('0x21')],function(_0x1892f8){return{'model':db[_0x1892f8[_0x04a3('0x22')]],'as':_0x1892f8['as'],'attributes':_0x1892f8['attributes']};}):[]};}):[]};}):[]:[]})[_0x04a3('0xe')](function(_0x93edde){logger[_0x04a3('0xf')]('GetVoiceQueue',_0x29915d);logger['debug'](_0x04a3('0x18'),_0x29915d,JSON[_0x04a3('0x14')](_0x93edde));_0x572f9f(_0x93edde);})[_0x04a3('0x23')](function(_0xfd8500){logger[_0x04a3('0x15')](_0x04a3('0x18'),_0xfd8500[_0x04a3('0x16')],_0x29915d);_0x1afca1(_0x367cbb[_0x04a3('0x15')](0x1f4,_0xfd8500[_0x04a3('0x16')]));});});};exports[_0x04a3('0x24')]=function(_0x2ef9a3){var _0x1566b6=this;return new Promise(function(_0x58dfe9,_0x3e6705){return db['VoiceQueue'][_0x04a3('0x25')]({'raw':_0x2ef9a3[_0x04a3('0x1b')]?_0x2ef9a3[_0x04a3('0x1b')][_0x04a3('0x1c')]===undefined?!![]:![]:!![],'where':_0x2ef9a3[_0x04a3('0x1b')]?_0x2ef9a3['options'][_0x04a3('0x1d')]||null:null,'attributes':_0x2ef9a3[_0x04a3('0x1b')]?_0x2ef9a3[_0x04a3('0x1b')][_0x04a3('0x1e')]||null:null,'include':_0x2ef9a3[_0x04a3('0x1b')]?_0x2ef9a3['options']['include']?_[_0x04a3('0x20')](_0x2ef9a3[_0x04a3('0x1b')][_0x04a3('0x21')],function(_0x4c0bed){return{'model':db[_0x4c0bed[_0x04a3('0x22')]],'as':_0x4c0bed['as'],'attributes':_0x4c0bed[_0x04a3('0x1e')],'include':_0x4c0bed[_0x04a3('0x21')]?_[_0x04a3('0x20')](_0x4c0bed[_0x04a3('0x21')],function(_0x454fb2){return{'model':db[_0x454fb2['model']],'as':_0x454fb2['as'],'attributes':_0x454fb2[_0x04a3('0x1e')],'include':_0x454fb2[_0x04a3('0x21')]?_[_0x04a3('0x20')](_0x454fb2[_0x04a3('0x21')],function(_0x443d84){return{'model':db[_0x443d84['model']],'as':_0x443d84['as'],'attributes':_0x443d84[_0x04a3('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x04a3('0xe')](function(_0x5f2492){logger[_0x04a3('0xf')](_0x04a3('0x24'),_0x2ef9a3);logger['debug'](_0x04a3('0x24'),_0x2ef9a3,JSON[_0x04a3('0x14')](_0x5f2492));_0x58dfe9(_0x5f2492);})['catch'](function(_0x4f03eb){logger['error'](_0x04a3('0x24'),_0x4f03eb[_0x04a3('0x16')],_0x2ef9a3);_0x3e6705(_0x1566b6['error'](0x1f4,_0x4f03eb[_0x04a3('0x16')]));});});};