eabae58ddcaf52860833e3c8f6798929e528e260
[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 _0x4ed5=['error','code','Dashboard,\x20%s,\x20%s','message','util','moment','bluebird','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','./dashboard.socket','register','request\x20sent','debug','stringify'];(function(_0x3d0abf,_0x4779d5){var _0x2bf259=function(_0x5389f8){while(--_0x5389f8){_0x3d0abf['push'](_0x3d0abf['shift']());}};_0x2bf259(++_0x4779d5);}(_0x4ed5,0x1a8));var _0x54ed=function(_0xfcd88b,_0x491084){_0xfcd88b=_0xfcd88b-0x0;var _0x29625c=_0x4ed5[_0xfcd88b];return _0x29625c;};'use strict';var _=require('lodash');var util=require(_0x54ed('0x0'));var moment=require(_0x54ed('0x1'));var BPromise=require(_0x54ed('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x54ed('0x3'));var logger=require(_0x54ed('0x4'))('rpc');var config=require(_0x54ed('0x5'));var jayson=require(_0x54ed('0x6'));var client=jayson[_0x54ed('0x7')][_0x54ed('0x8')]({'port':0x232a});config['redis']=_[_0x54ed('0x9')](config[_0x54ed('0xa')],{'host':_0x54ed('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x54ed('0xa')]));require(_0x54ed('0xc'))[_0x54ed('0xd')](socket);function respondWithRpcPromise(_0xe1998a,_0x1730fd,_0xe60421){return new BPromise(function(_0x442b05,_0xef7556){return client['request'](_0xe1998a,_0xe60421)['then'](function(_0x17da8e){logger['info']('Dashboard,\x20%s,\x20%s',_0x1730fd,_0x54ed('0xe'));logger[_0x54ed('0xf')]('Dashboard,\x20%s,\x20%s,\x20%s',_0x1730fd,_0x54ed('0xe'),JSON[_0x54ed('0x10')](_0x17da8e));if(_0x17da8e[_0x54ed('0x11')]){if(_0x17da8e[_0x54ed('0x11')][_0x54ed('0x12')]===0x1f4){logger['error'](_0x54ed('0x13'),_0x1730fd,_0x17da8e[_0x54ed('0x11')]['message']);return _0xef7556(_0x17da8e[_0x54ed('0x11')][_0x54ed('0x14')]);}logger[_0x54ed('0x11')](_0x54ed('0x13'),_0x1730fd,_0x17da8e[_0x54ed('0x11')][_0x54ed('0x14')]);return _0x442b05(_0x17da8e[_0x54ed('0x11')][_0x54ed('0x14')]);}else{logger['info'](_0x54ed('0x13'),_0x1730fd,_0x54ed('0xe'));_0x442b05(_0x17da8e['result'][_0x54ed('0x14')]);}})['catch'](function(_0x510348){logger[_0x54ed('0x11')]('Dashboard,\x20%s,\x20%s',_0x1730fd,_0x510348);_0xef7556(_0x510348);});});}