Built motion from commit (unavailable).|2.5.17
[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 _0x87d3=['OpenchannelQueue','options','raw','attributes','limit','map','include','model','find','where','ShowOpenchannelQueue','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','localhost','redis','./openchannelQueue.socket','register','info','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','OpenchannelQueue,\x20%s,\x20%s','message','result','catch'];(function(_0x34ab91,_0x158bf4){var _0x51f346=function(_0x24c895){while(--_0x24c895){_0x34ab91['push'](_0x34ab91['shift']());}};_0x51f346(++_0x158bf4);}(_0x87d3,0x13b));var _0x387d=function(_0x4af23c,_0x50e294){_0x4af23c=_0x4af23c-0x0;var _0x194b63=_0x87d3[_0x4af23c];return _0x194b63;};'use strict';var _=require(_0x387d('0x0'));var util=require(_0x387d('0x1'));var moment=require(_0x387d('0x2'));var BPromise=require(_0x387d('0x3'));var rs=require(_0x387d('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x387d('0x5'))['db'];var utils=require(_0x387d('0x6'));var logger=require(_0x387d('0x7'))(_0x387d('0x8'));var config=require(_0x387d('0x9'));var jayson=require(_0x387d('0xa'));var client=jayson['client'][_0x387d('0xb')]({'port':0x232a});config['redis']=_['defaults'](config['redis'],{'host':_0x387d('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x387d('0xd')]));require(_0x387d('0xe'))[_0x387d('0xf')](socket);function respondWithRpcPromise(_0x12a986,_0x32f539,_0x73a64f){return new BPromise(function(_0x7f1522,_0x1a210b){return client['request'](_0x12a986,_0x73a64f)['then'](function(_0x1feb18){logger[_0x387d('0x10')]('OpenchannelQueue,\x20%s,\x20%s',_0x32f539,'request\x20sent');logger[_0x387d('0x11')](_0x387d('0x12'),_0x32f539,_0x387d('0x13'),JSON[_0x387d('0x14')](_0x1feb18));if(_0x1feb18[_0x387d('0x15')]){if(_0x1feb18[_0x387d('0x15')][_0x387d('0x16')]===0x1f4){logger[_0x387d('0x15')](_0x387d('0x17'),_0x32f539,_0x1feb18[_0x387d('0x15')]['message']);return _0x1a210b(_0x1feb18[_0x387d('0x15')][_0x387d('0x18')]);}logger[_0x387d('0x15')](_0x387d('0x17'),_0x32f539,_0x1feb18[_0x387d('0x15')][_0x387d('0x18')]);return _0x7f1522(_0x1feb18[_0x387d('0x15')][_0x387d('0x18')]);}else{logger[_0x387d('0x10')]('OpenchannelQueue,\x20%s,\x20%s',_0x32f539,_0x387d('0x13'));_0x7f1522(_0x1feb18[_0x387d('0x19')][_0x387d('0x18')]);}})[_0x387d('0x1a')](function(_0x3b7752){logger[_0x387d('0x15')](_0x387d('0x17'),_0x32f539,_0x3b7752);_0x1a210b(_0x3b7752);});});}exports['GetOpenchannelQueue']=function(_0x3d26e7){var _0x4fc71e=this;return new Promise(function(_0x296b44,_0x570242){return db[_0x387d('0x1b')]['findAll']({'raw':_0x3d26e7[_0x387d('0x1c')]?_0x3d26e7[_0x387d('0x1c')][_0x387d('0x1d')]===undefined?!![]:![]:!![],'where':_0x3d26e7[_0x387d('0x1c')]?_0x3d26e7[_0x387d('0x1c')]['where']||null:null,'attributes':_0x3d26e7['options']?_0x3d26e7[_0x387d('0x1c')][_0x387d('0x1e')]||null:null,'limit':_0x3d26e7[_0x387d('0x1c')]?_0x3d26e7[_0x387d('0x1c')][_0x387d('0x1f')]||null:null,'include':_0x3d26e7[_0x387d('0x1c')]?_0x3d26e7[_0x387d('0x1c')]['include']?_[_0x387d('0x20')](_0x3d26e7[_0x387d('0x1c')][_0x387d('0x21')],function(_0x22b7f4){return{'model':db[_0x22b7f4[_0x387d('0x22')]],'as':_0x22b7f4['as'],'attributes':_0x22b7f4['attributes'],'include':_0x22b7f4[_0x387d('0x21')]?_['map'](_0x22b7f4[_0x387d('0x21')],function(_0x47f3c9){return{'model':db[_0x47f3c9[_0x387d('0x22')]],'as':_0x47f3c9['as'],'attributes':_0x47f3c9[_0x387d('0x1e')],'include':_0x47f3c9[_0x387d('0x21')]?_['map'](_0x47f3c9['include'],function(_0x346c08){return{'model':db[_0x346c08[_0x387d('0x22')]],'as':_0x346c08['as'],'attributes':_0x346c08[_0x387d('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x190b55){logger[_0x387d('0x10')]('GetOpenchannelQueue',_0x3d26e7);logger[_0x387d('0x11')]('GetOpenchannelQueue',_0x3d26e7,JSON[_0x387d('0x14')](_0x190b55));_0x296b44(_0x190b55);})[_0x387d('0x1a')](function(_0x1dcbcb){logger[_0x387d('0x15')]('GetOpenchannelQueue',_0x1dcbcb['message'],_0x3d26e7);_0x570242(_0x4fc71e[_0x387d('0x15')](0x1f4,_0x1dcbcb['message']));});});};exports['ShowOpenchannelQueue']=function(_0x1a1546){var _0x62d2a4=this;return new Promise(function(_0x4adfb3,_0x50496a){return db['OpenchannelQueue'][_0x387d('0x23')]({'raw':_0x1a1546[_0x387d('0x1c')]?_0x1a1546['options'][_0x387d('0x1d')]===undefined?!![]:![]:!![],'where':_0x1a1546['options']?_0x1a1546[_0x387d('0x1c')][_0x387d('0x24')]||null:null,'attributes':_0x1a1546[_0x387d('0x1c')]?_0x1a1546[_0x387d('0x1c')]['attributes']||null:null,'include':_0x1a1546['options']?_0x1a1546[_0x387d('0x1c')][_0x387d('0x21')]?_[_0x387d('0x20')](_0x1a1546[_0x387d('0x1c')][_0x387d('0x21')],function(_0x595a7b){return{'model':db[_0x595a7b['model']],'as':_0x595a7b['as'],'attributes':_0x595a7b[_0x387d('0x1e')],'include':_0x595a7b[_0x387d('0x21')]?_['map'](_0x595a7b['include'],function(_0x34780a){return{'model':db[_0x34780a[_0x387d('0x22')]],'as':_0x34780a['as'],'attributes':_0x34780a[_0x387d('0x1e')],'include':_0x34780a[_0x387d('0x21')]?_[_0x387d('0x20')](_0x34780a[_0x387d('0x21')],function(_0x50bdcc){return{'model':db[_0x50bdcc[_0x387d('0x22')]],'as':_0x50bdcc['as'],'attributes':_0x50bdcc['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x55cc4a){logger[_0x387d('0x10')](_0x387d('0x25'),_0x1a1546);logger[_0x387d('0x11')](_0x387d('0x25'),_0x1a1546,JSON[_0x387d('0x14')](_0x55cc4a));_0x4adfb3(_0x55cc4a);})[_0x387d('0x1a')](function(_0x4009f4){logger[_0x387d('0x15')]('ShowOpenchannelQueue',_0x4009f4[_0x387d('0x18')],_0x1a1546);_0x50496a(_0x62d2a4['error'](0x1f4,_0x4009f4['message']));});});};