Built motion from commit e02f907f.|2.6.14
[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 _0x1d3c=['socket.io-emitter','request','then','VoiceQueue,\x20%s,\x20%s','request\x20sent','error','code','message','info','catch','GetVoiceQueue','findAll','options','raw','limit','include','model','map','attributes','stringify','ShowVoiceQueue','where','debug','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','defaults','localhost'];(function(_0x26f639,_0x1bcf59){var _0x405890=function(_0x4b9538){while(--_0x4b9538){_0x26f639['push'](_0x26f639['shift']());}};_0x405890(++_0x1bcf59);}(_0x1d3c,0xd5));var _0xc1d3=function(_0x3005d5,_0xf588c7){_0x3005d5=_0x3005d5-0x0;var _0x547c7e=_0x1d3c[_0x3005d5];return _0x547c7e;};'use strict';var _=require(_0xc1d3('0x0'));var util=require(_0xc1d3('0x1'));var moment=require(_0xc1d3('0x2'));var BPromise=require(_0xc1d3('0x3'));var rs=require(_0xc1d3('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc1d3('0x5'))['db'];var utils=require(_0xc1d3('0x6'));var logger=require(_0xc1d3('0x7'))(_0xc1d3('0x8'));var config=require(_0xc1d3('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xc1d3('0xa')][_0xc1d3('0xb')]({'port':0x232a});config[_0xc1d3('0xc')]=_[_0xc1d3('0xd')](config['redis'],{'host':_0xc1d3('0xe'),'port':0x18eb});var socket=require(_0xc1d3('0xf'))(new Redis(config['redis']));require('./voiceQueue.socket')['register'](socket);function respondWithRpcPromise(_0x9e694e,_0x16764f,_0x2f2079){return new BPromise(function(_0x2da452,_0x28cd79){return client[_0xc1d3('0x10')](_0x9e694e,_0x2f2079)[_0xc1d3('0x11')](function(_0x3cc2a4){logger['info'](_0xc1d3('0x12'),_0x16764f,_0xc1d3('0x13'));logger['debug']('VoiceQueue,\x20%s,\x20%s,\x20%s',_0x16764f,_0xc1d3('0x13'),JSON['stringify'](_0x3cc2a4));if(_0x3cc2a4['error']){if(_0x3cc2a4[_0xc1d3('0x14')][_0xc1d3('0x15')]===0x1f4){logger[_0xc1d3('0x14')](_0xc1d3('0x12'),_0x16764f,_0x3cc2a4[_0xc1d3('0x14')][_0xc1d3('0x16')]);return _0x28cd79(_0x3cc2a4['error'][_0xc1d3('0x16')]);}logger[_0xc1d3('0x14')](_0xc1d3('0x12'),_0x16764f,_0x3cc2a4[_0xc1d3('0x14')][_0xc1d3('0x16')]);return _0x2da452(_0x3cc2a4[_0xc1d3('0x14')][_0xc1d3('0x16')]);}else{logger[_0xc1d3('0x17')]('VoiceQueue,\x20%s,\x20%s',_0x16764f,_0xc1d3('0x13'));_0x2da452(_0x3cc2a4['result'][_0xc1d3('0x16')]);}})[_0xc1d3('0x18')](function(_0x2da940){logger[_0xc1d3('0x14')](_0xc1d3('0x12'),_0x16764f,_0x2da940);_0x28cd79(_0x2da940);});});}exports[_0xc1d3('0x19')]=function(_0x279edc){var _0x27fb7f=this;return new Promise(function(_0x5e4b43,_0x1dc10a){return db['VoiceQueue'][_0xc1d3('0x1a')]({'raw':_0x279edc[_0xc1d3('0x1b')]?_0x279edc[_0xc1d3('0x1b')][_0xc1d3('0x1c')]===undefined?!![]:![]:!![],'where':_0x279edc[_0xc1d3('0x1b')]?_0x279edc[_0xc1d3('0x1b')]['where']||null:null,'attributes':_0x279edc['options']?_0x279edc[_0xc1d3('0x1b')]['attributes']||null:null,'limit':_0x279edc['options']?_0x279edc[_0xc1d3('0x1b')][_0xc1d3('0x1d')]||null:null,'include':_0x279edc[_0xc1d3('0x1b')]?_0x279edc[_0xc1d3('0x1b')][_0xc1d3('0x1e')]?_['map'](_0x279edc[_0xc1d3('0x1b')]['include'],function(_0x2a65b0){return{'model':db[_0x2a65b0[_0xc1d3('0x1f')]],'as':_0x2a65b0['as'],'attributes':_0x2a65b0['attributes'],'include':_0x2a65b0[_0xc1d3('0x1e')]?_[_0xc1d3('0x20')](_0x2a65b0[_0xc1d3('0x1e')],function(_0x3bcb77){return{'model':db[_0x3bcb77['model']],'as':_0x3bcb77['as'],'attributes':_0x3bcb77[_0xc1d3('0x21')],'include':_0x3bcb77[_0xc1d3('0x1e')]?_[_0xc1d3('0x20')](_0x3bcb77[_0xc1d3('0x1e')],function(_0x23f3b0){return{'model':db[_0x23f3b0[_0xc1d3('0x1f')]],'as':_0x23f3b0['as'],'attributes':_0x23f3b0[_0xc1d3('0x21')]};}):[]};}):[]};}):[]:[]})[_0xc1d3('0x11')](function(_0x558eb4){logger[_0xc1d3('0x17')](_0xc1d3('0x19'),_0x279edc);logger['debug'](_0xc1d3('0x19'),_0x279edc,JSON[_0xc1d3('0x22')](_0x558eb4));_0x5e4b43(_0x558eb4);})['catch'](function(_0x3d12eb){logger[_0xc1d3('0x14')]('GetVoiceQueue',_0x3d12eb['message'],_0x279edc);_0x1dc10a(_0x27fb7f['error'](0x1f4,_0x3d12eb[_0xc1d3('0x16')]));});});};exports[_0xc1d3('0x23')]=function(_0x3462ae){var _0x20944d=this;return new Promise(function(_0x36ef72,_0x23bc26){return db['VoiceQueue']['find']({'raw':_0x3462ae[_0xc1d3('0x1b')]?_0x3462ae[_0xc1d3('0x1b')][_0xc1d3('0x1c')]===undefined?!![]:![]:!![],'where':_0x3462ae[_0xc1d3('0x1b')]?_0x3462ae[_0xc1d3('0x1b')][_0xc1d3('0x24')]||null:null,'attributes':_0x3462ae[_0xc1d3('0x1b')]?_0x3462ae[_0xc1d3('0x1b')][_0xc1d3('0x21')]||null:null,'include':_0x3462ae[_0xc1d3('0x1b')]?_0x3462ae[_0xc1d3('0x1b')][_0xc1d3('0x1e')]?_['map'](_0x3462ae[_0xc1d3('0x1b')][_0xc1d3('0x1e')],function(_0x15f186){return{'model':db[_0x15f186[_0xc1d3('0x1f')]],'as':_0x15f186['as'],'attributes':_0x15f186['attributes'],'include':_0x15f186[_0xc1d3('0x1e')]?_[_0xc1d3('0x20')](_0x15f186[_0xc1d3('0x1e')],function(_0x1fe7a2){return{'model':db[_0x1fe7a2[_0xc1d3('0x1f')]],'as':_0x1fe7a2['as'],'attributes':_0x1fe7a2['attributes'],'include':_0x1fe7a2['include']?_[_0xc1d3('0x20')](_0x1fe7a2[_0xc1d3('0x1e')],function(_0x35d22d){return{'model':db[_0x35d22d[_0xc1d3('0x1f')]],'as':_0x35d22d['as'],'attributes':_0x35d22d['attributes']};}):[]};}):[]};}):[]:[]})[_0xc1d3('0x11')](function(_0x37db91){logger[_0xc1d3('0x17')](_0xc1d3('0x23'),_0x3462ae);logger[_0xc1d3('0x25')](_0xc1d3('0x23'),_0x3462ae,JSON[_0xc1d3('0x22')](_0x37db91));_0x36ef72(_0x37db91);})[_0xc1d3('0x18')](function(_0x14cc15){logger[_0xc1d3('0x14')](_0xc1d3('0x23'),_0x14cc15[_0xc1d3('0x16')],_0x3462ae);_0x23bc26(_0x20944d[_0xc1d3('0x14')](0x1f4,_0x14cc15[_0xc1d3('0x16')]));});});};