12757886bb15aafdeb187867ad5cecd5dc05af4c
[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 _0xa96d=['debug','stringify','error','code','message','Dashboard,\x20%s,\x20%s','info','catch','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','redis','defaults','./dashboard.socket','register','request','then','request\x20sent'];(function(_0xeaa3bd,_0x166691){var _0x2e1174=function(_0x310580){while(--_0x310580){_0xeaa3bd['push'](_0xeaa3bd['shift']());}};_0x2e1174(++_0x166691);}(_0xa96d,0x8a));var _0xda96=function(_0x4d03d6,_0x438a06){_0x4d03d6=_0x4d03d6-0x0;var _0x22752e=_0xa96d[_0x4d03d6];return _0x22752e;};'use strict';var _=require(_0xda96('0x0'));var util=require(_0xda96('0x1'));var moment=require(_0xda96('0x2'));var BPromise=require(_0xda96('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xda96('0x4'))['db'];var utils=require(_0xda96('0x5'));var logger=require(_0xda96('0x6'))(_0xda96('0x7'));var config=require('../../config/environment');var jayson=require(_0xda96('0x8'));var client=jayson[_0xda96('0x9')][_0xda96('0xa')]({'port':0x232a});config[_0xda96('0xb')]=_[_0xda96('0xc')](config[_0xda96('0xb')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xda96('0xd'))[_0xda96('0xe')](socket);function respondWithRpcPromise(_0x25d6d7,_0x37dbc1,_0xecfc1d){return new BPromise(function(_0x1bf3bd,_0x358777){return client[_0xda96('0xf')](_0x25d6d7,_0xecfc1d)[_0xda96('0x10')](function(_0x275173){logger['info']('Dashboard,\x20%s,\x20%s',_0x37dbc1,_0xda96('0x11'));logger[_0xda96('0x12')]('Dashboard,\x20%s,\x20%s,\x20%s',_0x37dbc1,_0xda96('0x11'),JSON[_0xda96('0x13')](_0x275173));if(_0x275173[_0xda96('0x14')]){if(_0x275173[_0xda96('0x14')][_0xda96('0x15')]===0x1f4){logger[_0xda96('0x14')]('Dashboard,\x20%s,\x20%s',_0x37dbc1,_0x275173[_0xda96('0x14')][_0xda96('0x16')]);return _0x358777(_0x275173[_0xda96('0x14')][_0xda96('0x16')]);}logger[_0xda96('0x14')](_0xda96('0x17'),_0x37dbc1,_0x275173[_0xda96('0x14')][_0xda96('0x16')]);return _0x1bf3bd(_0x275173['error']['message']);}else{logger[_0xda96('0x18')](_0xda96('0x17'),_0x37dbc1,_0xda96('0x11'));_0x1bf3bd(_0x275173['result'][_0xda96('0x16')]);}})[_0xda96('0x19')](function(_0x2caaf9){logger['error'](_0xda96('0x17'),_0x37dbc1,_0x2caaf9);_0x358777(_0x2caaf9);});});}