936555f4456de58d51b86cc50e38fe79ef64d4aa
[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 _0xb045=['./dashboard.socket','register','request','request\x20sent','debug','Dashboard,\x20%s,\x20%s,\x20%s','stringify','error','Dashboard,\x20%s,\x20%s','message','info','result','catch','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','defaults','localhost'];(function(_0x264e33,_0x38d36e){var _0x555826=function(_0x42a2a5){while(--_0x42a2a5){_0x264e33['push'](_0x264e33['shift']());}};_0x555826(++_0x38d36e);}(_0xb045,0x1d8));var _0x5b04=function(_0x574d9b,_0x2063da){_0x574d9b=_0x574d9b-0x0;var _0x31d2a5=_0xb045[_0x574d9b];return _0x31d2a5;};'use strict';var _=require(_0x5b04('0x0'));var util=require(_0x5b04('0x1'));var moment=require(_0x5b04('0x2'));var BPromise=require(_0x5b04('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x5b04('0x4'))['db'];var utils=require(_0x5b04('0x5'));var logger=require(_0x5b04('0x6'))(_0x5b04('0x7'));var config=require(_0x5b04('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x5b04('0x9')][_0x5b04('0xa')]({'port':0x232a});config[_0x5b04('0xb')]=_[_0x5b04('0xc')](config[_0x5b04('0xb')],{'host':_0x5b04('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x5b04('0xb')]));require(_0x5b04('0xe'))[_0x5b04('0xf')](socket);function respondWithRpcPromise(_0x40b909,_0xa2745,_0x2136c1){return new BPromise(function(_0x393a30,_0x33ea3e){return client[_0x5b04('0x10')](_0x40b909,_0x2136c1)['then'](function(_0x244ef7){logger['info']('Dashboard,\x20%s,\x20%s',_0xa2745,_0x5b04('0x11'));logger[_0x5b04('0x12')](_0x5b04('0x13'),_0xa2745,'request\x20sent',JSON[_0x5b04('0x14')](_0x244ef7));if(_0x244ef7[_0x5b04('0x15')]){if(_0x244ef7[_0x5b04('0x15')]['code']===0x1f4){logger[_0x5b04('0x15')](_0x5b04('0x16'),_0xa2745,_0x244ef7[_0x5b04('0x15')][_0x5b04('0x17')]);return _0x33ea3e(_0x244ef7[_0x5b04('0x15')][_0x5b04('0x17')]);}logger['error'](_0x5b04('0x16'),_0xa2745,_0x244ef7[_0x5b04('0x15')]['message']);return _0x393a30(_0x244ef7[_0x5b04('0x15')][_0x5b04('0x17')]);}else{logger[_0x5b04('0x18')]('Dashboard,\x20%s,\x20%s',_0xa2745,_0x5b04('0x11'));_0x393a30(_0x244ef7[_0x5b04('0x19')]['message']);}})[_0x5b04('0x1a')](function(_0x465efd){logger[_0x5b04('0x15')](_0x5b04('0x16'),_0xa2745,_0x465efd);_0x33ea3e(_0x465efd);});});}