443ade2f2cc1710eb919bd8e284655254ea5ea76
[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 _0x7a65=['bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./dashboard.socket','register','info','Dashboard,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','moment'];(function(_0x4d71e8,_0x5a2ba6){var _0x52a5f4=function(_0x36d0f5){while(--_0x36d0f5){_0x4d71e8['push'](_0x4d71e8['shift']());}};_0x52a5f4(++_0x5a2ba6);}(_0x7a65,0x7c));var _0x57a6=function(_0x3b347a,_0x22a0cc){_0x3b347a=_0x3b347a-0x0;var _0x46f95f=_0x7a65[_0x3b347a];return _0x46f95f;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x57a6('0x0'));var BPromise=require(_0x57a6('0x1'));var rs=require(_0x57a6('0x2'));var fs=require('fs');var Redis=require(_0x57a6('0x3'));var db=require(_0x57a6('0x4'))['db'];var utils=require(_0x57a6('0x5'));var logger=require(_0x57a6('0x6'))('rpc');var config=require(_0x57a6('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x57a6('0x8')][_0x57a6('0x9')]({'port':0x232a});config[_0x57a6('0xa')]=_[_0x57a6('0xb')](config[_0x57a6('0xa')],{'host':_0x57a6('0xc'),'port':0x18eb});var socket=require(_0x57a6('0xd'))(new Redis(config[_0x57a6('0xa')]));require(_0x57a6('0xe'))[_0x57a6('0xf')](socket);function respondWithRpcPromise(_0x569d0b,_0x54c158,_0x46e77a){return new BPromise(function(_0x17739e,_0x24e365){return client['request'](_0x569d0b,_0x46e77a)['then'](function(_0xf1579a){logger[_0x57a6('0x10')](_0x57a6('0x11'),_0x54c158,_0x57a6('0x12'));logger[_0x57a6('0x13')]('Dashboard,\x20%s,\x20%s,\x20%s',_0x54c158,_0x57a6('0x12'),JSON[_0x57a6('0x14')](_0xf1579a));if(_0xf1579a[_0x57a6('0x15')]){if(_0xf1579a[_0x57a6('0x15')][_0x57a6('0x16')]===0x1f4){logger['error'](_0x57a6('0x11'),_0x54c158,_0xf1579a[_0x57a6('0x15')][_0x57a6('0x17')]);return _0x24e365(_0xf1579a[_0x57a6('0x15')][_0x57a6('0x17')]);}logger[_0x57a6('0x15')](_0x57a6('0x11'),_0x54c158,_0xf1579a[_0x57a6('0x15')][_0x57a6('0x17')]);return _0x17739e(_0xf1579a[_0x57a6('0x15')][_0x57a6('0x17')]);}else{logger['info'](_0x57a6('0x11'),_0x54c158,_0x57a6('0x12'));_0x17739e(_0xf1579a[_0x57a6('0x18')]['message']);}})['catch'](function(_0x343a5f){logger[_0x57a6('0x15')](_0x57a6('0x11'),_0x54c158,_0x343a5f);_0x24e365(_0x343a5f);});});}