05e8e8a62d8f238882debffbb4271bd8c28614ad
[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 _0xecc3=['../../config/logger','rpc','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./openchannelQueue.socket','register','then','info','OpenchannelQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','GetOpenchannelQueue','OpenchannelQueue','findAll','options','include','map','model','attributes','ShowOpenchannelQueue','find','lodash','util','randomstring','ioredis','../../mysqldb','../../config/utils'];(function(_0x3d2030,_0x3b0ac3){var _0x334a19=function(_0x281c09){while(--_0x281c09){_0x3d2030['push'](_0x3d2030['shift']());}};_0x334a19(++_0x3b0ac3);}(_0xecc3,0xde));var _0x3ecc=function(_0xeff27c,_0x5b9db7){_0xeff27c=_0xeff27c-0x0;var _0x16d83b=_0xecc3[_0xeff27c];return _0x16d83b;};'use strict';var _=require(_0x3ecc('0x0'));var util=require(_0x3ecc('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x3ecc('0x2'));var fs=require('fs');var Redis=require(_0x3ecc('0x3'));var db=require(_0x3ecc('0x4'))['db'];var utils=require(_0x3ecc('0x5'));var logger=require(_0x3ecc('0x6'))(_0x3ecc('0x7'));var config=require('../../config/environment');var jayson=require(_0x3ecc('0x8'));var client=jayson[_0x3ecc('0x9')][_0x3ecc('0xa')]({'port':0x232a});config[_0x3ecc('0xb')]=_[_0x3ecc('0xc')](config[_0x3ecc('0xb')],{'host':_0x3ecc('0xd'),'port':0x18eb});var socket=require(_0x3ecc('0xe'))(new Redis(config[_0x3ecc('0xb')]));require(_0x3ecc('0xf'))[_0x3ecc('0x10')](socket);function respondWithRpcPromise(_0x20e54a,_0x191fd7,_0x2f0004){return new BPromise(function(_0x43b867,_0x1c1c4d){return client['request'](_0x20e54a,_0x2f0004)[_0x3ecc('0x11')](function(_0x1ca949){logger[_0x3ecc('0x12')](_0x3ecc('0x13'),_0x191fd7,_0x3ecc('0x14'));logger[_0x3ecc('0x15')]('OpenchannelQueue,\x20%s,\x20%s,\x20%s',_0x191fd7,_0x3ecc('0x14'),JSON[_0x3ecc('0x16')](_0x1ca949));if(_0x1ca949[_0x3ecc('0x17')]){if(_0x1ca949['error'][_0x3ecc('0x18')]===0x1f4){logger[_0x3ecc('0x17')](_0x3ecc('0x13'),_0x191fd7,_0x1ca949[_0x3ecc('0x17')][_0x3ecc('0x19')]);return _0x1c1c4d(_0x1ca949[_0x3ecc('0x17')][_0x3ecc('0x19')]);}logger[_0x3ecc('0x17')](_0x3ecc('0x13'),_0x191fd7,_0x1ca949[_0x3ecc('0x17')]['message']);return _0x43b867(_0x1ca949[_0x3ecc('0x17')][_0x3ecc('0x19')]);}else{logger[_0x3ecc('0x12')]('OpenchannelQueue,\x20%s,\x20%s',_0x191fd7,_0x3ecc('0x14'));_0x43b867(_0x1ca949[_0x3ecc('0x1a')][_0x3ecc('0x19')]);}})[_0x3ecc('0x1b')](function(_0x610655){logger[_0x3ecc('0x17')]('OpenchannelQueue,\x20%s,\x20%s',_0x191fd7,_0x610655);_0x1c1c4d(_0x610655);});});}exports[_0x3ecc('0x1c')]=function(_0xc6981e){var _0x53f004=this;return new Promise(function(_0x1b8b21,_0x14af4b){return db[_0x3ecc('0x1d')][_0x3ecc('0x1e')]({'raw':_0xc6981e[_0x3ecc('0x1f')]?_0xc6981e[_0x3ecc('0x1f')]['raw']===undefined?!![]:![]:!![],'where':_0xc6981e[_0x3ecc('0x1f')]?_0xc6981e[_0x3ecc('0x1f')]['where']||null:null,'attributes':_0xc6981e[_0x3ecc('0x1f')]?_0xc6981e[_0x3ecc('0x1f')]['attributes']||null:null,'limit':_0xc6981e[_0x3ecc('0x1f')]?_0xc6981e[_0x3ecc('0x1f')]['limit']||null:null,'include':_0xc6981e[_0x3ecc('0x1f')]?_0xc6981e[_0x3ecc('0x1f')][_0x3ecc('0x20')]?_[_0x3ecc('0x21')](_0xc6981e[_0x3ecc('0x1f')]['include'],function(_0x254527){return{'model':db[_0x254527[_0x3ecc('0x22')]],'as':_0x254527['as'],'attributes':_0x254527[_0x3ecc('0x23')],'include':_0x254527['include']?_[_0x3ecc('0x21')](_0x254527['include'],function(_0x508888){return{'model':db[_0x508888[_0x3ecc('0x22')]],'as':_0x508888['as'],'attributes':_0x508888['attributes'],'include':_0x508888[_0x3ecc('0x20')]?_[_0x3ecc('0x21')](_0x508888['include'],function(_0x473296){return{'model':db[_0x473296[_0x3ecc('0x22')]],'as':_0x473296['as'],'attributes':_0x473296[_0x3ecc('0x23')]};}):[]};}):[]};}):[]:[]})[_0x3ecc('0x11')](function(_0x17a4a8){logger[_0x3ecc('0x12')](_0x3ecc('0x1c'),_0xc6981e);logger['debug'](_0x3ecc('0x1c'),_0xc6981e,JSON[_0x3ecc('0x16')](_0x17a4a8));_0x1b8b21(_0x17a4a8);})[_0x3ecc('0x1b')](function(_0x5eedc0){logger['error'](_0x3ecc('0x1c'),_0x5eedc0[_0x3ecc('0x19')],_0xc6981e);_0x14af4b(_0x53f004[_0x3ecc('0x17')](0x1f4,_0x5eedc0[_0x3ecc('0x19')]));});});};exports[_0x3ecc('0x24')]=function(_0x23f53c){var _0x1a6c04=this;return new Promise(function(_0x208783,_0x908a32){return db[_0x3ecc('0x1d')][_0x3ecc('0x25')]({'raw':_0x23f53c['options']?_0x23f53c[_0x3ecc('0x1f')]['raw']===undefined?!![]:![]:!![],'where':_0x23f53c[_0x3ecc('0x1f')]?_0x23f53c[_0x3ecc('0x1f')]['where']||null:null,'attributes':_0x23f53c[_0x3ecc('0x1f')]?_0x23f53c[_0x3ecc('0x1f')]['attributes']||null:null,'include':_0x23f53c[_0x3ecc('0x1f')]?_0x23f53c[_0x3ecc('0x1f')]['include']?_[_0x3ecc('0x21')](_0x23f53c[_0x3ecc('0x1f')][_0x3ecc('0x20')],function(_0xc1fb80){return{'model':db[_0xc1fb80[_0x3ecc('0x22')]],'as':_0xc1fb80['as'],'attributes':_0xc1fb80[_0x3ecc('0x23')],'include':_0xc1fb80['include']?_[_0x3ecc('0x21')](_0xc1fb80[_0x3ecc('0x20')],function(_0x45de31){return{'model':db[_0x45de31['model']],'as':_0x45de31['as'],'attributes':_0x45de31[_0x3ecc('0x23')],'include':_0x45de31[_0x3ecc('0x20')]?_[_0x3ecc('0x21')](_0x45de31['include'],function(_0x1558a0){return{'model':db[_0x1558a0[_0x3ecc('0x22')]],'as':_0x1558a0['as'],'attributes':_0x1558a0[_0x3ecc('0x23')]};}):[]};}):[]};}):[]:[]})[_0x3ecc('0x11')](function(_0x2bb51a){logger[_0x3ecc('0x12')]('ShowOpenchannelQueue',_0x23f53c);logger[_0x3ecc('0x15')](_0x3ecc('0x24'),_0x23f53c,JSON[_0x3ecc('0x16')](_0x2bb51a));_0x208783(_0x2bb51a);})[_0x3ecc('0x1b')](function(_0x50c4bd){logger[_0x3ecc('0x17')](_0x3ecc('0x24'),_0x50c4bd['message'],_0x23f53c);_0x908a32(_0x1a6c04[_0x3ecc('0x17')](0x1f4,_0x50c4bd[_0x3ecc('0x19')]));});});};