d3021e7c4108883743e8606084782361491bcb1b
[motion2.git] / server / api / dashboard / dashboard.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 _0xd7b2=['rpc','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','register','request','then','info','Dashboard,\x20%s,\x20%s','debug','Dashboard,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','util','bluebird','ioredis','../../mysqldb','../../config/utils'];(function(_0x209240,_0x3ba77f){var _0x1a67dd=function(_0x51b7eb){while(--_0x51b7eb){_0x209240['push'](_0x209240['shift']());}};_0x1a67dd(++_0x3ba77f);}(_0xd7b2,0x1c6));var _0x2d7b=function(_0x193d87,_0x4e835d){_0x193d87=_0x193d87-0x0;var _0x395db7=_0xd7b2[_0x193d87];return _0x395db7;};'use strict';var _=require('lodash');var util=require(_0x2d7b('0x0'));var moment=require('moment');var BPromise=require(_0x2d7b('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x2d7b('0x2'));var db=require(_0x2d7b('0x3'))['db'];var utils=require(_0x2d7b('0x4'));var logger=require('../../config/logger')(_0x2d7b('0x5'));var config=require(_0x2d7b('0x6'));var jayson=require(_0x2d7b('0x7'));var client=jayson[_0x2d7b('0x8')][_0x2d7b('0x9')]({'port':0x232a});config['redis']=_[_0x2d7b('0xa')](config[_0x2d7b('0xb')],{'host':_0x2d7b('0xc'),'port':0x18eb});var socket=require(_0x2d7b('0xd'))(new Redis(config[_0x2d7b('0xb')]));require('./dashboard.socket')[_0x2d7b('0xe')](socket);function respondWithRpcPromise(_0x51acc3,_0x462dcd,_0xc632fa){return new BPromise(function(_0x104cde,_0x58a3cc){return client[_0x2d7b('0xf')](_0x51acc3,_0xc632fa)[_0x2d7b('0x10')](function(_0x22d519){logger[_0x2d7b('0x11')](_0x2d7b('0x12'),_0x462dcd,'request\x20sent');logger[_0x2d7b('0x13')](_0x2d7b('0x14'),_0x462dcd,_0x2d7b('0x15'),JSON[_0x2d7b('0x16')](_0x22d519));if(_0x22d519[_0x2d7b('0x17')]){if(_0x22d519['error']['code']===0x1f4){logger['error'](_0x2d7b('0x12'),_0x462dcd,_0x22d519[_0x2d7b('0x17')]['message']);return _0x58a3cc(_0x22d519[_0x2d7b('0x17')]['message']);}logger[_0x2d7b('0x17')]('Dashboard,\x20%s,\x20%s',_0x462dcd,_0x22d519[_0x2d7b('0x17')][_0x2d7b('0x18')]);return _0x104cde(_0x22d519[_0x2d7b('0x17')][_0x2d7b('0x18')]);}else{logger['info'](_0x2d7b('0x12'),_0x462dcd,'request\x20sent');_0x104cde(_0x22d519[_0x2d7b('0x19')][_0x2d7b('0x18')]);}})[_0x2d7b('0x1a')](function(_0x959126){logger[_0x2d7b('0x17')](_0x2d7b('0x12'),_0x462dcd,_0x959126);_0x58a3cc(_0x959126);});});}