Built motion from commit 167bccf5.|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 _0xadc4=['GetVoiceQueue','VoiceQueue','findAll','options','raw','where','attributes','limit','include','map','model','then','debug','ShowVoiceQueue','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./voiceQueue.socket','request','request\x20sent','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','VoiceQueue,\x20%s,\x20%s','message','info','result','catch'];(function(_0x3f0ed7,_0x1f439f){var _0x34578f=function(_0x498fe4){while(--_0x498fe4){_0x3f0ed7['push'](_0x3f0ed7['shift']());}};_0x34578f(++_0x1f439f);}(_0xadc4,0xae));var _0x4adc=function(_0x4a9cfa,_0x38de10){_0x4a9cfa=_0x4a9cfa-0x0;var _0x1a795f=_0xadc4[_0x4a9cfa];return _0x1a795f;};'use strict';var _=require(_0x4adc('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x4adc('0x1'));var rs=require(_0x4adc('0x2'));var fs=require('fs');var Redis=require(_0x4adc('0x3'));var db=require(_0x4adc('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x4adc('0x5'))(_0x4adc('0x6'));var config=require(_0x4adc('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x4adc('0x8')][_0x4adc('0x9')]({'port':0x232a});config[_0x4adc('0xa')]=_[_0x4adc('0xb')](config[_0x4adc('0xa')],{'host':_0x4adc('0xc'),'port':0x18eb});var socket=require(_0x4adc('0xd'))(new Redis(config[_0x4adc('0xa')]));require(_0x4adc('0xe'))['register'](socket);function respondWithRpcPromise(_0x57b5ce,_0x490952,_0x35ad5d){return new BPromise(function(_0x476218,_0x406732){return client[_0x4adc('0xf')](_0x57b5ce,_0x35ad5d)['then'](function(_0x3e76dd){logger['info']('VoiceQueue,\x20%s,\x20%s',_0x490952,_0x4adc('0x10'));logger['debug'](_0x4adc('0x11'),_0x490952,_0x4adc('0x10'),JSON[_0x4adc('0x12')](_0x3e76dd));if(_0x3e76dd[_0x4adc('0x13')]){if(_0x3e76dd['error'][_0x4adc('0x14')]===0x1f4){logger['error'](_0x4adc('0x15'),_0x490952,_0x3e76dd[_0x4adc('0x13')]['message']);return _0x406732(_0x3e76dd[_0x4adc('0x13')][_0x4adc('0x16')]);}logger[_0x4adc('0x13')](_0x4adc('0x15'),_0x490952,_0x3e76dd[_0x4adc('0x13')][_0x4adc('0x16')]);return _0x476218(_0x3e76dd[_0x4adc('0x13')][_0x4adc('0x16')]);}else{logger[_0x4adc('0x17')]('VoiceQueue,\x20%s,\x20%s',_0x490952,'request\x20sent');_0x476218(_0x3e76dd[_0x4adc('0x18')][_0x4adc('0x16')]);}})[_0x4adc('0x19')](function(_0x502c5f){logger[_0x4adc('0x13')](_0x4adc('0x15'),_0x490952,_0x502c5f);_0x406732(_0x502c5f);});});}exports[_0x4adc('0x1a')]=function(_0x5c77dc){var _0x3e301c=this;return new Promise(function(_0x1c8c85,_0x2397f4){return db[_0x4adc('0x1b')][_0x4adc('0x1c')]({'raw':_0x5c77dc[_0x4adc('0x1d')]?_0x5c77dc[_0x4adc('0x1d')][_0x4adc('0x1e')]===undefined?!![]:![]:!![],'where':_0x5c77dc[_0x4adc('0x1d')]?_0x5c77dc[_0x4adc('0x1d')][_0x4adc('0x1f')]||null:null,'attributes':_0x5c77dc[_0x4adc('0x1d')]?_0x5c77dc[_0x4adc('0x1d')][_0x4adc('0x20')]||null:null,'limit':_0x5c77dc[_0x4adc('0x1d')]?_0x5c77dc[_0x4adc('0x1d')][_0x4adc('0x21')]||null:null,'include':_0x5c77dc[_0x4adc('0x1d')]?_0x5c77dc[_0x4adc('0x1d')][_0x4adc('0x22')]?_[_0x4adc('0x23')](_0x5c77dc[_0x4adc('0x1d')][_0x4adc('0x22')],function(_0x8dc94e){return{'model':db[_0x8dc94e['model']],'as':_0x8dc94e['as'],'attributes':_0x8dc94e[_0x4adc('0x20')],'include':_0x8dc94e[_0x4adc('0x22')]?_['map'](_0x8dc94e[_0x4adc('0x22')],function(_0x4e700e){return{'model':db[_0x4e700e['model']],'as':_0x4e700e['as'],'attributes':_0x4e700e[_0x4adc('0x20')],'include':_0x4e700e[_0x4adc('0x22')]?_[_0x4adc('0x23')](_0x4e700e[_0x4adc('0x22')],function(_0x5091e7){return{'model':db[_0x5091e7[_0x4adc('0x24')]],'as':_0x5091e7['as'],'attributes':_0x5091e7[_0x4adc('0x20')]};}):[]};}):[]};}):[]:[]})[_0x4adc('0x25')](function(_0x581c2c){logger['info'](_0x4adc('0x1a'),_0x5c77dc);logger[_0x4adc('0x26')]('GetVoiceQueue',_0x5c77dc,JSON['stringify'](_0x581c2c));_0x1c8c85(_0x581c2c);})['catch'](function(_0x11839b){logger[_0x4adc('0x13')](_0x4adc('0x1a'),_0x11839b['message'],_0x5c77dc);_0x2397f4(_0x3e301c[_0x4adc('0x13')](0x1f4,_0x11839b[_0x4adc('0x16')]));});});};exports[_0x4adc('0x27')]=function(_0x30ba59){var _0x292fb4=this;return new Promise(function(_0x223dbb,_0xe35d1d){return db[_0x4adc('0x1b')]['find']({'raw':_0x30ba59[_0x4adc('0x1d')]?_0x30ba59[_0x4adc('0x1d')][_0x4adc('0x1e')]===undefined?!![]:![]:!![],'where':_0x30ba59['options']?_0x30ba59[_0x4adc('0x1d')][_0x4adc('0x1f')]||null:null,'attributes':_0x30ba59[_0x4adc('0x1d')]?_0x30ba59[_0x4adc('0x1d')][_0x4adc('0x20')]||null:null,'include':_0x30ba59[_0x4adc('0x1d')]?_0x30ba59[_0x4adc('0x1d')][_0x4adc('0x22')]?_[_0x4adc('0x23')](_0x30ba59[_0x4adc('0x1d')][_0x4adc('0x22')],function(_0x1259af){return{'model':db[_0x1259af[_0x4adc('0x24')]],'as':_0x1259af['as'],'attributes':_0x1259af[_0x4adc('0x20')],'include':_0x1259af[_0x4adc('0x22')]?_[_0x4adc('0x23')](_0x1259af[_0x4adc('0x22')],function(_0x1ed2b6){return{'model':db[_0x1ed2b6[_0x4adc('0x24')]],'as':_0x1ed2b6['as'],'attributes':_0x1ed2b6[_0x4adc('0x20')],'include':_0x1ed2b6['include']?_['map'](_0x1ed2b6['include'],function(_0x320c49){return{'model':db[_0x320c49[_0x4adc('0x24')]],'as':_0x320c49['as'],'attributes':_0x320c49[_0x4adc('0x20')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1c5452){logger[_0x4adc('0x17')]('ShowVoiceQueue',_0x30ba59);logger['debug']('ShowVoiceQueue',_0x30ba59,JSON[_0x4adc('0x12')](_0x1c5452));_0x223dbb(_0x1c5452);})[_0x4adc('0x19')](function(_0x33df41){logger[_0x4adc('0x13')](_0x4adc('0x27'),_0x33df41['message'],_0x30ba59);_0xe35d1d(_0x292fb4[_0x4adc('0x13')](0x1f4,_0x33df41['message']));});});};