Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / openchannelQueue / openchannelQueue.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 _0x14f6=['message','result','catch','GetOpenchannelQueue','OpenchannelQueue','findAll','options','raw','where','attributes','include','map','model','then','ShowOpenchannelQueue','find','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','redis','./openchannelQueue.socket','register','request','info','OpenchannelQueue,\x20%s,\x20%s','request\x20sent','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0x288fb8,_0x3606df){var _0x8f14b5=function(_0x4839d3){while(--_0x4839d3){_0x288fb8['push'](_0x288fb8['shift']());}};_0x8f14b5(++_0x3606df);}(_0x14f6,0x1d8));var _0x614f=function(_0x1ba717,_0xb9193a){_0x1ba717=_0x1ba717-0x0;var _0x208f52=_0x14f6[_0x1ba717];return _0x208f52;};'use strict';var _=require(_0x614f('0x0'));var util=require(_0x614f('0x1'));var moment=require('moment');var BPromise=require(_0x614f('0x2'));var rs=require(_0x614f('0x3'));var fs=require('fs');var Redis=require(_0x614f('0x4'));var db=require(_0x614f('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x614f('0x6'))(_0x614f('0x7'));var config=require(_0x614f('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x614f('0x9')]['http']({'port':0x232a});config['redis']=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x614f('0xa')]));require(_0x614f('0xb'))[_0x614f('0xc')](socket);function respondWithRpcPromise(_0x53954a,_0x13ce93,_0x4774ec){return new BPromise(function(_0x24953d,_0x2ce3d6){return client[_0x614f('0xd')](_0x53954a,_0x4774ec)['then'](function(_0x25449f){logger[_0x614f('0xe')](_0x614f('0xf'),_0x13ce93,_0x614f('0x10'));logger[_0x614f('0x11')](_0x614f('0x12'),_0x13ce93,_0x614f('0x10'),JSON[_0x614f('0x13')](_0x25449f));if(_0x25449f[_0x614f('0x14')]){if(_0x25449f[_0x614f('0x14')][_0x614f('0x15')]===0x1f4){logger['error']('OpenchannelQueue,\x20%s,\x20%s',_0x13ce93,_0x25449f[_0x614f('0x14')][_0x614f('0x16')]);return _0x2ce3d6(_0x25449f['error']['message']);}logger[_0x614f('0x14')]('OpenchannelQueue,\x20%s,\x20%s',_0x13ce93,_0x25449f[_0x614f('0x14')]['message']);return _0x24953d(_0x25449f[_0x614f('0x14')]['message']);}else{logger['info'](_0x614f('0xf'),_0x13ce93,_0x614f('0x10'));_0x24953d(_0x25449f[_0x614f('0x17')][_0x614f('0x16')]);}})[_0x614f('0x18')](function(_0x5a7b09){logger[_0x614f('0x14')](_0x614f('0xf'),_0x13ce93,_0x5a7b09);_0x2ce3d6(_0x5a7b09);});});}exports[_0x614f('0x19')]=function(_0x2e0ba6){var _0x5cadc6=this;return new Promise(function(_0x4be7e8,_0x37f216){return db[_0x614f('0x1a')][_0x614f('0x1b')]({'raw':_0x2e0ba6[_0x614f('0x1c')]?_0x2e0ba6['options'][_0x614f('0x1d')]===undefined?!![]:![]:!![],'where':_0x2e0ba6[_0x614f('0x1c')]?_0x2e0ba6['options'][_0x614f('0x1e')]||null:null,'attributes':_0x2e0ba6['options']?_0x2e0ba6[_0x614f('0x1c')][_0x614f('0x1f')]||null:null,'limit':_0x2e0ba6['options']?_0x2e0ba6['options']['limit']||null:null,'include':_0x2e0ba6['options']?_0x2e0ba6['options'][_0x614f('0x20')]?_[_0x614f('0x21')](_0x2e0ba6[_0x614f('0x1c')][_0x614f('0x20')],function(_0x47e7f6){return{'model':db[_0x47e7f6['model']],'as':_0x47e7f6['as'],'attributes':_0x47e7f6[_0x614f('0x1f')],'include':_0x47e7f6[_0x614f('0x20')]?_[_0x614f('0x21')](_0x47e7f6['include'],function(_0x355f0d){return{'model':db[_0x355f0d['model']],'as':_0x355f0d['as'],'attributes':_0x355f0d[_0x614f('0x1f')],'include':_0x355f0d[_0x614f('0x20')]?_[_0x614f('0x21')](_0x355f0d[_0x614f('0x20')],function(_0x5053f3){return{'model':db[_0x5053f3[_0x614f('0x22')]],'as':_0x5053f3['as'],'attributes':_0x5053f3['attributes']};}):[]};}):[]};}):[]:[]})[_0x614f('0x23')](function(_0x2586cf){logger[_0x614f('0xe')](_0x614f('0x19'),_0x2e0ba6);logger[_0x614f('0x11')](_0x614f('0x19'),_0x2e0ba6,JSON[_0x614f('0x13')](_0x2586cf));_0x4be7e8(_0x2586cf);})['catch'](function(_0x674eb0){logger[_0x614f('0x14')](_0x614f('0x19'),_0x674eb0['message'],_0x2e0ba6);_0x37f216(_0x5cadc6[_0x614f('0x14')](0x1f4,_0x674eb0['message']));});});};exports[_0x614f('0x24')]=function(_0x47a844){var _0x1a288b=this;return new Promise(function(_0x366d52,_0x4acbb9){return db[_0x614f('0x1a')][_0x614f('0x25')]({'raw':_0x47a844[_0x614f('0x1c')]?_0x47a844['options']['raw']===undefined?!![]:![]:!![],'where':_0x47a844[_0x614f('0x1c')]?_0x47a844[_0x614f('0x1c')][_0x614f('0x1e')]||null:null,'attributes':_0x47a844['options']?_0x47a844[_0x614f('0x1c')][_0x614f('0x1f')]||null:null,'include':_0x47a844[_0x614f('0x1c')]?_0x47a844[_0x614f('0x1c')]['include']?_[_0x614f('0x21')](_0x47a844[_0x614f('0x1c')][_0x614f('0x20')],function(_0x467e3c){return{'model':db[_0x467e3c[_0x614f('0x22')]],'as':_0x467e3c['as'],'attributes':_0x467e3c[_0x614f('0x1f')],'include':_0x467e3c[_0x614f('0x20')]?_[_0x614f('0x21')](_0x467e3c['include'],function(_0x441eb3){return{'model':db[_0x441eb3[_0x614f('0x22')]],'as':_0x441eb3['as'],'attributes':_0x441eb3[_0x614f('0x1f')],'include':_0x441eb3[_0x614f('0x20')]?_[_0x614f('0x21')](_0x441eb3[_0x614f('0x20')],function(_0x2a34c9){return{'model':db[_0x2a34c9[_0x614f('0x22')]],'as':_0x2a34c9['as'],'attributes':_0x2a34c9[_0x614f('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x614f('0x23')](function(_0x2e1ff9){logger[_0x614f('0xe')](_0x614f('0x24'),_0x47a844);logger[_0x614f('0x11')](_0x614f('0x24'),_0x47a844,JSON[_0x614f('0x13')](_0x2e1ff9));_0x366d52(_0x2e1ff9);})[_0x614f('0x18')](function(_0x350ad6){logger['error'](_0x614f('0x24'),_0x350ad6['message'],_0x47a844);_0x4acbb9(_0x1a288b[_0x614f('0x14')](0x1f4,_0x350ad6['message']));});});};