Built motion from commit 1fd437e9.|2.6.19
[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 _0x99a4=['rpc','../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','./voiceQueue.socket','request','info','VoiceQueue,\x20%s,\x20%s','request\x20sent','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','GetVoiceQueue','VoiceQueue','findAll','options','raw','attributes','limit','include','map','model','ShowVoiceQueue','where','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils'];(function(_0x2f027c,_0x316550){var _0x381bfb=function(_0x139e40){while(--_0x139e40){_0x2f027c['push'](_0x2f027c['shift']());}};_0x381bfb(++_0x316550);}(_0x99a4,0x1f4));var _0x499a=function(_0x455c6c,_0x1e78b7){_0x455c6c=_0x455c6c-0x0;var _0x488242=_0x99a4[_0x455c6c];return _0x488242;};'use strict';var _=require(_0x499a('0x0'));var util=require(_0x499a('0x1'));var moment=require(_0x499a('0x2'));var BPromise=require('bluebird');var rs=require(_0x499a('0x3'));var fs=require('fs');var Redis=require(_0x499a('0x4'));var db=require(_0x499a('0x5'))['db'];var utils=require(_0x499a('0x6'));var logger=require('../../config/logger')(_0x499a('0x7'));var config=require(_0x499a('0x8'));var jayson=require(_0x499a('0x9'));var client=jayson[_0x499a('0xa')][_0x499a('0xb')]({'port':0x232a});config[_0x499a('0xc')]=_[_0x499a('0xd')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x499a('0xe'))(new Redis(config[_0x499a('0xc')]));require(_0x499a('0xf'))['register'](socket);function respondWithRpcPromise(_0x3fe592,_0x368cbd,_0x3529f9){return new BPromise(function(_0xcc802b,_0x429167){return client[_0x499a('0x10')](_0x3fe592,_0x3529f9)['then'](function(_0x508f77){logger[_0x499a('0x11')](_0x499a('0x12'),_0x368cbd,_0x499a('0x13'));logger[_0x499a('0x14')](_0x499a('0x15'),_0x368cbd,'request\x20sent',JSON[_0x499a('0x16')](_0x508f77));if(_0x508f77[_0x499a('0x17')]){if(_0x508f77['error']['code']===0x1f4){logger['error'](_0x499a('0x12'),_0x368cbd,_0x508f77[_0x499a('0x17')][_0x499a('0x18')]);return _0x429167(_0x508f77[_0x499a('0x17')][_0x499a('0x18')]);}logger[_0x499a('0x17')]('VoiceQueue,\x20%s,\x20%s',_0x368cbd,_0x508f77[_0x499a('0x17')]['message']);return _0xcc802b(_0x508f77[_0x499a('0x17')]['message']);}else{logger['info'](_0x499a('0x12'),_0x368cbd,_0x499a('0x13'));_0xcc802b(_0x508f77[_0x499a('0x19')][_0x499a('0x18')]);}})[_0x499a('0x1a')](function(_0x3d7c53){logger[_0x499a('0x17')]('VoiceQueue,\x20%s,\x20%s',_0x368cbd,_0x3d7c53);_0x429167(_0x3d7c53);});});}exports[_0x499a('0x1b')]=function(_0x126611){var _0x2ac39c=this;return new Promise(function(_0x3810c3,_0x23b905){return db[_0x499a('0x1c')][_0x499a('0x1d')]({'raw':_0x126611[_0x499a('0x1e')]?_0x126611[_0x499a('0x1e')][_0x499a('0x1f')]===undefined?!![]:![]:!![],'where':_0x126611[_0x499a('0x1e')]?_0x126611[_0x499a('0x1e')]['where']||null:null,'attributes':_0x126611['options']?_0x126611[_0x499a('0x1e')][_0x499a('0x20')]||null:null,'limit':_0x126611[_0x499a('0x1e')]?_0x126611[_0x499a('0x1e')][_0x499a('0x21')]||null:null,'include':_0x126611[_0x499a('0x1e')]?_0x126611['options'][_0x499a('0x22')]?_[_0x499a('0x23')](_0x126611[_0x499a('0x1e')][_0x499a('0x22')],function(_0x3e0b8f){return{'model':db[_0x3e0b8f['model']],'as':_0x3e0b8f['as'],'attributes':_0x3e0b8f[_0x499a('0x20')],'include':_0x3e0b8f[_0x499a('0x22')]?_[_0x499a('0x23')](_0x3e0b8f[_0x499a('0x22')],function(_0x1b9b09){return{'model':db[_0x1b9b09[_0x499a('0x24')]],'as':_0x1b9b09['as'],'attributes':_0x1b9b09[_0x499a('0x20')],'include':_0x1b9b09[_0x499a('0x22')]?_[_0x499a('0x23')](_0x1b9b09[_0x499a('0x22')],function(_0x424866){return{'model':db[_0x424866[_0x499a('0x24')]],'as':_0x424866['as'],'attributes':_0x424866['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x131567){logger['info'](_0x499a('0x1b'),_0x126611);logger[_0x499a('0x14')](_0x499a('0x1b'),_0x126611,JSON[_0x499a('0x16')](_0x131567));_0x3810c3(_0x131567);})[_0x499a('0x1a')](function(_0x2e7b4b){logger[_0x499a('0x17')](_0x499a('0x1b'),_0x2e7b4b['message'],_0x126611);_0x23b905(_0x2ac39c[_0x499a('0x17')](0x1f4,_0x2e7b4b[_0x499a('0x18')]));});});};exports[_0x499a('0x25')]=function(_0x1946cb){var _0x4b0cf9=this;return new Promise(function(_0x441df3,_0x16ddd3){return db[_0x499a('0x1c')]['find']({'raw':_0x1946cb[_0x499a('0x1e')]?_0x1946cb[_0x499a('0x1e')][_0x499a('0x1f')]===undefined?!![]:![]:!![],'where':_0x1946cb[_0x499a('0x1e')]?_0x1946cb[_0x499a('0x1e')][_0x499a('0x26')]||null:null,'attributes':_0x1946cb['options']?_0x1946cb[_0x499a('0x1e')]['attributes']||null:null,'include':_0x1946cb[_0x499a('0x1e')]?_0x1946cb['options'][_0x499a('0x22')]?_[_0x499a('0x23')](_0x1946cb['options'][_0x499a('0x22')],function(_0x3bee38){return{'model':db[_0x3bee38[_0x499a('0x24')]],'as':_0x3bee38['as'],'attributes':_0x3bee38[_0x499a('0x20')],'include':_0x3bee38['include']?_[_0x499a('0x23')](_0x3bee38[_0x499a('0x22')],function(_0x4a4ee7){return{'model':db[_0x4a4ee7[_0x499a('0x24')]],'as':_0x4a4ee7['as'],'attributes':_0x4a4ee7[_0x499a('0x20')],'include':_0x4a4ee7[_0x499a('0x22')]?_['map'](_0x4a4ee7['include'],function(_0x519933){return{'model':db[_0x519933[_0x499a('0x24')]],'as':_0x519933['as'],'attributes':_0x519933['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x55b414){logger[_0x499a('0x11')](_0x499a('0x25'),_0x1946cb);logger[_0x499a('0x14')](_0x499a('0x25'),_0x1946cb,JSON['stringify'](_0x55b414));_0x441df3(_0x55b414);})[_0x499a('0x1a')](function(_0x38562a){logger['error']('ShowVoiceQueue',_0x38562a['message'],_0x1946cb);_0x16ddd3(_0x4b0cf9[_0x499a('0x17')](0x1f4,_0x38562a[_0x499a('0x18')]));});});};