Built motion from commit (unavailable).|2.5.12
[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 _0xe5c9=['./voiceQueue.socket','register','request','then','info','VoiceQueue,\x20%s,\x20%s','request\x20sent','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetVoiceQueue','VoiceQueue','findAll','options','where','attributes','limit','include','map','model','ShowVoiceQueue','find','raw','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter'];(function(_0x353e4b,_0x54d00d){var _0x51c99f=function(_0x100632){while(--_0x100632){_0x353e4b['push'](_0x353e4b['shift']());}};_0x51c99f(++_0x54d00d);}(_0xe5c9,0x1a8));var _0x9e5c=function(_0xf77119,_0x5b8440){_0xf77119=_0xf77119-0x0;var _0x12950b=_0xe5c9[_0xf77119];return _0x12950b;};'use strict';var _=require(_0x9e5c('0x0'));var util=require('util');var moment=require(_0x9e5c('0x1'));var BPromise=require(_0x9e5c('0x2'));var rs=require(_0x9e5c('0x3'));var fs=require('fs');var Redis=require(_0x9e5c('0x4'));var db=require(_0x9e5c('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x9e5c('0x6'))(_0x9e5c('0x7'));var config=require(_0x9e5c('0x8'));var jayson=require(_0x9e5c('0x9'));var client=jayson[_0x9e5c('0xa')][_0x9e5c('0xb')]({'port':0x232a});config[_0x9e5c('0xc')]=_[_0x9e5c('0xd')](config['redis'],{'host':_0x9e5c('0xe'),'port':0x18eb});var socket=require(_0x9e5c('0xf'))(new Redis(config[_0x9e5c('0xc')]));require(_0x9e5c('0x10'))[_0x9e5c('0x11')](socket);function respondWithRpcPromise(_0x24e88,_0x8aeee9,_0x17b7f4){return new BPromise(function(_0x496e91,_0x217eea){return client[_0x9e5c('0x12')](_0x24e88,_0x17b7f4)[_0x9e5c('0x13')](function(_0x21f27a){logger[_0x9e5c('0x14')](_0x9e5c('0x15'),_0x8aeee9,_0x9e5c('0x16'));logger[_0x9e5c('0x17')](_0x9e5c('0x18'),_0x8aeee9,_0x9e5c('0x16'),JSON[_0x9e5c('0x19')](_0x21f27a));if(_0x21f27a[_0x9e5c('0x1a')]){if(_0x21f27a[_0x9e5c('0x1a')][_0x9e5c('0x1b')]===0x1f4){logger[_0x9e5c('0x1a')](_0x9e5c('0x15'),_0x8aeee9,_0x21f27a[_0x9e5c('0x1a')][_0x9e5c('0x1c')]);return _0x217eea(_0x21f27a['error'][_0x9e5c('0x1c')]);}logger[_0x9e5c('0x1a')](_0x9e5c('0x15'),_0x8aeee9,_0x21f27a['error']['message']);return _0x496e91(_0x21f27a[_0x9e5c('0x1a')]['message']);}else{logger['info']('VoiceQueue,\x20%s,\x20%s',_0x8aeee9,_0x9e5c('0x16'));_0x496e91(_0x21f27a[_0x9e5c('0x1d')]['message']);}})[_0x9e5c('0x1e')](function(_0x3676bc){logger[_0x9e5c('0x1a')](_0x9e5c('0x15'),_0x8aeee9,_0x3676bc);_0x217eea(_0x3676bc);});});}exports[_0x9e5c('0x1f')]=function(_0x4f6569){var _0x489e00=this;return new Promise(function(_0x190c3a,_0x4520b7){return db[_0x9e5c('0x20')][_0x9e5c('0x21')]({'raw':_0x4f6569[_0x9e5c('0x22')]?_0x4f6569[_0x9e5c('0x22')]['raw']===undefined?!![]:![]:!![],'where':_0x4f6569['options']?_0x4f6569[_0x9e5c('0x22')][_0x9e5c('0x23')]||null:null,'attributes':_0x4f6569['options']?_0x4f6569[_0x9e5c('0x22')][_0x9e5c('0x24')]||null:null,'limit':_0x4f6569[_0x9e5c('0x22')]?_0x4f6569[_0x9e5c('0x22')][_0x9e5c('0x25')]||null:null,'include':_0x4f6569[_0x9e5c('0x22')]?_0x4f6569[_0x9e5c('0x22')][_0x9e5c('0x26')]?_[_0x9e5c('0x27')](_0x4f6569['options'][_0x9e5c('0x26')],function(_0x547bb0){return{'model':db[_0x547bb0[_0x9e5c('0x28')]],'as':_0x547bb0['as'],'attributes':_0x547bb0[_0x9e5c('0x24')],'include':_0x547bb0[_0x9e5c('0x26')]?_['map'](_0x547bb0['include'],function(_0x26e024){return{'model':db[_0x26e024['model']],'as':_0x26e024['as'],'attributes':_0x26e024[_0x9e5c('0x24')],'include':_0x26e024[_0x9e5c('0x26')]?_[_0x9e5c('0x27')](_0x26e024[_0x9e5c('0x26')],function(_0x228d96){return{'model':db[_0x228d96['model']],'as':_0x228d96['as'],'attributes':_0x228d96[_0x9e5c('0x24')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x194c0e){logger[_0x9e5c('0x14')](_0x9e5c('0x1f'),_0x4f6569);logger[_0x9e5c('0x17')](_0x9e5c('0x1f'),_0x4f6569,JSON[_0x9e5c('0x19')](_0x194c0e));_0x190c3a(_0x194c0e);})[_0x9e5c('0x1e')](function(_0x5e482e){logger[_0x9e5c('0x1a')](_0x9e5c('0x1f'),_0x5e482e['message'],_0x4f6569);_0x4520b7(_0x489e00['error'](0x1f4,_0x5e482e[_0x9e5c('0x1c')]));});});};exports[_0x9e5c('0x29')]=function(_0x1d43c7){var _0x1ece92=this;return new Promise(function(_0x1f5cae,_0xf92422){return db[_0x9e5c('0x20')][_0x9e5c('0x2a')]({'raw':_0x1d43c7[_0x9e5c('0x22')]?_0x1d43c7['options'][_0x9e5c('0x2b')]===undefined?!![]:![]:!![],'where':_0x1d43c7[_0x9e5c('0x22')]?_0x1d43c7['options'][_0x9e5c('0x23')]||null:null,'attributes':_0x1d43c7[_0x9e5c('0x22')]?_0x1d43c7[_0x9e5c('0x22')][_0x9e5c('0x24')]||null:null,'include':_0x1d43c7['options']?_0x1d43c7['options'][_0x9e5c('0x26')]?_['map'](_0x1d43c7[_0x9e5c('0x22')][_0x9e5c('0x26')],function(_0x484eaa){return{'model':db[_0x484eaa[_0x9e5c('0x28')]],'as':_0x484eaa['as'],'attributes':_0x484eaa[_0x9e5c('0x24')],'include':_0x484eaa[_0x9e5c('0x26')]?_['map'](_0x484eaa[_0x9e5c('0x26')],function(_0x2c84e7){return{'model':db[_0x2c84e7[_0x9e5c('0x28')]],'as':_0x2c84e7['as'],'attributes':_0x2c84e7[_0x9e5c('0x24')],'include':_0x2c84e7[_0x9e5c('0x26')]?_[_0x9e5c('0x27')](_0x2c84e7[_0x9e5c('0x26')],function(_0x5e280b){return{'model':db[_0x5e280b[_0x9e5c('0x28')]],'as':_0x5e280b['as'],'attributes':_0x5e280b[_0x9e5c('0x24')]};}):[]};}):[]};}):[]:[]})[_0x9e5c('0x13')](function(_0x215663){logger[_0x9e5c('0x14')](_0x9e5c('0x29'),_0x1d43c7);logger[_0x9e5c('0x17')]('ShowVoiceQueue',_0x1d43c7,JSON[_0x9e5c('0x19')](_0x215663));_0x1f5cae(_0x215663);})[_0x9e5c('0x1e')](function(_0x53602c){logger['error'](_0x9e5c('0x29'),_0x53602c[_0x9e5c('0x1c')],_0x1d43c7);_0xf92422(_0x1ece92['error'](0x1f4,_0x53602c[_0x9e5c('0x1c')]));});});};