9bfdf6273e85790684290ebec7049b9f9d22f5cc
[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 _0x0ff7=['limit','include','map','model','then','ShowVoiceQueue','find','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./voiceQueue.socket','register','request','info','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','VoiceQueue,\x20%s,\x20%s','message','result','catch','GetVoiceQueue','findAll','options','raw','where','attributes'];(function(_0x8a94cb,_0x34f59e){var _0x45c132=function(_0xb1113e){while(--_0xb1113e){_0x8a94cb['push'](_0x8a94cb['shift']());}};_0x45c132(++_0x34f59e);}(_0x0ff7,0x134));var _0x70ff=function(_0x2112d4,_0x3c863c){_0x2112d4=_0x2112d4-0x0;var _0x434972=_0x0ff7[_0x2112d4];return _0x434972;};'use strict';var _=require(_0x70ff('0x0'));var util=require(_0x70ff('0x1'));var moment=require(_0x70ff('0x2'));var BPromise=require(_0x70ff('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x70ff('0x4'));var db=require(_0x70ff('0x5'))['db'];var utils=require(_0x70ff('0x6'));var logger=require(_0x70ff('0x7'))(_0x70ff('0x8'));var config=require('../../config/environment');var jayson=require(_0x70ff('0x9'));var client=jayson[_0x70ff('0xa')][_0x70ff('0xb')]({'port':0x232a});config[_0x70ff('0xc')]=_[_0x70ff('0xd')](config['redis'],{'host':_0x70ff('0xe'),'port':0x18eb});var socket=require(_0x70ff('0xf'))(new Redis(config[_0x70ff('0xc')]));require(_0x70ff('0x10'))[_0x70ff('0x11')](socket);function respondWithRpcPromise(_0x4b3a54,_0xc9930a,_0x55d198){return new BPromise(function(_0xa3575b,_0x4f7c65){return client[_0x70ff('0x12')](_0x4b3a54,_0x55d198)['then'](function(_0x43dce5){logger[_0x70ff('0x13')]('VoiceQueue,\x20%s,\x20%s',_0xc9930a,'request\x20sent');logger[_0x70ff('0x14')](_0x70ff('0x15'),_0xc9930a,_0x70ff('0x16'),JSON[_0x70ff('0x17')](_0x43dce5));if(_0x43dce5['error']){if(_0x43dce5[_0x70ff('0x18')][_0x70ff('0x19')]===0x1f4){logger[_0x70ff('0x18')](_0x70ff('0x1a'),_0xc9930a,_0x43dce5[_0x70ff('0x18')][_0x70ff('0x1b')]);return _0x4f7c65(_0x43dce5[_0x70ff('0x18')][_0x70ff('0x1b')]);}logger['error']('VoiceQueue,\x20%s,\x20%s',_0xc9930a,_0x43dce5[_0x70ff('0x18')][_0x70ff('0x1b')]);return _0xa3575b(_0x43dce5[_0x70ff('0x18')][_0x70ff('0x1b')]);}else{logger['info'](_0x70ff('0x1a'),_0xc9930a,_0x70ff('0x16'));_0xa3575b(_0x43dce5[_0x70ff('0x1c')][_0x70ff('0x1b')]);}})[_0x70ff('0x1d')](function(_0x587fe4){logger[_0x70ff('0x18')]('VoiceQueue,\x20%s,\x20%s',_0xc9930a,_0x587fe4);_0x4f7c65(_0x587fe4);});});}exports[_0x70ff('0x1e')]=function(_0x440306){var _0x2eedd3=this;return new Promise(function(_0x2d8b73,_0x5f2819){return db['VoiceQueue'][_0x70ff('0x1f')]({'raw':_0x440306[_0x70ff('0x20')]?_0x440306['options'][_0x70ff('0x21')]===undefined?!![]:![]:!![],'where':_0x440306['options']?_0x440306[_0x70ff('0x20')][_0x70ff('0x22')]||null:null,'attributes':_0x440306[_0x70ff('0x20')]?_0x440306[_0x70ff('0x20')][_0x70ff('0x23')]||null:null,'limit':_0x440306[_0x70ff('0x20')]?_0x440306['options'][_0x70ff('0x24')]||null:null,'include':_0x440306[_0x70ff('0x20')]?_0x440306[_0x70ff('0x20')][_0x70ff('0x25')]?_['map'](_0x440306[_0x70ff('0x20')][_0x70ff('0x25')],function(_0x216723){return{'model':db[_0x216723['model']],'as':_0x216723['as'],'attributes':_0x216723[_0x70ff('0x23')],'include':_0x216723[_0x70ff('0x25')]?_[_0x70ff('0x26')](_0x216723['include'],function(_0x28c9c3){return{'model':db[_0x28c9c3[_0x70ff('0x27')]],'as':_0x28c9c3['as'],'attributes':_0x28c9c3[_0x70ff('0x23')],'include':_0x28c9c3[_0x70ff('0x25')]?_['map'](_0x28c9c3['include'],function(_0x306c4f){return{'model':db[_0x306c4f[_0x70ff('0x27')]],'as':_0x306c4f['as'],'attributes':_0x306c4f[_0x70ff('0x23')]};}):[]};}):[]};}):[]:[]})[_0x70ff('0x28')](function(_0x5a2dea){logger[_0x70ff('0x13')](_0x70ff('0x1e'),_0x440306);logger['debug'](_0x70ff('0x1e'),_0x440306,JSON[_0x70ff('0x17')](_0x5a2dea));_0x2d8b73(_0x5a2dea);})['catch'](function(_0x541841){logger[_0x70ff('0x18')](_0x70ff('0x1e'),_0x541841['message'],_0x440306);_0x5f2819(_0x2eedd3[_0x70ff('0x18')](0x1f4,_0x541841[_0x70ff('0x1b')]));});});};exports[_0x70ff('0x29')]=function(_0x2e0fa9){var _0x46a99b=this;return new Promise(function(_0x1e7566,_0xaf7df8){return db['VoiceQueue'][_0x70ff('0x2a')]({'raw':_0x2e0fa9[_0x70ff('0x20')]?_0x2e0fa9[_0x70ff('0x20')][_0x70ff('0x21')]===undefined?!![]:![]:!![],'where':_0x2e0fa9['options']?_0x2e0fa9[_0x70ff('0x20')][_0x70ff('0x22')]||null:null,'attributes':_0x2e0fa9['options']?_0x2e0fa9['options'][_0x70ff('0x23')]||null:null,'include':_0x2e0fa9[_0x70ff('0x20')]?_0x2e0fa9[_0x70ff('0x20')][_0x70ff('0x25')]?_[_0x70ff('0x26')](_0x2e0fa9[_0x70ff('0x20')][_0x70ff('0x25')],function(_0x406f1a){return{'model':db[_0x406f1a[_0x70ff('0x27')]],'as':_0x406f1a['as'],'attributes':_0x406f1a['attributes'],'include':_0x406f1a[_0x70ff('0x25')]?_[_0x70ff('0x26')](_0x406f1a[_0x70ff('0x25')],function(_0x331486){return{'model':db[_0x331486['model']],'as':_0x331486['as'],'attributes':_0x331486[_0x70ff('0x23')],'include':_0x331486[_0x70ff('0x25')]?_['map'](_0x331486['include'],function(_0x43beab){return{'model':db[_0x43beab[_0x70ff('0x27')]],'as':_0x43beab['as'],'attributes':_0x43beab[_0x70ff('0x23')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x54dd73){logger[_0x70ff('0x13')](_0x70ff('0x29'),_0x2e0fa9);logger['debug'](_0x70ff('0x29'),_0x2e0fa9,JSON[_0x70ff('0x17')](_0x54dd73));_0x1e7566(_0x54dd73);})[_0x70ff('0x1d')](function(_0x5b0a03){logger[_0x70ff('0x18')](_0x70ff('0x29'),_0x5b0a03[_0x70ff('0x1b')],_0x2e0fa9);_0xaf7df8(_0x46a99b['error'](0x1f4,_0x5b0a03[_0x70ff('0x1b')]));});});};