Built motion from commit (unavailable).|2.5.31
[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 _0xf337=['result','GetVoiceQueue','VoiceQueue','findAll','options','raw','where','attributes','limit','map','model','include','catch','ShowVoiceQueue','find','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','./voiceQueue.socket','register','then','info','VoiceQueue,\x20%s,\x20%s','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x1cfa0d,_0x4391f2){var _0xe33279=function(_0x3ce7c1){while(--_0x3ce7c1){_0x1cfa0d['push'](_0x1cfa0d['shift']());}};_0xe33279(++_0x4391f2);}(_0xf337,0xe6));var _0x7f33=function(_0x5155dd,_0x27790b){_0x5155dd=_0x5155dd-0x0;var _0xa8b2b3=_0xf337[_0x5155dd];return _0xa8b2b3;};'use strict';var _=require(_0x7f33('0x0'));var util=require(_0x7f33('0x1'));var moment=require(_0x7f33('0x2'));var BPromise=require(_0x7f33('0x3'));var rs=require(_0x7f33('0x4'));var fs=require('fs');var Redis=require(_0x7f33('0x5'));var db=require(_0x7f33('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x7f33('0x7'))(_0x7f33('0x8'));var config=require(_0x7f33('0x9'));var jayson=require(_0x7f33('0xa'));var client=jayson[_0x7f33('0xb')][_0x7f33('0xc')]({'port':0x232a});config['redis']=_[_0x7f33('0xd')](config[_0x7f33('0xe')],{'host':_0x7f33('0xf'),'port':0x18eb});var socket=require(_0x7f33('0x10'))(new Redis(config['redis']));require(_0x7f33('0x11'))[_0x7f33('0x12')](socket);function respondWithRpcPromise(_0x3ad35c,_0x401203,_0x13f564){return new BPromise(function(_0x5aa61a,_0x55a2fb){return client['request'](_0x3ad35c,_0x13f564)[_0x7f33('0x13')](function(_0x5e3c8d){logger[_0x7f33('0x14')](_0x7f33('0x15'),_0x401203,'request\x20sent');logger[_0x7f33('0x16')](_0x7f33('0x17'),_0x401203,'request\x20sent',JSON[_0x7f33('0x18')](_0x5e3c8d));if(_0x5e3c8d[_0x7f33('0x19')]){if(_0x5e3c8d[_0x7f33('0x19')][_0x7f33('0x1a')]===0x1f4){logger[_0x7f33('0x19')](_0x7f33('0x15'),_0x401203,_0x5e3c8d[_0x7f33('0x19')][_0x7f33('0x1b')]);return _0x55a2fb(_0x5e3c8d[_0x7f33('0x19')][_0x7f33('0x1b')]);}logger[_0x7f33('0x19')](_0x7f33('0x15'),_0x401203,_0x5e3c8d[_0x7f33('0x19')][_0x7f33('0x1b')]);return _0x5aa61a(_0x5e3c8d[_0x7f33('0x19')][_0x7f33('0x1b')]);}else{logger[_0x7f33('0x14')](_0x7f33('0x15'),_0x401203,'request\x20sent');_0x5aa61a(_0x5e3c8d[_0x7f33('0x1c')]['message']);}})['catch'](function(_0x4b76b3){logger[_0x7f33('0x19')](_0x7f33('0x15'),_0x401203,_0x4b76b3);_0x55a2fb(_0x4b76b3);});});}exports[_0x7f33('0x1d')]=function(_0x42146d){var _0xad6a53=this;return new Promise(function(_0x2f6022,_0x1affbd){return db[_0x7f33('0x1e')][_0x7f33('0x1f')]({'raw':_0x42146d['options']?_0x42146d[_0x7f33('0x20')][_0x7f33('0x21')]===undefined?!![]:![]:!![],'where':_0x42146d['options']?_0x42146d[_0x7f33('0x20')][_0x7f33('0x22')]||null:null,'attributes':_0x42146d[_0x7f33('0x20')]?_0x42146d[_0x7f33('0x20')][_0x7f33('0x23')]||null:null,'limit':_0x42146d[_0x7f33('0x20')]?_0x42146d['options'][_0x7f33('0x24')]||null:null,'include':_0x42146d[_0x7f33('0x20')]?_0x42146d[_0x7f33('0x20')]['include']?_[_0x7f33('0x25')](_0x42146d[_0x7f33('0x20')]['include'],function(_0x23c75a){return{'model':db[_0x23c75a[_0x7f33('0x26')]],'as':_0x23c75a['as'],'attributes':_0x23c75a[_0x7f33('0x23')],'include':_0x23c75a[_0x7f33('0x27')]?_[_0x7f33('0x25')](_0x23c75a[_0x7f33('0x27')],function(_0x52a8ac){return{'model':db[_0x52a8ac[_0x7f33('0x26')]],'as':_0x52a8ac['as'],'attributes':_0x52a8ac[_0x7f33('0x23')],'include':_0x52a8ac[_0x7f33('0x27')]?_[_0x7f33('0x25')](_0x52a8ac[_0x7f33('0x27')],function(_0x4542a8){return{'model':db[_0x4542a8['model']],'as':_0x4542a8['as'],'attributes':_0x4542a8[_0x7f33('0x23')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2cf5d2){logger[_0x7f33('0x14')](_0x7f33('0x1d'),_0x42146d);logger[_0x7f33('0x16')](_0x7f33('0x1d'),_0x42146d,JSON[_0x7f33('0x18')](_0x2cf5d2));_0x2f6022(_0x2cf5d2);})[_0x7f33('0x28')](function(_0x759178){logger['error']('GetVoiceQueue',_0x759178[_0x7f33('0x1b')],_0x42146d);_0x1affbd(_0xad6a53[_0x7f33('0x19')](0x1f4,_0x759178['message']));});});};exports[_0x7f33('0x29')]=function(_0x344108){var _0x2e668a=this;return new Promise(function(_0x4b9ee8,_0x256e5a){return db[_0x7f33('0x1e')][_0x7f33('0x2a')]({'raw':_0x344108[_0x7f33('0x20')]?_0x344108['options']['raw']===undefined?!![]:![]:!![],'where':_0x344108[_0x7f33('0x20')]?_0x344108[_0x7f33('0x20')][_0x7f33('0x22')]||null:null,'attributes':_0x344108[_0x7f33('0x20')]?_0x344108[_0x7f33('0x20')][_0x7f33('0x23')]||null:null,'include':_0x344108[_0x7f33('0x20')]?_0x344108[_0x7f33('0x20')][_0x7f33('0x27')]?_[_0x7f33('0x25')](_0x344108[_0x7f33('0x20')]['include'],function(_0x44bc5c){return{'model':db[_0x44bc5c[_0x7f33('0x26')]],'as':_0x44bc5c['as'],'attributes':_0x44bc5c[_0x7f33('0x23')],'include':_0x44bc5c['include']?_[_0x7f33('0x25')](_0x44bc5c[_0x7f33('0x27')],function(_0x1a736a){return{'model':db[_0x1a736a[_0x7f33('0x26')]],'as':_0x1a736a['as'],'attributes':_0x1a736a[_0x7f33('0x23')],'include':_0x1a736a['include']?_[_0x7f33('0x25')](_0x1a736a[_0x7f33('0x27')],function(_0x28cc19){return{'model':db[_0x28cc19['model']],'as':_0x28cc19['as'],'attributes':_0x28cc19[_0x7f33('0x23')]};}):[]};}):[]};}):[]:[]})[_0x7f33('0x13')](function(_0x551f16){logger['info'](_0x7f33('0x29'),_0x344108);logger['debug'](_0x7f33('0x29'),_0x344108,JSON[_0x7f33('0x18')](_0x551f16));_0x4b9ee8(_0x551f16);})[_0x7f33('0x28')](function(_0xd54ac9){logger[_0x7f33('0x19')]('ShowVoiceQueue',_0xd54ac9[_0x7f33('0x1b')],_0x344108);_0x256e5a(_0x2e668a[_0x7f33('0x19')](0x1f4,_0xd54ac9['message']));});});};