Built motion from commit 00bf23f6.|2.6.16
[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 _0x746f=['VoiceQueue','findAll','options','raw','attributes','include','map','model','find','ShowVoiceQueue','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','localhost','socket.io-emitter','./voiceQueue.socket','request','then','info','VoiceQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','catch','GetVoiceQueue'];(function(_0x1d74d3,_0x506eda){var _0x5b02e9=function(_0x5ceb84){while(--_0x5ceb84){_0x1d74d3['push'](_0x1d74d3['shift']());}};_0x5b02e9(++_0x506eda);}(_0x746f,0x7c));var _0xf746=function(_0x5c6f45,_0x4d9473){_0x5c6f45=_0x5c6f45-0x0;var _0x59e9e7=_0x746f[_0x5c6f45];return _0x59e9e7;};'use strict';var _=require(_0xf746('0x0'));var util=require(_0xf746('0x1'));var moment=require('moment');var BPromise=require(_0xf746('0x2'));var rs=require(_0xf746('0x3'));var fs=require('fs');var Redis=require(_0xf746('0x4'));var db=require(_0xf746('0x5'))['db'];var utils=require(_0xf746('0x6'));var logger=require(_0xf746('0x7'))(_0xf746('0x8'));var config=require(_0xf746('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xf746('0xa')][_0xf746('0xb')]({'port':0x232a});config[_0xf746('0xc')]=_['defaults'](config[_0xf746('0xc')],{'host':_0xf746('0xd'),'port':0x18eb});var socket=require(_0xf746('0xe'))(new Redis(config[_0xf746('0xc')]));require(_0xf746('0xf'))['register'](socket);function respondWithRpcPromise(_0x1d0058,_0x90eab1,_0x2df1ce){return new BPromise(function(_0x1742f6,_0x791143){return client[_0xf746('0x10')](_0x1d0058,_0x2df1ce)[_0xf746('0x11')](function(_0x3a2381){logger[_0xf746('0x12')](_0xf746('0x13'),_0x90eab1,_0xf746('0x14'));logger[_0xf746('0x15')]('VoiceQueue,\x20%s,\x20%s,\x20%s',_0x90eab1,_0xf746('0x14'),JSON[_0xf746('0x16')](_0x3a2381));if(_0x3a2381[_0xf746('0x17')]){if(_0x3a2381[_0xf746('0x17')][_0xf746('0x18')]===0x1f4){logger[_0xf746('0x17')](_0xf746('0x13'),_0x90eab1,_0x3a2381[_0xf746('0x17')][_0xf746('0x19')]);return _0x791143(_0x3a2381['error'][_0xf746('0x19')]);}logger[_0xf746('0x17')](_0xf746('0x13'),_0x90eab1,_0x3a2381[_0xf746('0x17')][_0xf746('0x19')]);return _0x1742f6(_0x3a2381['error'][_0xf746('0x19')]);}else{logger[_0xf746('0x12')](_0xf746('0x13'),_0x90eab1,_0xf746('0x14'));_0x1742f6(_0x3a2381['result'][_0xf746('0x19')]);}})[_0xf746('0x1a')](function(_0x612640){logger[_0xf746('0x17')](_0xf746('0x13'),_0x90eab1,_0x612640);_0x791143(_0x612640);});});}exports[_0xf746('0x1b')]=function(_0x5b539f){var _0x3976db=this;return new Promise(function(_0x3cf237,_0x55a4b9){return db[_0xf746('0x1c')][_0xf746('0x1d')]({'raw':_0x5b539f['options']?_0x5b539f[_0xf746('0x1e')][_0xf746('0x1f')]===undefined?!![]:![]:!![],'where':_0x5b539f['options']?_0x5b539f[_0xf746('0x1e')]['where']||null:null,'attributes':_0x5b539f[_0xf746('0x1e')]?_0x5b539f[_0xf746('0x1e')][_0xf746('0x20')]||null:null,'limit':_0x5b539f['options']?_0x5b539f[_0xf746('0x1e')]['limit']||null:null,'include':_0x5b539f['options']?_0x5b539f[_0xf746('0x1e')][_0xf746('0x21')]?_[_0xf746('0x22')](_0x5b539f['options'][_0xf746('0x21')],function(_0x5f033f){return{'model':db[_0x5f033f[_0xf746('0x23')]],'as':_0x5f033f['as'],'attributes':_0x5f033f[_0xf746('0x20')],'include':_0x5f033f[_0xf746('0x21')]?_[_0xf746('0x22')](_0x5f033f[_0xf746('0x21')],function(_0x465bb0){return{'model':db[_0x465bb0['model']],'as':_0x465bb0['as'],'attributes':_0x465bb0[_0xf746('0x20')],'include':_0x465bb0[_0xf746('0x21')]?_['map'](_0x465bb0[_0xf746('0x21')],function(_0x2cd6f7){return{'model':db[_0x2cd6f7[_0xf746('0x23')]],'as':_0x2cd6f7['as'],'attributes':_0x2cd6f7['attributes']};}):[]};}):[]};}):[]:[]})[_0xf746('0x11')](function(_0x334b29){logger['info'](_0xf746('0x1b'),_0x5b539f);logger[_0xf746('0x15')](_0xf746('0x1b'),_0x5b539f,JSON['stringify'](_0x334b29));_0x3cf237(_0x334b29);})[_0xf746('0x1a')](function(_0x1daa8b){logger['error'](_0xf746('0x1b'),_0x1daa8b['message'],_0x5b539f);_0x55a4b9(_0x3976db[_0xf746('0x17')](0x1f4,_0x1daa8b[_0xf746('0x19')]));});});};exports['ShowVoiceQueue']=function(_0x4b57ce){var _0x28b86e=this;return new Promise(function(_0x2ddaf6,_0x14c533){return db[_0xf746('0x1c')][_0xf746('0x24')]({'raw':_0x4b57ce[_0xf746('0x1e')]?_0x4b57ce[_0xf746('0x1e')][_0xf746('0x1f')]===undefined?!![]:![]:!![],'where':_0x4b57ce['options']?_0x4b57ce[_0xf746('0x1e')]['where']||null:null,'attributes':_0x4b57ce['options']?_0x4b57ce[_0xf746('0x1e')][_0xf746('0x20')]||null:null,'include':_0x4b57ce[_0xf746('0x1e')]?_0x4b57ce[_0xf746('0x1e')][_0xf746('0x21')]?_[_0xf746('0x22')](_0x4b57ce[_0xf746('0x1e')][_0xf746('0x21')],function(_0x4cc834){return{'model':db[_0x4cc834[_0xf746('0x23')]],'as':_0x4cc834['as'],'attributes':_0x4cc834[_0xf746('0x20')],'include':_0x4cc834[_0xf746('0x21')]?_['map'](_0x4cc834['include'],function(_0x2e0e38){return{'model':db[_0x2e0e38[_0xf746('0x23')]],'as':_0x2e0e38['as'],'attributes':_0x2e0e38[_0xf746('0x20')],'include':_0x2e0e38[_0xf746('0x21')]?_[_0xf746('0x22')](_0x2e0e38['include'],function(_0x3ca8a9){return{'model':db[_0x3ca8a9['model']],'as':_0x3ca8a9['as'],'attributes':_0x3ca8a9[_0xf746('0x20')]};}):[]};}):[]};}):[]:[]})[_0xf746('0x11')](function(_0x3c0ac3){logger['info'](_0xf746('0x25'),_0x4b57ce);logger[_0xf746('0x15')](_0xf746('0x25'),_0x4b57ce,JSON['stringify'](_0x3c0ac3));_0x2ddaf6(_0x3c0ac3);})[_0xf746('0x1a')](function(_0x23cabd){logger[_0xf746('0x17')]('ShowVoiceQueue',_0x23cabd['message'],_0x4b57ce);_0x14c533(_0x28b86e[_0xf746('0x17')](0x1f4,_0x23cabd[_0xf746('0x19')]));});});};