Built motion from commit 44b1f254.|2.6.26
[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 _0x9ad8=['include','map','model','ShowVoiceQueue','raw','debug','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','./voiceQueue.socket','register','request','then','info','VoiceQueue,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','GetVoiceQueue','VoiceQueue','findAll','options','where','attributes','limit'];(function(_0x2df4cc,_0x1233c6){var _0x40af8d=function(_0x5e0f2a){while(--_0x5e0f2a){_0x2df4cc['push'](_0x2df4cc['shift']());}};_0x40af8d(++_0x1233c6);}(_0x9ad8,0xce));var _0x89ad=function(_0x132fb6,_0x7a257b){_0x132fb6=_0x132fb6-0x0;var _0x2ca9d5=_0x9ad8[_0x132fb6];return _0x2ca9d5;};'use strict';var _=require(_0x89ad('0x0'));var util=require(_0x89ad('0x1'));var moment=require(_0x89ad('0x2'));var BPromise=require(_0x89ad('0x3'));var rs=require(_0x89ad('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x89ad('0x5'))['db'];var utils=require(_0x89ad('0x6'));var logger=require('../../config/logger')(_0x89ad('0x7'));var config=require(_0x89ad('0x8'));var jayson=require(_0x89ad('0x9'));var client=jayson[_0x89ad('0xa')][_0x89ad('0xb')]({'port':0x232a});config['redis']=_['defaults'](config[_0x89ad('0xc')],{'host':_0x89ad('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x89ad('0xc')]));require(_0x89ad('0xe'))[_0x89ad('0xf')](socket);function respondWithRpcPromise(_0x1dd4e2,_0x4fb8ca,_0x3634c6){return new BPromise(function(_0x34faf0,_0x30f897){return client[_0x89ad('0x10')](_0x1dd4e2,_0x3634c6)[_0x89ad('0x11')](function(_0x52af49){logger[_0x89ad('0x12')](_0x89ad('0x13'),_0x4fb8ca,_0x89ad('0x14'));logger['debug']('VoiceQueue,\x20%s,\x20%s,\x20%s',_0x4fb8ca,_0x89ad('0x14'),JSON[_0x89ad('0x15')](_0x52af49));if(_0x52af49[_0x89ad('0x16')]){if(_0x52af49[_0x89ad('0x16')][_0x89ad('0x17')]===0x1f4){logger[_0x89ad('0x16')](_0x89ad('0x13'),_0x4fb8ca,_0x52af49['error']['message']);return _0x30f897(_0x52af49[_0x89ad('0x16')][_0x89ad('0x18')]);}logger[_0x89ad('0x16')](_0x89ad('0x13'),_0x4fb8ca,_0x52af49['error'][_0x89ad('0x18')]);return _0x34faf0(_0x52af49['error'][_0x89ad('0x18')]);}else{logger['info'](_0x89ad('0x13'),_0x4fb8ca,_0x89ad('0x14'));_0x34faf0(_0x52af49[_0x89ad('0x19')][_0x89ad('0x18')]);}})[_0x89ad('0x1a')](function(_0x1b0c92){logger['error'](_0x89ad('0x13'),_0x4fb8ca,_0x1b0c92);_0x30f897(_0x1b0c92);});});}exports[_0x89ad('0x1b')]=function(_0x3c98f3){var _0x28d10f=this;return new Promise(function(_0x58ef26,_0x3c891f){return db[_0x89ad('0x1c')][_0x89ad('0x1d')]({'raw':_0x3c98f3[_0x89ad('0x1e')]?_0x3c98f3[_0x89ad('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x3c98f3['options']?_0x3c98f3[_0x89ad('0x1e')][_0x89ad('0x1f')]||null:null,'attributes':_0x3c98f3['options']?_0x3c98f3['options'][_0x89ad('0x20')]||null:null,'limit':_0x3c98f3['options']?_0x3c98f3[_0x89ad('0x1e')][_0x89ad('0x21')]||null:null,'include':_0x3c98f3[_0x89ad('0x1e')]?_0x3c98f3['options'][_0x89ad('0x22')]?_['map'](_0x3c98f3[_0x89ad('0x1e')]['include'],function(_0x412149){return{'model':db[_0x412149['model']],'as':_0x412149['as'],'attributes':_0x412149[_0x89ad('0x20')],'include':_0x412149['include']?_[_0x89ad('0x23')](_0x412149[_0x89ad('0x22')],function(_0x49a867){return{'model':db[_0x49a867[_0x89ad('0x24')]],'as':_0x49a867['as'],'attributes':_0x49a867['attributes'],'include':_0x49a867[_0x89ad('0x22')]?_['map'](_0x49a867[_0x89ad('0x22')],function(_0x584477){return{'model':db[_0x584477[_0x89ad('0x24')]],'as':_0x584477['as'],'attributes':_0x584477[_0x89ad('0x20')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5084f3){logger[_0x89ad('0x12')](_0x89ad('0x1b'),_0x3c98f3);logger['debug'](_0x89ad('0x1b'),_0x3c98f3,JSON[_0x89ad('0x15')](_0x5084f3));_0x58ef26(_0x5084f3);})[_0x89ad('0x1a')](function(_0x50d0a5){logger[_0x89ad('0x16')](_0x89ad('0x1b'),_0x50d0a5['message'],_0x3c98f3);_0x3c891f(_0x28d10f[_0x89ad('0x16')](0x1f4,_0x50d0a5[_0x89ad('0x18')]));});});};exports[_0x89ad('0x25')]=function(_0x5c04ab){var _0x4875d2=this;return new Promise(function(_0x3e5cd0,_0xcbb229){return db['VoiceQueue']['find']({'raw':_0x5c04ab[_0x89ad('0x1e')]?_0x5c04ab[_0x89ad('0x1e')][_0x89ad('0x26')]===undefined?!![]:![]:!![],'where':_0x5c04ab[_0x89ad('0x1e')]?_0x5c04ab[_0x89ad('0x1e')][_0x89ad('0x1f')]||null:null,'attributes':_0x5c04ab['options']?_0x5c04ab['options']['attributes']||null:null,'include':_0x5c04ab[_0x89ad('0x1e')]?_0x5c04ab[_0x89ad('0x1e')][_0x89ad('0x22')]?_[_0x89ad('0x23')](_0x5c04ab[_0x89ad('0x1e')][_0x89ad('0x22')],function(_0x400e2d){return{'model':db[_0x400e2d[_0x89ad('0x24')]],'as':_0x400e2d['as'],'attributes':_0x400e2d[_0x89ad('0x20')],'include':_0x400e2d['include']?_[_0x89ad('0x23')](_0x400e2d['include'],function(_0x43357b){return{'model':db[_0x43357b[_0x89ad('0x24')]],'as':_0x43357b['as'],'attributes':_0x43357b[_0x89ad('0x20')],'include':_0x43357b[_0x89ad('0x22')]?_[_0x89ad('0x23')](_0x43357b[_0x89ad('0x22')],function(_0x1dc44b){return{'model':db[_0x1dc44b[_0x89ad('0x24')]],'as':_0x1dc44b['as'],'attributes':_0x1dc44b['attributes']};}):[]};}):[]};}):[]:[]})[_0x89ad('0x11')](function(_0x3a4a53){logger['info'](_0x89ad('0x25'),_0x5c04ab);logger[_0x89ad('0x27')](_0x89ad('0x25'),_0x5c04ab,JSON[_0x89ad('0x15')](_0x3a4a53));_0x3e5cd0(_0x3a4a53);})[_0x89ad('0x1a')](function(_0x300504){logger['error'](_0x89ad('0x25'),_0x300504['message'],_0x5c04ab);_0xcbb229(_0x4875d2[_0x89ad('0x16')](0x1f4,_0x300504[_0x89ad('0x18')]));});});};