Built motion from commit 47436d59.|2.6.7
[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 _0xe005=['raw','lodash','util','moment','bluebird','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./voiceQueue.socket','register','request','then','info','VoiceQueue,\x20%s,\x20%s','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','message','GetVoiceQueue','VoiceQueue','findAll','options','where','attributes','limit','include','model','map','catch','ShowVoiceQueue','find'];(function(_0x23f4ad,_0x3229ca){var _0x774969=function(_0x1dd16c){while(--_0x1dd16c){_0x23f4ad['push'](_0x23f4ad['shift']());}};_0x774969(++_0x3229ca);}(_0xe005,0xa1));var _0x5e00=function(_0x548ca2,_0x4f1916){_0x548ca2=_0x548ca2-0x0;var _0x110a9a=_0xe005[_0x548ca2];return _0x110a9a;};'use strict';var _=require(_0x5e00('0x0'));var util=require(_0x5e00('0x1'));var moment=require(_0x5e00('0x2'));var BPromise=require(_0x5e00('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x5e00('0x4'));var db=require(_0x5e00('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x5e00('0x6'));var config=require(_0x5e00('0x7'));var jayson=require(_0x5e00('0x8'));var client=jayson[_0x5e00('0x9')][_0x5e00('0xa')]({'port':0x232a});config[_0x5e00('0xb')]=_[_0x5e00('0xc')](config[_0x5e00('0xb')],{'host':_0x5e00('0xd'),'port':0x18eb});var socket=require(_0x5e00('0xe'))(new Redis(config[_0x5e00('0xb')]));require(_0x5e00('0xf'))[_0x5e00('0x10')](socket);function respondWithRpcPromise(_0x173837,_0x52e831,_0x4c882a){return new BPromise(function(_0x3d37f2,_0x11a331){return client[_0x5e00('0x11')](_0x173837,_0x4c882a)[_0x5e00('0x12')](function(_0x3aeaa0){logger[_0x5e00('0x13')](_0x5e00('0x14'),_0x52e831,'request\x20sent');logger[_0x5e00('0x15')](_0x5e00('0x16'),_0x52e831,'request\x20sent',JSON[_0x5e00('0x17')](_0x3aeaa0));if(_0x3aeaa0['error']){if(_0x3aeaa0[_0x5e00('0x18')]['code']===0x1f4){logger[_0x5e00('0x18')]('VoiceQueue,\x20%s,\x20%s',_0x52e831,_0x3aeaa0[_0x5e00('0x18')][_0x5e00('0x19')]);return _0x11a331(_0x3aeaa0[_0x5e00('0x18')][_0x5e00('0x19')]);}logger[_0x5e00('0x18')]('VoiceQueue,\x20%s,\x20%s',_0x52e831,_0x3aeaa0[_0x5e00('0x18')]['message']);return _0x3d37f2(_0x3aeaa0[_0x5e00('0x18')][_0x5e00('0x19')]);}else{logger[_0x5e00('0x13')](_0x5e00('0x14'),_0x52e831,'request\x20sent');_0x3d37f2(_0x3aeaa0['result'][_0x5e00('0x19')]);}})['catch'](function(_0x1976e9){logger[_0x5e00('0x18')](_0x5e00('0x14'),_0x52e831,_0x1976e9);_0x11a331(_0x1976e9);});});}exports[_0x5e00('0x1a')]=function(_0x27570c){var _0xe48858=this;return new Promise(function(_0x338340,_0x454e9f){return db[_0x5e00('0x1b')][_0x5e00('0x1c')]({'raw':_0x27570c[_0x5e00('0x1d')]?_0x27570c[_0x5e00('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x27570c[_0x5e00('0x1d')]?_0x27570c[_0x5e00('0x1d')][_0x5e00('0x1e')]||null:null,'attributes':_0x27570c[_0x5e00('0x1d')]?_0x27570c[_0x5e00('0x1d')][_0x5e00('0x1f')]||null:null,'limit':_0x27570c['options']?_0x27570c[_0x5e00('0x1d')][_0x5e00('0x20')]||null:null,'include':_0x27570c[_0x5e00('0x1d')]?_0x27570c['options'][_0x5e00('0x21')]?_['map'](_0x27570c[_0x5e00('0x1d')][_0x5e00('0x21')],function(_0x52db78){return{'model':db[_0x52db78[_0x5e00('0x22')]],'as':_0x52db78['as'],'attributes':_0x52db78[_0x5e00('0x1f')],'include':_0x52db78[_0x5e00('0x21')]?_[_0x5e00('0x23')](_0x52db78[_0x5e00('0x21')],function(_0x4b7644){return{'model':db[_0x4b7644[_0x5e00('0x22')]],'as':_0x4b7644['as'],'attributes':_0x4b7644[_0x5e00('0x1f')],'include':_0x4b7644[_0x5e00('0x21')]?_['map'](_0x4b7644[_0x5e00('0x21')],function(_0x47e9b8){return{'model':db[_0x47e9b8['model']],'as':_0x47e9b8['as'],'attributes':_0x47e9b8[_0x5e00('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x5e00('0x12')](function(_0x5bdbd7){logger['info'](_0x5e00('0x1a'),_0x27570c);logger[_0x5e00('0x15')]('GetVoiceQueue',_0x27570c,JSON[_0x5e00('0x17')](_0x5bdbd7));_0x338340(_0x5bdbd7);})[_0x5e00('0x24')](function(_0x3a4533){logger[_0x5e00('0x18')](_0x5e00('0x1a'),_0x3a4533[_0x5e00('0x19')],_0x27570c);_0x454e9f(_0xe48858['error'](0x1f4,_0x3a4533['message']));});});};exports[_0x5e00('0x25')]=function(_0x51538b){var _0x297c2f=this;return new Promise(function(_0x117e84,_0x37f2d9){return db['VoiceQueue'][_0x5e00('0x26')]({'raw':_0x51538b[_0x5e00('0x1d')]?_0x51538b[_0x5e00('0x1d')][_0x5e00('0x27')]===undefined?!![]:![]:!![],'where':_0x51538b[_0x5e00('0x1d')]?_0x51538b[_0x5e00('0x1d')][_0x5e00('0x1e')]||null:null,'attributes':_0x51538b[_0x5e00('0x1d')]?_0x51538b[_0x5e00('0x1d')][_0x5e00('0x1f')]||null:null,'include':_0x51538b[_0x5e00('0x1d')]?_0x51538b['options']['include']?_[_0x5e00('0x23')](_0x51538b[_0x5e00('0x1d')][_0x5e00('0x21')],function(_0x28d395){return{'model':db[_0x28d395[_0x5e00('0x22')]],'as':_0x28d395['as'],'attributes':_0x28d395[_0x5e00('0x1f')],'include':_0x28d395[_0x5e00('0x21')]?_[_0x5e00('0x23')](_0x28d395[_0x5e00('0x21')],function(_0x449f5d){return{'model':db[_0x449f5d[_0x5e00('0x22')]],'as':_0x449f5d['as'],'attributes':_0x449f5d[_0x5e00('0x1f')],'include':_0x449f5d['include']?_[_0x5e00('0x23')](_0x449f5d[_0x5e00('0x21')],function(_0x445954){return{'model':db[_0x445954[_0x5e00('0x22')]],'as':_0x445954['as'],'attributes':_0x445954[_0x5e00('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5bdf8e){logger[_0x5e00('0x13')](_0x5e00('0x25'),_0x51538b);logger[_0x5e00('0x15')]('ShowVoiceQueue',_0x51538b,JSON[_0x5e00('0x17')](_0x5bdf8e));_0x117e84(_0x5bdf8e);})[_0x5e00('0x24')](function(_0x9dead){logger[_0x5e00('0x18')]('ShowVoiceQueue',_0x9dead[_0x5e00('0x19')],_0x51538b);_0x37f2d9(_0x297c2f[_0x5e00('0x18')](0x1f4,_0x9dead['message']));});});};