2ff08a7da608434ca75d5ad2aedf5bd22b4b36cd
[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 _0x13bd=['then','info','VoiceQueue,\x20%s,\x20%s','request\x20sent','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','GetVoiceQueue','VoiceQueue','findAll','options','raw','attributes','limit','include','model','map','debug','catch','ShowVoiceQueue','find','where','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','http','defaults','redis','localhost','register','request'];(function(_0x573823,_0x1d27fc){var _0x2b60ad=function(_0x12a929){while(--_0x12a929){_0x573823['push'](_0x573823['shift']());}};_0x2b60ad(++_0x1d27fc);}(_0x13bd,0x12a));var _0xd13b=function(_0x23ec89,_0x11c956){_0x23ec89=_0x23ec89-0x0;var _0x51aea2=_0x13bd[_0x23ec89];return _0x51aea2;};'use strict';var _=require(_0xd13b('0x0'));var util=require('util');var moment=require(_0xd13b('0x1'));var BPromise=require(_0xd13b('0x2'));var rs=require(_0xd13b('0x3'));var fs=require('fs');var Redis=require(_0xd13b('0x4'));var db=require(_0xd13b('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xd13b('0x6'))(_0xd13b('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0xd13b('0x8')]({'port':0x232a});config['redis']=_[_0xd13b('0x9')](config[_0xd13b('0xa')],{'host':_0xd13b('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xd13b('0xa')]));require('./voiceQueue.socket')[_0xd13b('0xc')](socket);function respondWithRpcPromise(_0x6f008f,_0x4202ae,_0x47d505){return new BPromise(function(_0x11a21e,_0xddb92d){return client[_0xd13b('0xd')](_0x6f008f,_0x47d505)[_0xd13b('0xe')](function(_0x4b6183){logger[_0xd13b('0xf')](_0xd13b('0x10'),_0x4202ae,_0xd13b('0x11'));logger['debug'](_0xd13b('0x12'),_0x4202ae,'request\x20sent',JSON[_0xd13b('0x13')](_0x4b6183));if(_0x4b6183[_0xd13b('0x14')]){if(_0x4b6183[_0xd13b('0x14')][_0xd13b('0x15')]===0x1f4){logger[_0xd13b('0x14')](_0xd13b('0x10'),_0x4202ae,_0x4b6183[_0xd13b('0x14')][_0xd13b('0x16')]);return _0xddb92d(_0x4b6183[_0xd13b('0x14')][_0xd13b('0x16')]);}logger['error'](_0xd13b('0x10'),_0x4202ae,_0x4b6183['error']['message']);return _0x11a21e(_0x4b6183[_0xd13b('0x14')]['message']);}else{logger[_0xd13b('0xf')]('VoiceQueue,\x20%s,\x20%s',_0x4202ae,_0xd13b('0x11'));_0x11a21e(_0x4b6183[_0xd13b('0x17')]['message']);}})['catch'](function(_0x4dcbf6){logger['error']('VoiceQueue,\x20%s,\x20%s',_0x4202ae,_0x4dcbf6);_0xddb92d(_0x4dcbf6);});});}exports[_0xd13b('0x18')]=function(_0x24b642){var _0x18d3c5=this;return new Promise(function(_0x3790e0,_0x42a368){return db[_0xd13b('0x19')][_0xd13b('0x1a')]({'raw':_0x24b642[_0xd13b('0x1b')]?_0x24b642[_0xd13b('0x1b')][_0xd13b('0x1c')]===undefined?!![]:![]:!![],'where':_0x24b642[_0xd13b('0x1b')]?_0x24b642[_0xd13b('0x1b')]['where']||null:null,'attributes':_0x24b642[_0xd13b('0x1b')]?_0x24b642[_0xd13b('0x1b')][_0xd13b('0x1d')]||null:null,'limit':_0x24b642['options']?_0x24b642[_0xd13b('0x1b')][_0xd13b('0x1e')]||null:null,'include':_0x24b642['options']?_0x24b642[_0xd13b('0x1b')]['include']?_['map'](_0x24b642['options']['include'],function(_0x35a9a4){return{'model':db[_0x35a9a4['model']],'as':_0x35a9a4['as'],'attributes':_0x35a9a4['attributes'],'include':_0x35a9a4['include']?_['map'](_0x35a9a4[_0xd13b('0x1f')],function(_0x1fdc7c){return{'model':db[_0x1fdc7c[_0xd13b('0x20')]],'as':_0x1fdc7c['as'],'attributes':_0x1fdc7c['attributes'],'include':_0x1fdc7c[_0xd13b('0x1f')]?_[_0xd13b('0x21')](_0x1fdc7c[_0xd13b('0x1f')],function(_0x36e2c2){return{'model':db[_0x36e2c2[_0xd13b('0x20')]],'as':_0x36e2c2['as'],'attributes':_0x36e2c2[_0xd13b('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xd13b('0xe')](function(_0x42a2e8){logger[_0xd13b('0xf')]('GetVoiceQueue',_0x24b642);logger[_0xd13b('0x22')](_0xd13b('0x18'),_0x24b642,JSON[_0xd13b('0x13')](_0x42a2e8));_0x3790e0(_0x42a2e8);})[_0xd13b('0x23')](function(_0x59621b){logger['error'](_0xd13b('0x18'),_0x59621b[_0xd13b('0x16')],_0x24b642);_0x42a368(_0x18d3c5['error'](0x1f4,_0x59621b[_0xd13b('0x16')]));});});};exports[_0xd13b('0x24')]=function(_0x3b2650){var _0x1cf586=this;return new Promise(function(_0x27637e,_0x346207){return db[_0xd13b('0x19')][_0xd13b('0x25')]({'raw':_0x3b2650['options']?_0x3b2650[_0xd13b('0x1b')][_0xd13b('0x1c')]===undefined?!![]:![]:!![],'where':_0x3b2650['options']?_0x3b2650['options'][_0xd13b('0x26')]||null:null,'attributes':_0x3b2650[_0xd13b('0x1b')]?_0x3b2650[_0xd13b('0x1b')]['attributes']||null:null,'include':_0x3b2650[_0xd13b('0x1b')]?_0x3b2650[_0xd13b('0x1b')][_0xd13b('0x1f')]?_[_0xd13b('0x21')](_0x3b2650[_0xd13b('0x1b')][_0xd13b('0x1f')],function(_0x454e69){return{'model':db[_0x454e69['model']],'as':_0x454e69['as'],'attributes':_0x454e69[_0xd13b('0x1d')],'include':_0x454e69['include']?_[_0xd13b('0x21')](_0x454e69[_0xd13b('0x1f')],function(_0x59bfb6){return{'model':db[_0x59bfb6[_0xd13b('0x20')]],'as':_0x59bfb6['as'],'attributes':_0x59bfb6[_0xd13b('0x1d')],'include':_0x59bfb6[_0xd13b('0x1f')]?_[_0xd13b('0x21')](_0x59bfb6[_0xd13b('0x1f')],function(_0x2b16ce){return{'model':db[_0x2b16ce[_0xd13b('0x20')]],'as':_0x2b16ce['as'],'attributes':_0x2b16ce[_0xd13b('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xd13b('0xe')](function(_0x5e1046){logger['info'](_0xd13b('0x24'),_0x3b2650);logger[_0xd13b('0x22')](_0xd13b('0x24'),_0x3b2650,JSON[_0xd13b('0x13')](_0x5e1046));_0x27637e(_0x5e1046);})['catch'](function(_0x1dac65){logger[_0xd13b('0x14')](_0xd13b('0x24'),_0x1dac65[_0xd13b('0x16')],_0x3b2650);_0x346207(_0x1cf586[_0xd13b('0x14')](0x1f4,_0x1dac65[_0xd13b('0x16')]));});});};