602736cac3f6ddc84b4761a53be89031b334659c
[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 _0x4d18=['options','where','limit','include','map','attributes','model','ShowOpenchannelQueue','moment','bluebird','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','./openchannelQueue.socket','register','request','then','info','OpenchannelQueue,\x20%s,\x20%s','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','GetOpenchannelQueue','OpenchannelQueue','findAll'];(function(_0x14ed07,_0x3ec11e){var _0x43e5f9=function(_0x3fc1d2){while(--_0x3fc1d2){_0x14ed07['push'](_0x14ed07['shift']());}};_0x43e5f9(++_0x3ec11e);}(_0x4d18,0x1aa));var _0x84d1=function(_0x5ad8b4,_0x28beaa){_0x5ad8b4=_0x5ad8b4-0x0;var _0x1f078e=_0x4d18[_0x5ad8b4];return _0x1f078e;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x84d1('0x0'));var BPromise=require(_0x84d1('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x84d1('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0x84d1('0x3'));var logger=require(_0x84d1('0x4'))(_0x84d1('0x5'));var config=require(_0x84d1('0x6'));var jayson=require(_0x84d1('0x7'));var client=jayson[_0x84d1('0x8')]['http']({'port':0x232a});config[_0x84d1('0x9')]=_[_0x84d1('0xa')](config[_0x84d1('0x9')],{'host':_0x84d1('0xb'),'port':0x18eb});var socket=require(_0x84d1('0xc'))(new Redis(config[_0x84d1('0x9')]));require(_0x84d1('0xd'))[_0x84d1('0xe')](socket);function respondWithRpcPromise(_0x209cf6,_0x45cd4d,_0x72327e){return new BPromise(function(_0x523935,_0x551360){return client[_0x84d1('0xf')](_0x209cf6,_0x72327e)[_0x84d1('0x10')](function(_0x279d3a){logger[_0x84d1('0x11')](_0x84d1('0x12'),_0x45cd4d,'request\x20sent');logger[_0x84d1('0x13')](_0x84d1('0x14'),_0x45cd4d,_0x84d1('0x15'),JSON[_0x84d1('0x16')](_0x279d3a));if(_0x279d3a[_0x84d1('0x17')]){if(_0x279d3a['error'][_0x84d1('0x18')]===0x1f4){logger[_0x84d1('0x17')](_0x84d1('0x12'),_0x45cd4d,_0x279d3a[_0x84d1('0x17')][_0x84d1('0x19')]);return _0x551360(_0x279d3a[_0x84d1('0x17')][_0x84d1('0x19')]);}logger['error'](_0x84d1('0x12'),_0x45cd4d,_0x279d3a[_0x84d1('0x17')][_0x84d1('0x19')]);return _0x523935(_0x279d3a[_0x84d1('0x17')][_0x84d1('0x19')]);}else{logger[_0x84d1('0x11')](_0x84d1('0x12'),_0x45cd4d,_0x84d1('0x15'));_0x523935(_0x279d3a['result']['message']);}})[_0x84d1('0x1a')](function(_0xdc4e64){logger[_0x84d1('0x17')](_0x84d1('0x12'),_0x45cd4d,_0xdc4e64);_0x551360(_0xdc4e64);});});}exports[_0x84d1('0x1b')]=function(_0x1fb127){var _0x2a13f0=this;return new Promise(function(_0x3b1b38,_0x3a1ec6){return db[_0x84d1('0x1c')][_0x84d1('0x1d')]({'raw':_0x1fb127[_0x84d1('0x1e')]?_0x1fb127[_0x84d1('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x1fb127[_0x84d1('0x1e')]?_0x1fb127[_0x84d1('0x1e')][_0x84d1('0x1f')]||null:null,'attributes':_0x1fb127[_0x84d1('0x1e')]?_0x1fb127[_0x84d1('0x1e')]['attributes']||null:null,'limit':_0x1fb127[_0x84d1('0x1e')]?_0x1fb127[_0x84d1('0x1e')][_0x84d1('0x20')]||null:null,'include':_0x1fb127[_0x84d1('0x1e')]?_0x1fb127['options'][_0x84d1('0x21')]?_[_0x84d1('0x22')](_0x1fb127[_0x84d1('0x1e')][_0x84d1('0x21')],function(_0x15da28){return{'model':db[_0x15da28['model']],'as':_0x15da28['as'],'attributes':_0x15da28[_0x84d1('0x23')],'include':_0x15da28[_0x84d1('0x21')]?_[_0x84d1('0x22')](_0x15da28['include'],function(_0x15ed06){return{'model':db[_0x15ed06[_0x84d1('0x24')]],'as':_0x15ed06['as'],'attributes':_0x15ed06[_0x84d1('0x23')],'include':_0x15ed06[_0x84d1('0x21')]?_[_0x84d1('0x22')](_0x15ed06[_0x84d1('0x21')],function(_0x1dcedb){return{'model':db[_0x1dcedb[_0x84d1('0x24')]],'as':_0x1dcedb['as'],'attributes':_0x1dcedb['attributes']};}):[]};}):[]};}):[]:[]})[_0x84d1('0x10')](function(_0x941689){logger[_0x84d1('0x11')](_0x84d1('0x1b'),_0x1fb127);logger[_0x84d1('0x13')]('GetOpenchannelQueue',_0x1fb127,JSON[_0x84d1('0x16')](_0x941689));_0x3b1b38(_0x941689);})[_0x84d1('0x1a')](function(_0x3efef9){logger['error']('GetOpenchannelQueue',_0x3efef9[_0x84d1('0x19')],_0x1fb127);_0x3a1ec6(_0x2a13f0[_0x84d1('0x17')](0x1f4,_0x3efef9[_0x84d1('0x19')]));});});};exports[_0x84d1('0x25')]=function(_0x406688){var _0x263d04=this;return new Promise(function(_0x50db02,_0x583890){return db[_0x84d1('0x1c')]['find']({'raw':_0x406688[_0x84d1('0x1e')]?_0x406688['options']['raw']===undefined?!![]:![]:!![],'where':_0x406688[_0x84d1('0x1e')]?_0x406688[_0x84d1('0x1e')]['where']||null:null,'attributes':_0x406688[_0x84d1('0x1e')]?_0x406688[_0x84d1('0x1e')]['attributes']||null:null,'include':_0x406688[_0x84d1('0x1e')]?_0x406688[_0x84d1('0x1e')]['include']?_[_0x84d1('0x22')](_0x406688[_0x84d1('0x1e')]['include'],function(_0x140205){return{'model':db[_0x140205[_0x84d1('0x24')]],'as':_0x140205['as'],'attributes':_0x140205[_0x84d1('0x23')],'include':_0x140205[_0x84d1('0x21')]?_[_0x84d1('0x22')](_0x140205['include'],function(_0x14e381){return{'model':db[_0x14e381['model']],'as':_0x14e381['as'],'attributes':_0x14e381[_0x84d1('0x23')],'include':_0x14e381[_0x84d1('0x21')]?_[_0x84d1('0x22')](_0x14e381[_0x84d1('0x21')],function(_0x5c53b9){return{'model':db[_0x5c53b9[_0x84d1('0x24')]],'as':_0x5c53b9['as'],'attributes':_0x5c53b9[_0x84d1('0x23')]};}):[]};}):[]};}):[]:[]})[_0x84d1('0x10')](function(_0x4ad5dd){logger[_0x84d1('0x11')](_0x84d1('0x25'),_0x406688);logger[_0x84d1('0x13')]('ShowOpenchannelQueue',_0x406688,JSON[_0x84d1('0x16')](_0x4ad5dd));_0x50db02(_0x4ad5dd);})[_0x84d1('0x1a')](function(_0x1f5440){logger[_0x84d1('0x17')]('ShowOpenchannelQueue',_0x1f5440[_0x84d1('0x19')],_0x406688);_0x583890(_0x263d04[_0x84d1('0x17')](0x1f4,_0x1f5440[_0x84d1('0x19')]));});});};