Built motion from commit f7863d46.|2.5.41
[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 _0x9987=['options','limit','include','model','map','attributes','stringify','find','raw','ShowOpenchannelQueue','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./openchannelQueue.socket','request','then','info','OpenchannelQueue,\x20%s,\x20%s','request\x20sent','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetOpenchannelQueue','OpenchannelQueue'];(function(_0x4e64ad,_0x5cd843){var _0x48e2f9=function(_0x15944c){while(--_0x15944c){_0x4e64ad['push'](_0x4e64ad['shift']());}};_0x48e2f9(++_0x5cd843);}(_0x9987,0x11b));var _0x7998=function(_0x36d439,_0x3b96bc){_0x36d439=_0x36d439-0x0;var _0x2c7757=_0x9987[_0x36d439];return _0x2c7757;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x7998('0x0'));var BPromise=require(_0x7998('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x7998('0x2'))['db'];var utils=require(_0x7998('0x3'));var logger=require(_0x7998('0x4'))(_0x7998('0x5'));var config=require(_0x7998('0x6'));var jayson=require(_0x7998('0x7'));var client=jayson[_0x7998('0x8')][_0x7998('0x9')]({'port':0x232a});config[_0x7998('0xa')]=_[_0x7998('0xb')](config[_0x7998('0xa')],{'host':_0x7998('0xc'),'port':0x18eb});var socket=require(_0x7998('0xd'))(new Redis(config[_0x7998('0xa')]));require(_0x7998('0xe'))['register'](socket);function respondWithRpcPromise(_0x4ea10f,_0x560886,_0x234d59){return new BPromise(function(_0x4a8f40,_0x3f57aa){return client[_0x7998('0xf')](_0x4ea10f,_0x234d59)[_0x7998('0x10')](function(_0x1b8728){logger[_0x7998('0x11')](_0x7998('0x12'),_0x560886,_0x7998('0x13'));logger[_0x7998('0x14')](_0x7998('0x15'),_0x560886,'request\x20sent',JSON['stringify'](_0x1b8728));if(_0x1b8728[_0x7998('0x16')]){if(_0x1b8728[_0x7998('0x16')][_0x7998('0x17')]===0x1f4){logger[_0x7998('0x16')](_0x7998('0x12'),_0x560886,_0x1b8728[_0x7998('0x16')][_0x7998('0x18')]);return _0x3f57aa(_0x1b8728[_0x7998('0x16')][_0x7998('0x18')]);}logger[_0x7998('0x16')](_0x7998('0x12'),_0x560886,_0x1b8728[_0x7998('0x16')][_0x7998('0x18')]);return _0x4a8f40(_0x1b8728[_0x7998('0x16')]['message']);}else{logger['info'](_0x7998('0x12'),_0x560886,_0x7998('0x13'));_0x4a8f40(_0x1b8728[_0x7998('0x19')][_0x7998('0x18')]);}})[_0x7998('0x1a')](function(_0x1b8d8a){logger['error'](_0x7998('0x12'),_0x560886,_0x1b8d8a);_0x3f57aa(_0x1b8d8a);});});}exports[_0x7998('0x1b')]=function(_0x19f0a0){var _0x3f29a1=this;return new Promise(function(_0x56ffbc,_0x35972f){return db[_0x7998('0x1c')]['findAll']({'raw':_0x19f0a0['options']?_0x19f0a0[_0x7998('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x19f0a0[_0x7998('0x1d')]?_0x19f0a0[_0x7998('0x1d')]['where']||null:null,'attributes':_0x19f0a0[_0x7998('0x1d')]?_0x19f0a0['options']['attributes']||null:null,'limit':_0x19f0a0[_0x7998('0x1d')]?_0x19f0a0[_0x7998('0x1d')][_0x7998('0x1e')]||null:null,'include':_0x19f0a0['options']?_0x19f0a0[_0x7998('0x1d')][_0x7998('0x1f')]?_['map'](_0x19f0a0['options'][_0x7998('0x1f')],function(_0x54bc9d){return{'model':db[_0x54bc9d[_0x7998('0x20')]],'as':_0x54bc9d['as'],'attributes':_0x54bc9d['attributes'],'include':_0x54bc9d[_0x7998('0x1f')]?_[_0x7998('0x21')](_0x54bc9d[_0x7998('0x1f')],function(_0x3bd15e){return{'model':db[_0x3bd15e[_0x7998('0x20')]],'as':_0x3bd15e['as'],'attributes':_0x3bd15e[_0x7998('0x22')],'include':_0x3bd15e[_0x7998('0x1f')]?_['map'](_0x3bd15e[_0x7998('0x1f')],function(_0x571b1b){return{'model':db[_0x571b1b[_0x7998('0x20')]],'as':_0x571b1b['as'],'attributes':_0x571b1b[_0x7998('0x22')]};}):[]};}):[]};}):[]:[]})[_0x7998('0x10')](function(_0x2ec2e5){logger[_0x7998('0x11')](_0x7998('0x1b'),_0x19f0a0);logger[_0x7998('0x14')]('GetOpenchannelQueue',_0x19f0a0,JSON[_0x7998('0x23')](_0x2ec2e5));_0x56ffbc(_0x2ec2e5);})[_0x7998('0x1a')](function(_0x2a2167){logger['error'](_0x7998('0x1b'),_0x2a2167[_0x7998('0x18')],_0x19f0a0);_0x35972f(_0x3f29a1[_0x7998('0x16')](0x1f4,_0x2a2167['message']));});});};exports['ShowOpenchannelQueue']=function(_0x515fcc){var _0xe3259b=this;return new Promise(function(_0x4cefb3,_0x2697d0){return db['OpenchannelQueue'][_0x7998('0x24')]({'raw':_0x515fcc[_0x7998('0x1d')]?_0x515fcc[_0x7998('0x1d')][_0x7998('0x25')]===undefined?!![]:![]:!![],'where':_0x515fcc['options']?_0x515fcc[_0x7998('0x1d')]['where']||null:null,'attributes':_0x515fcc['options']?_0x515fcc[_0x7998('0x1d')]['attributes']||null:null,'include':_0x515fcc['options']?_0x515fcc[_0x7998('0x1d')][_0x7998('0x1f')]?_['map'](_0x515fcc['options'][_0x7998('0x1f')],function(_0x8844f9){return{'model':db[_0x8844f9['model']],'as':_0x8844f9['as'],'attributes':_0x8844f9['attributes'],'include':_0x8844f9['include']?_[_0x7998('0x21')](_0x8844f9[_0x7998('0x1f')],function(_0x11635d){return{'model':db[_0x11635d['model']],'as':_0x11635d['as'],'attributes':_0x11635d[_0x7998('0x22')],'include':_0x11635d['include']?_['map'](_0x11635d[_0x7998('0x1f')],function(_0x5dabe1){return{'model':db[_0x5dabe1[_0x7998('0x20')]],'as':_0x5dabe1['as'],'attributes':_0x5dabe1[_0x7998('0x22')]};}):[]};}):[]};}):[]:[]})[_0x7998('0x10')](function(_0x41b896){logger[_0x7998('0x11')](_0x7998('0x26'),_0x515fcc);logger[_0x7998('0x14')](_0x7998('0x26'),_0x515fcc,JSON[_0x7998('0x23')](_0x41b896));_0x4cefb3(_0x41b896);})['catch'](function(_0x2ac9c4){logger[_0x7998('0x16')](_0x7998('0x26'),_0x2ac9c4[_0x7998('0x18')],_0x515fcc);_0x2697d0(_0xe3259b[_0x7998('0x16')](0x1f4,_0x2ac9c4['message']));});});};