Built motion from commit (unavailable).|2.6.0
[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 _0x28bf=['../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','register','request','then','VoiceQueue,\x20%s,\x20%s','request\x20sent','VoiceQueue,\x20%s,\x20%s,\x20%s','error','code','message','info','catch','GetVoiceQueue','VoiceQueue','findAll','options','raw','attributes','include','map','model','debug','stringify','ShowVoiceQueue','find','where','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x3b272a,_0x4ab1e8){var _0x74b911=function(_0xeafcb6){while(--_0xeafcb6){_0x3b272a['push'](_0x3b272a['shift']());}};_0x74b911(++_0x4ab1e8);}(_0x28bf,0xc1));var _0xf28b=function(_0x1c9e96,_0x2eb6ec){_0x1c9e96=_0x1c9e96-0x0;var _0x4f6754=_0x28bf[_0x1c9e96];return _0x4f6754;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xf28b('0x0'));var BPromise=require('bluebird');var rs=require(_0xf28b('0x1'));var fs=require('fs');var Redis=require(_0xf28b('0x2'));var db=require(_0xf28b('0x3'))['db'];var utils=require(_0xf28b('0x4'));var logger=require(_0xf28b('0x5'))(_0xf28b('0x6'));var config=require(_0xf28b('0x7'));var jayson=require(_0xf28b('0x8'));var client=jayson[_0xf28b('0x9')][_0xf28b('0xa')]({'port':0x232a});config[_0xf28b('0xb')]=_[_0xf28b('0xc')](config['redis'],{'host':_0xf28b('0xd'),'port':0x18eb});var socket=require(_0xf28b('0xe'))(new Redis(config[_0xf28b('0xb')]));require('./voiceQueue.socket')[_0xf28b('0xf')](socket);function respondWithRpcPromise(_0x21decd,_0x3fb087,_0x51a985){return new BPromise(function(_0x5c46f7,_0x5306c8){return client[_0xf28b('0x10')](_0x21decd,_0x51a985)[_0xf28b('0x11')](function(_0x228e37){logger['info'](_0xf28b('0x12'),_0x3fb087,_0xf28b('0x13'));logger['debug'](_0xf28b('0x14'),_0x3fb087,_0xf28b('0x13'),JSON['stringify'](_0x228e37));if(_0x228e37[_0xf28b('0x15')]){if(_0x228e37[_0xf28b('0x15')][_0xf28b('0x16')]===0x1f4){logger[_0xf28b('0x15')]('VoiceQueue,\x20%s,\x20%s',_0x3fb087,_0x228e37[_0xf28b('0x15')][_0xf28b('0x17')]);return _0x5306c8(_0x228e37[_0xf28b('0x15')][_0xf28b('0x17')]);}logger[_0xf28b('0x15')](_0xf28b('0x12'),_0x3fb087,_0x228e37[_0xf28b('0x15')][_0xf28b('0x17')]);return _0x5c46f7(_0x228e37['error'][_0xf28b('0x17')]);}else{logger[_0xf28b('0x18')](_0xf28b('0x12'),_0x3fb087,'request\x20sent');_0x5c46f7(_0x228e37['result'][_0xf28b('0x17')]);}})[_0xf28b('0x19')](function(_0x28a9bc){logger[_0xf28b('0x15')](_0xf28b('0x12'),_0x3fb087,_0x28a9bc);_0x5306c8(_0x28a9bc);});});}exports[_0xf28b('0x1a')]=function(_0x4776bb){var _0x220b9c=this;return new Promise(function(_0x39d9f1,_0x4f48db){return db[_0xf28b('0x1b')][_0xf28b('0x1c')]({'raw':_0x4776bb[_0xf28b('0x1d')]?_0x4776bb[_0xf28b('0x1d')][_0xf28b('0x1e')]===undefined?!![]:![]:!![],'where':_0x4776bb[_0xf28b('0x1d')]?_0x4776bb['options']['where']||null:null,'attributes':_0x4776bb['options']?_0x4776bb[_0xf28b('0x1d')][_0xf28b('0x1f')]||null:null,'limit':_0x4776bb[_0xf28b('0x1d')]?_0x4776bb[_0xf28b('0x1d')]['limit']||null:null,'include':_0x4776bb[_0xf28b('0x1d')]?_0x4776bb[_0xf28b('0x1d')][_0xf28b('0x20')]?_[_0xf28b('0x21')](_0x4776bb[_0xf28b('0x1d')][_0xf28b('0x20')],function(_0x3c6966){return{'model':db[_0x3c6966[_0xf28b('0x22')]],'as':_0x3c6966['as'],'attributes':_0x3c6966[_0xf28b('0x1f')],'include':_0x3c6966[_0xf28b('0x20')]?_[_0xf28b('0x21')](_0x3c6966[_0xf28b('0x20')],function(_0x31f874){return{'model':db[_0x31f874[_0xf28b('0x22')]],'as':_0x31f874['as'],'attributes':_0x31f874[_0xf28b('0x1f')],'include':_0x31f874[_0xf28b('0x20')]?_[_0xf28b('0x21')](_0x31f874['include'],function(_0x604ceb){return{'model':db[_0x604ceb[_0xf28b('0x22')]],'as':_0x604ceb['as'],'attributes':_0x604ceb[_0xf28b('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xf28b('0x11')](function(_0xf4c8ec){logger[_0xf28b('0x18')](_0xf28b('0x1a'),_0x4776bb);logger[_0xf28b('0x23')]('GetVoiceQueue',_0x4776bb,JSON[_0xf28b('0x24')](_0xf4c8ec));_0x39d9f1(_0xf4c8ec);})[_0xf28b('0x19')](function(_0x48fc22){logger[_0xf28b('0x15')]('GetVoiceQueue',_0x48fc22['message'],_0x4776bb);_0x4f48db(_0x220b9c['error'](0x1f4,_0x48fc22['message']));});});};exports[_0xf28b('0x25')]=function(_0x4e6859){var _0x10981b=this;return new Promise(function(_0x3c559e,_0x4ecb1c){return db['VoiceQueue'][_0xf28b('0x26')]({'raw':_0x4e6859[_0xf28b('0x1d')]?_0x4e6859['options'][_0xf28b('0x1e')]===undefined?!![]:![]:!![],'where':_0x4e6859[_0xf28b('0x1d')]?_0x4e6859[_0xf28b('0x1d')][_0xf28b('0x27')]||null:null,'attributes':_0x4e6859['options']?_0x4e6859[_0xf28b('0x1d')]['attributes']||null:null,'include':_0x4e6859[_0xf28b('0x1d')]?_0x4e6859[_0xf28b('0x1d')][_0xf28b('0x20')]?_['map'](_0x4e6859['options'][_0xf28b('0x20')],function(_0xe91c1f){return{'model':db[_0xe91c1f[_0xf28b('0x22')]],'as':_0xe91c1f['as'],'attributes':_0xe91c1f[_0xf28b('0x1f')],'include':_0xe91c1f[_0xf28b('0x20')]?_[_0xf28b('0x21')](_0xe91c1f[_0xf28b('0x20')],function(_0x477a63){return{'model':db[_0x477a63[_0xf28b('0x22')]],'as':_0x477a63['as'],'attributes':_0x477a63['attributes'],'include':_0x477a63[_0xf28b('0x20')]?_[_0xf28b('0x21')](_0x477a63[_0xf28b('0x20')],function(_0x536c2c){return{'model':db[_0x536c2c[_0xf28b('0x22')]],'as':_0x536c2c['as'],'attributes':_0x536c2c[_0xf28b('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xf28b('0x11')](function(_0x45f801){logger[_0xf28b('0x18')](_0xf28b('0x25'),_0x4e6859);logger[_0xf28b('0x23')](_0xf28b('0x25'),_0x4e6859,JSON[_0xf28b('0x24')](_0x45f801));_0x3c559e(_0x45f801);})['catch'](function(_0xc9ce7a){logger[_0xf28b('0x15')](_0xf28b('0x25'),_0xc9ce7a['message'],_0x4e6859);_0x4ecb1c(_0x10981b[_0xf28b('0x15')](0x1f4,_0xc9ce7a['message']));});});};