Built motion from commit 3061e47c.|2.6.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 _0xbf3b=['include','map','model','ShowVoiceQueue','find','raw','then','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','redis','defaults','localhost','./voiceQueue.socket','request','VoiceQueue,\x20%s,\x20%s','request\x20sent','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','catch','GetVoiceQueue','VoiceQueue','options','where','attributes','limit'];(function(_0x178a01,_0x23db05){var _0x3aaecf=function(_0x571e0d){while(--_0x571e0d){_0x178a01['push'](_0x178a01['shift']());}};_0x3aaecf(++_0x23db05);}(_0xbf3b,0x1cf));var _0xbbf3=function(_0x543c3c,_0x308616){_0x543c3c=_0x543c3c-0x0;var _0x1cbd3b=_0xbf3b[_0x543c3c];return _0x1cbd3b;};'use strict';var _=require('lodash');var util=require(_0xbbf3('0x0'));var moment=require(_0xbbf3('0x1'));var BPromise=require(_0xbbf3('0x2'));var rs=require(_0xbbf3('0x3'));var fs=require('fs');var Redis=require(_0xbbf3('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xbbf3('0x5'));var logger=require(_0xbbf3('0x6'))('rpc');var config=require(_0xbbf3('0x7'));var jayson=require(_0xbbf3('0x8'));var client=jayson['client'][_0xbbf3('0x9')]({'port':0x232a});config[_0xbbf3('0xa')]=_[_0xbbf3('0xb')](config[_0xbbf3('0xa')],{'host':_0xbbf3('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xbbf3('0xa')]));require(_0xbbf3('0xd'))['register'](socket);function respondWithRpcPromise(_0x3ae366,_0x2a68e5,_0x125eb4){return new BPromise(function(_0x36970c,_0x3ae9f7){return client[_0xbbf3('0xe')](_0x3ae366,_0x125eb4)['then'](function(_0x427560){logger['info'](_0xbbf3('0xf'),_0x2a68e5,_0xbbf3('0x10'));logger[_0xbbf3('0x11')](_0xbbf3('0x12'),_0x2a68e5,'request\x20sent',JSON[_0xbbf3('0x13')](_0x427560));if(_0x427560['error']){if(_0x427560[_0xbbf3('0x14')]['code']===0x1f4){logger[_0xbbf3('0x14')](_0xbbf3('0xf'),_0x2a68e5,_0x427560[_0xbbf3('0x14')]['message']);return _0x3ae9f7(_0x427560[_0xbbf3('0x14')][_0xbbf3('0x15')]);}logger['error'](_0xbbf3('0xf'),_0x2a68e5,_0x427560[_0xbbf3('0x14')][_0xbbf3('0x15')]);return _0x36970c(_0x427560[_0xbbf3('0x14')]['message']);}else{logger[_0xbbf3('0x16')]('VoiceQueue,\x20%s,\x20%s',_0x2a68e5,_0xbbf3('0x10'));_0x36970c(_0x427560[_0xbbf3('0x17')][_0xbbf3('0x15')]);}})[_0xbbf3('0x18')](function(_0x12f4f2){logger[_0xbbf3('0x14')](_0xbbf3('0xf'),_0x2a68e5,_0x12f4f2);_0x3ae9f7(_0x12f4f2);});});}exports[_0xbbf3('0x19')]=function(_0x5c33b8){var _0x5afa8c=this;return new Promise(function(_0x3a315a,_0x5df94c){return db[_0xbbf3('0x1a')]['findAll']({'raw':_0x5c33b8[_0xbbf3('0x1b')]?_0x5c33b8[_0xbbf3('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x5c33b8[_0xbbf3('0x1b')]?_0x5c33b8[_0xbbf3('0x1b')][_0xbbf3('0x1c')]||null:null,'attributes':_0x5c33b8['options']?_0x5c33b8['options'][_0xbbf3('0x1d')]||null:null,'limit':_0x5c33b8[_0xbbf3('0x1b')]?_0x5c33b8[_0xbbf3('0x1b')][_0xbbf3('0x1e')]||null:null,'include':_0x5c33b8[_0xbbf3('0x1b')]?_0x5c33b8[_0xbbf3('0x1b')][_0xbbf3('0x1f')]?_[_0xbbf3('0x20')](_0x5c33b8[_0xbbf3('0x1b')]['include'],function(_0x490d8c){return{'model':db[_0x490d8c[_0xbbf3('0x21')]],'as':_0x490d8c['as'],'attributes':_0x490d8c['attributes'],'include':_0x490d8c[_0xbbf3('0x1f')]?_[_0xbbf3('0x20')](_0x490d8c[_0xbbf3('0x1f')],function(_0x479ee9){return{'model':db[_0x479ee9[_0xbbf3('0x21')]],'as':_0x479ee9['as'],'attributes':_0x479ee9['attributes'],'include':_0x479ee9[_0xbbf3('0x1f')]?_[_0xbbf3('0x20')](_0x479ee9[_0xbbf3('0x1f')],function(_0x1513db){return{'model':db[_0x1513db[_0xbbf3('0x21')]],'as':_0x1513db['as'],'attributes':_0x1513db[_0xbbf3('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x20e7ee){logger[_0xbbf3('0x16')]('GetVoiceQueue',_0x5c33b8);logger[_0xbbf3('0x11')]('GetVoiceQueue',_0x5c33b8,JSON[_0xbbf3('0x13')](_0x20e7ee));_0x3a315a(_0x20e7ee);})['catch'](function(_0x39ff8c){logger['error'](_0xbbf3('0x19'),_0x39ff8c[_0xbbf3('0x15')],_0x5c33b8);_0x5df94c(_0x5afa8c[_0xbbf3('0x14')](0x1f4,_0x39ff8c['message']));});});};exports[_0xbbf3('0x22')]=function(_0x125cdc){var _0x354533=this;return new Promise(function(_0x53e6c0,_0x4f2ad2){return db[_0xbbf3('0x1a')][_0xbbf3('0x23')]({'raw':_0x125cdc[_0xbbf3('0x1b')]?_0x125cdc[_0xbbf3('0x1b')][_0xbbf3('0x24')]===undefined?!![]:![]:!![],'where':_0x125cdc[_0xbbf3('0x1b')]?_0x125cdc[_0xbbf3('0x1b')]['where']||null:null,'attributes':_0x125cdc[_0xbbf3('0x1b')]?_0x125cdc[_0xbbf3('0x1b')][_0xbbf3('0x1d')]||null:null,'include':_0x125cdc['options']?_0x125cdc[_0xbbf3('0x1b')][_0xbbf3('0x1f')]?_['map'](_0x125cdc['options'][_0xbbf3('0x1f')],function(_0x299595){return{'model':db[_0x299595['model']],'as':_0x299595['as'],'attributes':_0x299595['attributes'],'include':_0x299595['include']?_[_0xbbf3('0x20')](_0x299595[_0xbbf3('0x1f')],function(_0x11936c){return{'model':db[_0x11936c[_0xbbf3('0x21')]],'as':_0x11936c['as'],'attributes':_0x11936c[_0xbbf3('0x1d')],'include':_0x11936c[_0xbbf3('0x1f')]?_['map'](_0x11936c[_0xbbf3('0x1f')],function(_0x1880b3){return{'model':db[_0x1880b3[_0xbbf3('0x21')]],'as':_0x1880b3['as'],'attributes':_0x1880b3[_0xbbf3('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xbbf3('0x25')](function(_0x2d5429){logger['info'](_0xbbf3('0x22'),_0x125cdc);logger[_0xbbf3('0x11')](_0xbbf3('0x22'),_0x125cdc,JSON[_0xbbf3('0x13')](_0x2d5429));_0x53e6c0(_0x2d5429);})['catch'](function(_0x5c86ff){logger[_0xbbf3('0x14')]('ShowVoiceQueue',_0x5c86ff[_0xbbf3('0x15')],_0x125cdc);_0x4f2ad2(_0x354533[_0xbbf3('0x14')](0x1f4,_0x5c86ff['message']));});});};