e32dd320de606856220ed5087624f2b41a5ed39e
[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 _0x4510=['rpc','jayson/promise','http','redis','localhost','socket.io-emitter','register','request','then','request\x20sent','debug','Dashboard,\x20%s,\x20%s,\x20%s','stringify','error','code','Dashboard,\x20%s,\x20%s','message','info','result','catch','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x2020ea,_0x26fc4f){var _0x3657fe=function(_0x4cc17f){while(--_0x4cc17f){_0x2020ea['push'](_0x2020ea['shift']());}};_0x3657fe(++_0x26fc4f);}(_0x4510,0x1b8));var _0x0451=function(_0x4a919f,_0x553927){_0x4a919f=_0x4a919f-0x0;var _0x2cd4ab=_0x4510[_0x4a919f];return _0x2cd4ab;};'use strict';var _=require(_0x0451('0x0'));var util=require('util');var moment=require(_0x0451('0x1'));var BPromise=require(_0x0451('0x2'));var rs=require(_0x0451('0x3'));var fs=require('fs');var Redis=require(_0x0451('0x4'));var db=require(_0x0451('0x5'))['db'];var utils=require(_0x0451('0x6'));var logger=require(_0x0451('0x7'))(_0x0451('0x8'));var config=require('../../config/environment');var jayson=require(_0x0451('0x9'));var client=jayson['client'][_0x0451('0xa')]({'port':0x232a});config[_0x0451('0xb')]=_['defaults'](config[_0x0451('0xb')],{'host':_0x0451('0xc'),'port':0x18eb});var socket=require(_0x0451('0xd'))(new Redis(config[_0x0451('0xb')]));require('./dashboard.socket')[_0x0451('0xe')](socket);function respondWithRpcPromise(_0x34f667,_0x1f846d,_0x4353ab){return new BPromise(function(_0x59e982,_0x2d4531){return client[_0x0451('0xf')](_0x34f667,_0x4353ab)[_0x0451('0x10')](function(_0x4ce2fe){logger['info']('Dashboard,\x20%s,\x20%s',_0x1f846d,_0x0451('0x11'));logger[_0x0451('0x12')](_0x0451('0x13'),_0x1f846d,'request\x20sent',JSON[_0x0451('0x14')](_0x4ce2fe));if(_0x4ce2fe['error']){if(_0x4ce2fe[_0x0451('0x15')][_0x0451('0x16')]===0x1f4){logger[_0x0451('0x15')](_0x0451('0x17'),_0x1f846d,_0x4ce2fe[_0x0451('0x15')]['message']);return _0x2d4531(_0x4ce2fe[_0x0451('0x15')][_0x0451('0x18')]);}logger['error'](_0x0451('0x17'),_0x1f846d,_0x4ce2fe[_0x0451('0x15')][_0x0451('0x18')]);return _0x59e982(_0x4ce2fe['error'][_0x0451('0x18')]);}else{logger[_0x0451('0x19')]('Dashboard,\x20%s,\x20%s',_0x1f846d,_0x0451('0x11'));_0x59e982(_0x4ce2fe[_0x0451('0x1a')]['message']);}})[_0x0451('0x1b')](function(_0x4588f6){logger['error']('Dashboard,\x20%s,\x20%s',_0x1f846d,_0x4588f6);_0x2d4531(_0x4588f6);});});}