d63a34642b61cb3c2f08068cd8ffd36640d7e1e2
[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 _0x21df=['localhost','socket.io-emitter','request','then','info','OpenchannelQueue,\x20%s,\x20%s','request\x20sent','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','GetOpenchannelQueue','OpenchannelQueue','findAll','options','raw','where','attributes','limit','map','include','model','ShowOpenchannelQueue','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','redis','defaults'];(function(_0x85c87b,_0x5377a7){var _0x262906=function(_0x5b92b3){while(--_0x5b92b3){_0x85c87b['push'](_0x85c87b['shift']());}};_0x262906(++_0x5377a7);}(_0x21df,0x12b));var _0xf21d=function(_0x21a06a,_0x5be4a5){_0x21a06a=_0x21a06a-0x0;var _0x289657=_0x21df[_0x21a06a];return _0x289657;};'use strict';var _=require(_0xf21d('0x0'));var util=require(_0xf21d('0x1'));var moment=require(_0xf21d('0x2'));var BPromise=require(_0xf21d('0x3'));var rs=require(_0xf21d('0x4'));var fs=require('fs');var Redis=require(_0xf21d('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xf21d('0x6'));var logger=require(_0xf21d('0x7'))('rpc');var config=require(_0xf21d('0x8'));var jayson=require(_0xf21d('0x9'));var client=jayson[_0xf21d('0xa')]['http']({'port':0x232a});config[_0xf21d('0xb')]=_[_0xf21d('0xc')](config['redis'],{'host':_0xf21d('0xd'),'port':0x18eb});var socket=require(_0xf21d('0xe'))(new Redis(config[_0xf21d('0xb')]));require('./openchannelQueue.socket')['register'](socket);function respondWithRpcPromise(_0x31b1e6,_0x2509ad,_0x1a62ff){return new BPromise(function(_0x38baa5,_0x2354ed){return client[_0xf21d('0xf')](_0x31b1e6,_0x1a62ff)[_0xf21d('0x10')](function(_0x5e9ccb){logger[_0xf21d('0x11')](_0xf21d('0x12'),_0x2509ad,_0xf21d('0x13'));logger[_0xf21d('0x14')](_0xf21d('0x15'),_0x2509ad,'request\x20sent',JSON[_0xf21d('0x16')](_0x5e9ccb));if(_0x5e9ccb[_0xf21d('0x17')]){if(_0x5e9ccb[_0xf21d('0x17')][_0xf21d('0x18')]===0x1f4){logger[_0xf21d('0x17')](_0xf21d('0x12'),_0x2509ad,_0x5e9ccb[_0xf21d('0x17')][_0xf21d('0x19')]);return _0x2354ed(_0x5e9ccb[_0xf21d('0x17')][_0xf21d('0x19')]);}logger['error'](_0xf21d('0x12'),_0x2509ad,_0x5e9ccb[_0xf21d('0x17')]['message']);return _0x38baa5(_0x5e9ccb['error']['message']);}else{logger[_0xf21d('0x11')]('OpenchannelQueue,\x20%s,\x20%s',_0x2509ad,_0xf21d('0x13'));_0x38baa5(_0x5e9ccb['result'][_0xf21d('0x19')]);}})[_0xf21d('0x1a')](function(_0xbbae2a){logger[_0xf21d('0x17')](_0xf21d('0x12'),_0x2509ad,_0xbbae2a);_0x2354ed(_0xbbae2a);});});}exports[_0xf21d('0x1b')]=function(_0x1053c0){var _0x3666e0=this;return new Promise(function(_0xe16056,_0x2211bd){return db[_0xf21d('0x1c')][_0xf21d('0x1d')]({'raw':_0x1053c0['options']?_0x1053c0[_0xf21d('0x1e')][_0xf21d('0x1f')]===undefined?!![]:![]:!![],'where':_0x1053c0[_0xf21d('0x1e')]?_0x1053c0[_0xf21d('0x1e')][_0xf21d('0x20')]||null:null,'attributes':_0x1053c0[_0xf21d('0x1e')]?_0x1053c0['options'][_0xf21d('0x21')]||null:null,'limit':_0x1053c0['options']?_0x1053c0[_0xf21d('0x1e')][_0xf21d('0x22')]||null:null,'include':_0x1053c0['options']?_0x1053c0[_0xf21d('0x1e')]['include']?_[_0xf21d('0x23')](_0x1053c0[_0xf21d('0x1e')][_0xf21d('0x24')],function(_0x43cdf2){return{'model':db[_0x43cdf2[_0xf21d('0x25')]],'as':_0x43cdf2['as'],'attributes':_0x43cdf2['attributes'],'include':_0x43cdf2[_0xf21d('0x24')]?_['map'](_0x43cdf2[_0xf21d('0x24')],function(_0x7b83d0){return{'model':db[_0x7b83d0[_0xf21d('0x25')]],'as':_0x7b83d0['as'],'attributes':_0x7b83d0[_0xf21d('0x21')],'include':_0x7b83d0['include']?_['map'](_0x7b83d0[_0xf21d('0x24')],function(_0x6dcc86){return{'model':db[_0x6dcc86[_0xf21d('0x25')]],'as':_0x6dcc86['as'],'attributes':_0x6dcc86[_0xf21d('0x21')]};}):[]};}):[]};}):[]:[]})[_0xf21d('0x10')](function(_0x3e7e8d){logger[_0xf21d('0x11')](_0xf21d('0x1b'),_0x1053c0);logger[_0xf21d('0x14')](_0xf21d('0x1b'),_0x1053c0,JSON[_0xf21d('0x16')](_0x3e7e8d));_0xe16056(_0x3e7e8d);})[_0xf21d('0x1a')](function(_0x9d081e){logger['error'](_0xf21d('0x1b'),_0x9d081e[_0xf21d('0x19')],_0x1053c0);_0x2211bd(_0x3666e0[_0xf21d('0x17')](0x1f4,_0x9d081e[_0xf21d('0x19')]));});});};exports[_0xf21d('0x26')]=function(_0xc023da){var _0x8d0cdf=this;return new Promise(function(_0x5f68c7,_0x44f9dd){return db[_0xf21d('0x1c')]['find']({'raw':_0xc023da[_0xf21d('0x1e')]?_0xc023da[_0xf21d('0x1e')][_0xf21d('0x1f')]===undefined?!![]:![]:!![],'where':_0xc023da[_0xf21d('0x1e')]?_0xc023da['options']['where']||null:null,'attributes':_0xc023da[_0xf21d('0x1e')]?_0xc023da[_0xf21d('0x1e')]['attributes']||null:null,'include':_0xc023da[_0xf21d('0x1e')]?_0xc023da[_0xf21d('0x1e')][_0xf21d('0x24')]?_[_0xf21d('0x23')](_0xc023da[_0xf21d('0x1e')][_0xf21d('0x24')],function(_0x5a7822){return{'model':db[_0x5a7822[_0xf21d('0x25')]],'as':_0x5a7822['as'],'attributes':_0x5a7822['attributes'],'include':_0x5a7822[_0xf21d('0x24')]?_[_0xf21d('0x23')](_0x5a7822[_0xf21d('0x24')],function(_0x11fd81){return{'model':db[_0x11fd81[_0xf21d('0x25')]],'as':_0x11fd81['as'],'attributes':_0x11fd81[_0xf21d('0x21')],'include':_0x11fd81[_0xf21d('0x24')]?_[_0xf21d('0x23')](_0x11fd81['include'],function(_0x2ab986){return{'model':db[_0x2ab986[_0xf21d('0x25')]],'as':_0x2ab986['as'],'attributes':_0x2ab986[_0xf21d('0x21')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x4e5e50){logger[_0xf21d('0x11')]('ShowOpenchannelQueue',_0xc023da);logger[_0xf21d('0x14')](_0xf21d('0x26'),_0xc023da,JSON['stringify'](_0x4e5e50));_0x5f68c7(_0x4e5e50);})[_0xf21d('0x1a')](function(_0x100f35){logger[_0xf21d('0x17')]('ShowOpenchannelQueue',_0x100f35[_0xf21d('0x19')],_0xc023da);_0x44f9dd(_0x8d0cdf[_0xf21d('0x17')](0x1f4,_0x100f35['message']));});});};